-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeywatch.py
More file actions
37 lines (34 loc) · 1.26 KB
/
Keywatch.py
File metadata and controls
37 lines (34 loc) · 1.26 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
import argparse
import sys
from keylogger import KeyLogger
from gui import run_gui
def main():
parser = argparse.ArgumentParser(
description="KeyWatch: Ethical Cross-platform Keylogger Tool"
)
parser.add_argument('--cli', action='store_true', help='Run KeyWatch in CLI mode')
parser.add_argument('--gui', action='store_true', help='Run KeyWatch in GUI mode')
parser.add_argument('--logfile', type=str, default='keywatch.log', help='Path to log file')
parser.add_argument('--view', action='store_true', help='View logged keystrokes (CLI only)')
args = parser.parse_args()
if args.gui:
run_gui()
elif args.cli:
if args.view:
try:
with open(args.logfile, "r") as f:
print(f.read())
except Exception as e:
print(f"Error reading log file: {e}")
else:
print("Starting KeyWatch in CLI mode. Press Ctrl+C to stop.")
print("For educational and authorized use only!")
keylogger = KeyLogger(args.logfile)
try:
keylogger.start()
except KeyboardInterrupt:
print("\nKeyWatch stopped.")
else:
parser.print_help()
if __name__ == "__main__":
main()