-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
151 lines (118 loc) · 4.82 KB
/
Copy pathsetup.py
File metadata and controls
151 lines (118 loc) · 4.82 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
import os
import sys
import subprocess
import shutil
from colorama import Fore, Style, init
init(autoreset=True)
VERSION = "1.0"
SCAN_PROFILES = {
"1": {
"name": "SYN Scan (Stealth)",
"cmd": "sudo nmap -sS",
"desc": "Half-open scan, less likely to be logged",
},
"2": {
"name": "Service & OS Detection",
"cmd": "sudo nmap -sV -O",
"desc": "Identifies running services and operating system",
},
"3": {
"name": "Aggressive Scan",
"cmd": "sudo nmap -A",
"desc": "OS detection, version, scripts and traceroute",
},
"4": {
"name": "Quick Port Scan",
"cmd": "nmap -F",
"desc": "Scans the 100 most common ports",
},
"5": {
"name": "UDP Scan",
"cmd": "sudo nmap -sU",
"desc": "Scans UDP ports (may take longer)",
},
"6": {
"name": "Skip Host Discovery",
"cmd": "sudo nmap -Pn",
"desc": "Treats host as online, skips ping",
},
"7": {
"name": "NSE Vuln Scan",
"cmd": "sudo nmap --script=vuln",
"desc": "Runs vulnerability detection scripts",
},
"8": {
"name": "Ping Sweep",
"cmd": "nmap -sn",
"desc": "Discovers live hosts on a network",
},
}
def check_nmap():
"""Make sure nmap is installed before doing anything."""
if shutil.which("nmap") is None:
print(f"\n {Fore.RED}[!] nmap not found in PATH. Install it first.{Style.RESET_ALL}\n")
sys.exit(1)
def clear():
os.system("cls" if os.name == "nt" else "clear")
def banner():
art = f"""{Fore.CYAN}{Style.BRIGHT}
█████╗ ██╗ ██╗████████╗ ██████╗
██╔══██╗██║ ██║╚══██╔══╝██╔═══██╗
███████║██║ ██║ ██║ ██║ ██║
██╔══██║██║ ██║ ██║ ██║ ██║
██║ ██║╚██████╔╝ ██║ ╚██████╔╝ {Fore.WHITE}By Davi Moreira Pereira
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ {Fore.WHITE}GitHub: davimoreira0{Fore.CYAN}
███╗ ██╗███╗ ███╗ █████╗ ██████╗
████╗ ██║████╗ ████║██╔══██╗██╔══██╗
██╔██╗ ██║██╔████╔██║███████║██████╔╝
██║╚██╗██║██║╚██╔╝██║██╔══██║██╔═══╝
██║ ╚████║██║ ╚═╝ ██║██║ ██║██║
╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ {Fore.WHITE}v{VERSION}
{Style.RESET_ALL}"""
print(art)
def run_scan(profile_key, target):
"""Execute the nmap command for a given profile and target."""
profile = SCAN_PROFILES[profile_key]
full_cmd = f"{profile['cmd']} {target}"
print(f"\n {Fore.GREEN}$ {full_cmd}{Style.RESET_ALL}\n")
ret = os.system(full_cmd)
if ret != 0:
print(f"\n {Fore.YELLOW}[*] nmap exited with code {ret >> 8}{Style.RESET_ALL}")
print()
input(f" {Fore.CYAN}Press ENTER to continue...{Style.RESET_ALL}")
def prompt_target():
"""Ask the user for a target IP/hostname."""
target = input(f" {Fore.CYAN}Target (IP or hostname): {Style.RESET_ALL}").strip()
if not target:
print(f" {Fore.RED}[!] No target provided.{Style.RESET_ALL}")
return None
return target
def menu():
"""Print available scan options."""
print(f" {Fore.WHITE}{Style.BRIGHT}SCAN OPTIONS{Style.RESET_ALL}\n")
for key, profile in SCAN_PROFILES.items():
num = f"{Fore.BLUE}{Style.BRIGHT}[{key}]{Style.RESET_ALL}"
name = f"{Fore.CYAN}{profile['name']}{Style.RESET_ALL}"
desc = f"{Fore.WHITE}{Style.DIM}{profile['desc']}{Style.RESET_ALL}"
print(f" {num} {name} {desc}")
print(f"\n {Fore.BLUE}{Style.BRIGHT}[0]{Style.RESET_ALL} {Fore.CYAN}Exit{Style.RESET_ALL}\n")
def main():
check_nmap()
while True:
clear()
banner()
menu()
choice = input(f" {Fore.CYAN}>> {Style.RESET_ALL}").strip()
if choice == "0":
print(f"\n {Fore.CYAN}Bye.{Style.RESET_ALL}\n")
break
if choice not in SCAN_PROFILES:
input(f" {Fore.RED}[!] Invalid option. Press ENTER...{Style.RESET_ALL}")
continue
target = prompt_target()
if target is None:
continue
run_scan(choice, target)
if __name__ == "__main__":
main()