-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasy_nmap.py
More file actions
288 lines (247 loc) · 8.81 KB
/
easy_nmap.py
File metadata and controls
288 lines (247 loc) · 8.81 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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
import os
import subprocess
import sys
banner = """
███████╗ █████╗ ███████╗██╗ ██╗ ███╗ ██╗███╗ ███╗ █████╗ ██████╗
██╔════╝██╔══██╗██╔════╝╚██╗ ██╔╝ ████╗ ██║████╗ ████║██╔══██╗██╔══██╗
█████╗ ███████║███████╗ ╚████╔╝ ██╔██╗ ██║██╔████╔██║███████║██████╔╝
██╔══╝ ██╔══██║╚════██║ ╚██╔╝ ██║╚██╗██║██║╚██╔╝██║██╔══██║██╔═══╝
███████╗██║ ██║███████║ ██║ ██║ ╚████║██║ ╚═╝ ██║██║ ██║██║
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝
----------------------------Author:DarkMRX--------------------------------
------------Youtube : CyberSL (https://youtu.be/pM7TeSrsXrI)--------------
"""
W = "\033[0m"
G = "\033[32;1m"
R = "\033[31;1m"
B = "\033[34;1m"
Y = "\033[33;1m"
def is_tools():
try:
devnull = open(os.devnull)
subprocess.Popen(["nmap"], stdout=devnull,
stderr=devnull).communicate()
except OSError as e:
if e.errno == os.errno.ENOENT:
return False
return True
def checkPlatform():
if(sys.platform == "linux"):
return True
elif(sys.platform == "linux2"):
return True
else:
return False
print(R + "[!]Error: Sorry This tool is only work for Linux os." + W)
exit(0)
def checkifExsistNmap():
if(is_tools() == False):
print("[!] Error: nmap not Found!")
print("[-] Info: Please Install nmap")
exit(0)
def waitekey():
input("Press Enter key to continue...")
def help():
os.system("clear")
print(B + banner + Y + """
Easy NMAP - Author:DarkMRX
Youtube Channel: CyberSL(Sinhala)
1. If you want to ignore discovery type '-Pn' flag before IP address
ex: IP/URL : -Pn 10.10.10.1
2. If you want to save all the output in to the .txt file type '-oN filename.txt' flag before IP address
ex: IP/URL : -oN result.txt 10.10.10.1
3. If you want to use any othe nmap flag(s) type it before IP address
ex: IP/URL : -sV -sV 10.10.10.1
Thanks for using this tool if you like this tool go and subscribe my youtube channel.
https://www.youtube.com/channel/UCKbiSLwJj8yMQ0Mg9AQZfcw
""" + W)
waitekey()
main()
def info_help():
print(Y + """
1. Host Scan (basic)
2. Port Scan
3. Services Discovery
98. Help
99. Exit
""" + W, "\n")
def checkHttp(host):
if ('https://' in host):
print(R + "\n[!]Error: Please Enter URL without 'https://' \n" + W)
return False
elif('http://'in host):
print(R + "\n[!]Error: Please Enter URL without 'http://' \n" + W)
return False
else:
return True
def ServicesDiscoveryMenu():
print(Y + """
1. Standard Service Detection
2. Detect OS and Services (Slow)
0. Back
""" + W)
def HostScanMenu():
print(Y + """
1. IP/Domain Scan
2. IP/Domain Scan (More Details)
3. IP/Domain Scan with OS Detection
4. IP/Domain Scan with OS Detection (Advance)
0. Back
""" + W)
def PortScanMenu():
print(Y + """
1. Scan Single/Multiple Port(s) or Port Range in Host/Hosts
2. Scan 100 Most Common Ports (Fast)
3. Scan All Ports (65535) (Very Slow)
4. Scan TCP Ports
5. Scan UDP Ports
0. Back
""" + W)
def ServicesDiscovery():
ServicesDiscoveryMenu()
try:
value = int(input("Enter : "))
print(
B + "\n[#]Hint: IP/URL/IP Range OR Subnet Ex: (10.10.10.1/24) \n" + W)
if (value == 1):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd = "nmap -sV {0}".format(hosts)
os.system(cmd)
waitekey()
ServicesDiscovery()
elif(value == 2):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd1 = "nmap -A {0}".format(hosts)
os.system(cmd1)
waitekey()
ServicesDiscovery()
elif(value == 0):
main()
else:
print(R + "[!] Error: Please Enter Valid Number" + W)
main()
except ValueError as e:
print(R + f"[!] Error:{e}" + W)
def portDiscovery():
PortScanMenu()
try:
value = int(input("Enter : "))
print(
B +
"""[#]Hint: IP/URL/IP Range OR Subnet Ex: (10.10.10.1/24)
[#]Hint: Port(s),Port Range Ex: 8080,21-59,443""" + W)
if(value == 1):
hosts = str(input("IP/URL : "))
ports = str(input("Port(s) : "))
if(checkHttp(host=hosts) == True):
cmd = "nmap -v -p {0} {1}".format(ports, hosts)
os.system(cmd)
waitekey()
portDiscovery()
elif(value == 2):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd1 = "nmap -v -F {0}".format(hosts)
os.system(cmd1)
waitekey()
portDiscovery()
elif(value == 3):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd2 = "nmap -v -p- {0}".format(hosts)
os.system(cmd2)
waitekey()
portDiscovery()
elif(value == 4):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd3 = "nmap -v -sT {0}".format(hosts)
os.system(cmd3)
waitekey()
portDiscovery()
elif(value == 5):
hosts = str(input("IP/URL : "))
ports = str(input("Port(s) : "))
if(checkHttp(host=hosts) == True):
cmd4 = "nmap -v -sU -p {0} {1}".format(ports, hosts)
os.system(cmd4)
waitekey()
portDiscovery()
elif(value == 0):
main()
else:
print(R + "[!] Error: Please Enter Valid Number" + W)
main()
except ValueError as e:
print(R + f"[!] Error:{e}" + W)
def hostDiscovery():
HostScanMenu()
try:
value = int(input("Enter : "))
print(
B + "\n[#]Hint: IP/URL/IP Range OR Subnet Ex: (10.10.10.1/24) \n" + W)
#hosts = str(input("IP/URL : "))
if(value == 1):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd = "nmap -v {0}".format(hosts)
os.system(cmd)
waitekey()
hostDiscovery()
elif(value == 2):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd1 = "nmap -v {0}".format(hosts)
os.system(cmd1)
waitekey()
hostDiscovery()
elif(value == 3):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd2 = "nmap -v -O {0}".format(hosts)
os.system(cmd2)
waitekey()
hostDiscovery()
elif(value == 4):
hosts = str(input("IP/URL : "))
if(checkHttp(host=hosts) == True):
cmd3 = "nmap -v -O --osscan-guess {0}".format(hosts)
os.system(cmd3)
waitekey()
hostDiscovery()
elif(value == 0):
main()
else:
print(R + "[!] Error: Please Enter Valid Number" + W)
main()
except ValueError as e:
print(R + f"[!] Error:{e}" + W)
def main():
checkPlatform()
os.system("clear")
print(banner)
checkifExsistNmap()
info_help()
value = int(input("Enter : "))
try:
if(value == 1):
hostDiscovery()
elif(value == 2):
portDiscovery()
elif(value == 3):
ServicesDiscovery()
elif(value == 98):
help()
elif(value == 99):
print(G + "Thank for using Easy Nmap.\n ~DarkMRX~" + W)
exit(0)
else:
print(R + "[!] Error: Please Enter Valid Number" + W)
waitekey()
main()
except ValueError as e:
print(R + f"[!] Error:{e}" + W)
if __name__ == '__main__':
main()