-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
105 lines (92 loc) · 3.88 KB
/
Copy pathmain.py
File metadata and controls
105 lines (92 loc) · 3.88 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
100
101
102
103
104
105
#!/usr/bin/env python3
"""
DeepNet - Network Packet Analyzer
Educational Network Analysis Tool
Author: DeepNet Team
Version: 1.0
IMPORTANT: This tool is for educational purposes only.
Only use on networks you own or have explicit permission to monitor.
Unauthorized packet sniffing may violate laws and regulations.
"""
import sys
import os
import argparse
from pathlib import Path
# Add the project root to Python path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def print_banner():
"""Print the DeepNet banner"""
banner = """
╔══════════════════════════════════════════════════════════════╗
║ DeepNet ║
║ Network Packet Analyzer ║
║ Version 1.0 ║
║ ║
║ ⚠️ FOR EDUCATIONAL PURPOSES ONLY ⚠️ ║
║ Only use on networks you own or have permission to monitor ║
╚══════════════════════════════════════════════════════════════╝
"""
print(banner)
def main():
"""Main entry point for DeepNet"""
print_banner()
parser = argparse.ArgumentParser(
description='DeepNet - Network Packet Analyzer',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python main.py gui # Launch GUI interface
python main.py cli # Launch CLI interface
python main.py cli --interface eth0 --count 100 # Capture 100 packets on eth0
"""
)
subparsers = parser.add_subparsers(dest='mode', help='Interface mode')
# GUI mode
gui_parser = subparsers.add_parser('gui', help='Launch GUI interface')
# CLI mode
cli_parser = subparsers.add_parser('cli', help='Launch CLI interface')
cli_parser.add_argument('-i', '--interface',
help='Network interface to sniff (e.g., eth0, Wi-Fi)')
cli_parser.add_argument('-c', '--count', type=int, default=0,
help='Number of packets to capture (0 for unlimited)')
cli_parser.add_argument('-f', '--filter',
help='Packet filter (e.g., "tcp port 80")')
cli_parser.add_argument('-o', '--output',
help='Output file to save packets')
cli_parser.add_argument('-v', '--verbose', action='store_true',
help='Enable verbose output')
# Parse arguments
args = parser.parse_args()
# Check if no arguments provided
if not args.mode:
parser.print_help()
return
try:
if args.mode == 'gui':
from gui import DeepNetGUI
app = DeepNetGUI()
app.run()
elif args.mode == 'cli':
from cli import DeepNetCLI
cli = DeepNetCLI(
interface=args.interface,
count=args.count,
filter_str=args.filter,
output_file=args.output,
verbose=args.verbose
)
cli.run()
except KeyboardInterrupt:
print("\n\n[INFO] DeepNet stopped by user")
except ImportError as e:
print(f"[ERROR] Missing required dependencies: {e}")
print("Please install required packages:")
print("pip install scapy tkinter")
except Exception as e:
print(f"[ERROR] An unexpected error occurred: {e}")
if args.mode == 'cli' and hasattr(args, 'verbose') and args.verbose:
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()