-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathespionage
More file actions
executable file
·99 lines (86 loc) · 2.84 KB
/
espionage
File metadata and controls
executable file
·99 lines (86 loc) · 2.84 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/python3
import argparse
import os
import sys
import subprocess
from pathlib import Path
from TUI.espionage import *
def get_version():
"""Read version from ~/.local/share/espionage/VERSION file"""
version_file = Path.home() / ".local" / "share" / "espionage" / "VERSION"
try:
with open(version_file, 'r') as f:
return f.read().strip()
except FileNotFoundError:
return "Version file not found"
except Exception as e:
return f"Error reading version: {e}"
def run_uninstall():
"""Execute the uninstall script"""
uninstall_script = Path.home() / ".local" / "share" / "espionage" / "uninstall.sh"
try:
if not uninstall_script.exists():
print(f"Error: Uninstall script not found at {uninstall_script}")
sys.exit(1)
# Make sure the script is executable
os.chmod(uninstall_script, 0o755)
# Execute the uninstall script
result = subprocess.run([str(uninstall_script)], check=True)
sys.exit(result.returncode)
except subprocess.CalledProcessError as e:
print(f"Error running uninstall script: {e}")
sys.exit(1)
except Exception as e:
print(f"Unexpected error: {e}")
sys.exit(1)
def create_parser():
"""Create and configure argument parser"""
parser = argparse.ArgumentParser(
prog='espionage',
description='ESPionage - A TUI application for ESP based firmware analysis',
epilog="""
Examples:
espionage Start the TUI interface
espionage --version Display version information
espionage -v Display version information (short form)
espionage --help Show this help message
espionage -h Show this help message (short form)
espionage --uninstall Uninstall ESPionage from the system
""",
formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument(
'-v', '--version',
action='store_true',
help='Print version information'
)
parser.add_argument(
'--uninstall',
action='store_true',
help='Execute uninstall script to remove ESPionage'
)
return parser
def main():
parser = create_parser()
args = parser.parse_args()
# Handle version flag
if args.version:
version = get_version()
print(version)
sys.exit(0)
# Handle uninstall flag
if args.uninstall:
print("Uninstalling ESPionage...")
run_uninstall()
# If no arguments provided, start the TUI
try:
app = ESPionage()
app.run()
except KeyboardInterrupt:
print("\nESPionage terminated by user.")
sys.exit(0)
except Exception as e:
print(f"Error starting ESPionage: {e}")
sys.exit(1)
if __name__ == "__main__":
main()