This repository has been archived by the owner on Feb 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
181 lines (160 loc) · 8.77 KB
/
run.py
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import requests
import nmap
from dnsdumpster.DNSDumpsterAPI import DNSDumpsterAPI
from colorama import Fore, Style, init
init(autoreset=True)
def print_banner(message, width=80):
banner_lines = message.strip().split('\n')
centered_banner = "\n".join([line.center(width) for line in banner_lines])
print(centered_banner)
print("=" * width)
def get_real_ip(domain):
try:
res = DNSDumpsterAPI().search(domain)
ip_addresses = [record['ip'] for record in res.get('dns_records', {}).get('host', []) if record.get('ip')]
return ip_addresses
except Exception as e:
print(f"{Fore.RED}Error retrieving DNS information for {domain}: {e}")
return []
def get_ip_location(ip):
try:
response = requests.get(f"https://ipinfo.io/{ip}/json")
return response.json()
except requests.RequestException as e:
print(f"{Fore.RED}Error fetching location for IP {ip}: {e}")
return None
def scan_ports(ip, port_range='1-1024'):
nm = nmap.PortScanner()
try:
nm.scan(ip, port_range)
return nm[ip]
except Exception as e:
print(f"{Fore.RED}Error scanning ports for IP {ip}: {e}")
return None
def scan_vulnerabilities(ip):
nm = nmap.PortScanner()
try:
nm.scan(ip, arguments='--script vuln')
return nm[ip]
except Exception as e:
print(f"{Fore.RED}Error scanning vulnerabilities for IP {ip}: {e}")
return None
def comprehensive_scan(ip):
nm = nmap.PortScanner()
try:
nm.scan(ip, arguments='-p- -A')
return nm[ip]
except Exception as e:
print(f"{Fore.RED}Error performing comprehensive scan for IP {ip}: {e}")
return None
if __name__ == "__main__":
banner = """
.-./`) .-'''-. ,-----. ,---------. ____ .--. .--. ____
\ .-.') / _ \ .' .-, '.\ \ .' __ `. | | _/ / .' __ `.
/ `-' \ (`' )/`--' / ,-.| \ _ \`--. ,---'/ ' \ \| (`' ) / / ' \ \
`-'`"`(_ o _). ; \ '_ / | : | \ |___| / ||(_ ()_) |___| / |
.---. (_,_). '. | _`,/ \ _/ | :_ _: _.-` || (_,_) __ _.-` |
| | .---. \ :: ( '\_/ \ ; (_I_) .' _ || |\ \ | |.' _ |
| | \ `-' | \ `"/ \ ) / (_(=)_) | _( )_ || | \ `' /| _( )_ |
| | \ / '. \_/``".' (_I_) \ (_ o _) /| | \ / \ (_ o _) /
'---' `-...-' '-----' '---' '.(_,_).' `--' `'-' '.(_,_).'
Isotaka Nobomaro ====> MA ======> IG: isotaka.nobomaro
"""
print_banner(banner)
domain = input("Enter the domain: ")
ip_addresses = get_real_ip(domain)
if ip_addresses:
print(f"Possible real IP addresses and their locations for {domain}:")
for ip in ip_addresses:
location_info = get_ip_location(ip)
if location_info:
print(f"{Fore.GREEN}[*] IP: {ip}")
print(f"{Fore.GREEN}[*] Location: {location_info.get('city')}, {location_info.get('region')}, {location_info.get('country')}")
print(f"{Fore.GREEN}[*] Organization: {location_info.get('org')}")
print(f"{Fore.GREEN}[*] Coordinates: {location_info.get('loc')}")
print("-" * 40)
else:
print(f"{Fore.GREEN}[*] IP: {ip}")
print("Location information not available")
print("-" * 40)
while True:
print(f"Select a scanning option for IP {ip}:")
print(f"{Fore.BLUE}1. Port Scan (Default: ports 1-1024)")
print(f"{Fore.BLUE}2. Vulnerability Scan")
print(f"{Fore.BLUE}3. Comprehensive Scan (All ports, OS detection, service detection, etc.)")
print(f"{Fore.BLUE}4. Custom Port Range Scan")
print(f"{Fore.BLUE}5. Exit")
choice = input("Enter your choice (1-5): ")
print("=" * 40)
if choice == '1':
print(f"Scanning ports for IP {ip}:")
scan_result = scan_ports(ip)
if scan_result:
for proto in scan_result.all_protocols():
for port in scan_result[proto]:
details = scan_result[proto][port]
state = details['state']
name = details['name']
product = details.get('product', 'N/A')
version = details.get('version', 'N/A')
print(f"{Fore.GREEN}[*] Port: {port}\tState: {state}\tService: {name}\tVersion: {product} {version}")
else:
print(f"{Fore.GREEN}[*] No port information available")
print("=" * 40)
elif choice == '2':
print(f"Scanning vulnerabilities for IP {ip}:")
vuln_result = scan_vulnerabilities(ip)
if vuln_result:
for proto in vuln_result.all_protocols():
for port in vuln_result[proto]:
details = vuln_result[proto][port]
state = details['state']
name = details['name']
script_results = details.get('script', {})
print(f"{Fore.GREEN}[*] Port: {port}\tState: {state}\tService: {name}")
for script_name, script_output in script_results.items():
print(f"{Fore.GREEN}[VULN] {script_name}: {script_output}")
else:
print(f"{Fore.GREEN}[*] No vulnerability information available")
print("=" * 40)
elif choice == '3':
print(f"Performing comprehensive scan for IP {ip}:")
comp_result = comprehensive_scan(ip)
if comp_result:
for proto in comp_result.all_protocols():
for port in comp_result[proto]:
details = comp_result[proto][port]
state = details['state']
name = details['name']
product = details.get('product', 'N/A')
version = details.get('version', 'N/A')
print(f"{Fore.GREEN}[*] Port: {port}\tState: {state}\tService: {name}\tVersion: {product} {version}")
script_results = details.get('script', {})
for script_name, script_output in script_results.items():
print(f"{Fore.GREEN}[VULN] {script_name}: {script_output}")
else:
print(f"{Fore.GREEN}[*] No comprehensive information available")
print("=" * 40)
elif choice == '4':
port_range = input("Enter custom port range (e.g., 1-1000): ")
print(f"Scanning custom port range {port_range} for IP {ip}:")
scan_result = scan_ports(ip, port_range)
if scan_result:
for proto in scan_result.all_protocols():
for port in scan_result[proto]:
details = scan_result[proto][port]
state = details['state']
name = details['name']
product = details.get('product', 'N/A')
version = details.get('version', 'N/A')
print(f"{Fore.GREEN}[*] Port: {port}\tState: {state}\tService: {name}\tVersion: {product} {version}")
else:
print(f"{Fore.GREEN}[*] No port information available")
print("=" * 40)
elif choice == '5':
break
else:
print(f"{Fore.RED}Invalid choice. Please select a valid option.")
print("=" * 40)
else:
print(f"No IP addresses found for {domain}")