-
Notifications
You must be signed in to change notification settings - Fork 0
/
dscan.py
343 lines (328 loc) · 14.3 KB
/
dscan.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
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Imports
import enumerator
import os, sys, traceback
import socket
import ipaddress as ip
from pathlib import Path
from terminaltables import DoubleTable
from tabulate import tabulate
from banner import xe_header
from time import sleep
#---------------------------------------------------------------
# Welcome screen and home screen in one
try:
def home():
# Configure the network interface and gateway...
global up_interface
up_interface = open('/opt/dscan/tools/files/iface.txt', 'r').read()
up_interface = up_interface.replace("\n","")
if up_interface == "0":
up_interface = os.popen("route | awk '/Iface/{getline; print $8}'").read()
up_interface = up_interface.replace("\n","")
global gateway
gateway = open('/opt/dscan/tools/files/gateway.txt', 'r').read()
gateway = gateway.replace("\n","")
if gateway == "0":
gateway = os.popen("ip route show | grep -i 'default via'| awk '{print $3 }'").read()
gateway = gateway.replace("\n","")
n_name = os.popen('iwgetid -r').read() # Get wireless network name
n_mac = os.popen("ip addr | grep 'state UP' -A1 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'").read() # Get network mac
n_ip = os.popen("hostname -I").read() # Local IP address
n_host = os.popen("hostname").read() # hostname
#-----------------------------------------------------------#
if not os.geteuid() == 0:
sys.exit("\n[!] DonkeyScanner must be run as root. ¯\_(ツ)_/¯ \n")
author = "CR4CKB0X (9R4M4N K4SL1W4L)"
print(xe_header())
print ("\t\t\t\t\t\t A complete Network-MAP-per\n")
print("Created By: "+author+"\nGit Account: https://github.com/Praman1997")
print("--------------------------------------------------------------------------")
print("\n\n")
# Printing the network configuration
table = [["IP Address","MAC Address","Gateway","Iface","Hostname"],
["","","","",""],
[n_ip,n_mac.upper(),gateway,up_interface,n_host]]
table = DoubleTable(table)
print (table.table)
print("----------------------------\n\n")
def options_list():
option_table = [["Command","Explanation..."],
["enum","Run ENUMERATOR!"],
["getip","Get IP Address from URL (I honestly didn't think that was possible!)"],
["make","List available IP Addresses (It's Basic, yo!)"],
["ipscan","IP Scan or Subnet Scan (Beginners' Stuff)"],
["idlescan","Idle or Zombie Scan ('WTF?!' Stuff)"],
["evasion","IDS, IPS or Firewall Evasion ('I know what I am doing...' Stuff)"],
["osscan","Operating System detection ('Woah!!! Magic!!!' Stuff)"],
["help","Show this list at any point of time"],
["banner","Show random banner (They are really cool...)"],
["cls","Clear Screen"],
["update","Update to current version of DonkeyScanner"],
["exit","Whimp out and go home!"]]
option_table = DoubleTable(option_table)
print (option_table.table)
def command():
try:
initial_choice = raw_input("dscan>> ")
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
if (initial_choice == "make"):
try:
make_list()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "enum"):
try:
run_enum()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "getip"):
try:
getIP()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "ipscan"):
try:
ip_scan()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "idlescan"):
try:
idle_scan()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "evasion"):
try:
evasion()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "osscan"):
try:
os_detection()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "help"):
try:
options_list()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "banner"):
try:
os.system("clear")
home()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "cls"):
try:
os.system("clear")
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "update"):
try:
update()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
elif (initial_choice == "exit"):
print ("[*] GoodBye!!!")
exit(0)
else:
try:
print ("Error 404: Command not found. Please try again!")
sleep(1)
print ("Note: Enter 'help' for command list...\n")
sleep(1)
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()
def update():
os.system("clear")
print ("[+] Updating DonkeyScanner! This may take a few minutes")
try:
os.system("git clone https://github.com/Praman1997/DonkeyScanner.git && cd DonkeyScanner && sudo python install.py && cd .. && sudo rm -rf DonkeyScanner/")
print ("[+] DonkeyScanner updated successfully... Please restart using 'dscan' command as before...")
except Exception as e:
print ("[-] Error while updating the DonkeyScanner...\n[*] In order to do it manually, please type the following commands:")
print ("[Step 1] git clone https://github.com/Praman1997/DonkeyScanner.git && cd DonkeyScanner")
print ("[Step 2] sudo python install.py\n\t[*] Once prompted, select the appropriate option...")
print ("[Step 3] cd .. && sudo rm -rf DonkeyScanner/")
print ("[Step 4] sudo dscan")
def make_list():
os.system("clear")
print(""" \033[1;36m
┌══════════════════════════════════════════════════════════════┐
█ █
█ Listing Available IP Addresses █
█ █
└══════════════════════════════════════════════════════════════┘ \033[1;m""")
subnet = raw_input("\n\nEnter subnet (Eg: 192.168.0.*): ")
command = "nmap -sn "+subnet+" | grep -o "+subnet+" > /opt/dscan/available_ip_addresses.txt "
os.system(command)
print ("List Complete...\n")
show_list = raw_input("Do you want to see the list? (y/n): ")
if (show_list == "y" or show_list == "Y"):
os.system('echo "Showing the list:\n" && cat /opt/dscan/available_ip_addresses.txt')
sleep (1)
def run_enum():
enumerator.run()
sleep (5)
def getIP():
os.system("clear")
print(""" \033[1;36m
┌══════════════════════════════════════════════════════════════┐
█ █
█ Get IP Address █
█ █
└══════════════════════════════════════════════════════════════┘ \033[1;m""")
url = raw_input("Enter URL: ")
print (socket.gethostbyname(url))
print ("Note: Copy the IP Address, I will wait for 5 seconds!")
sleep(5)
def ip_scan():
os.system("clear")
print(""" \033[1;36m
┌══════════════════════════════════════════════════════════════┐
█ █
█ The IP Scanner █
█ █
└══════════════════════════════════════════════════════════════┘ \033[1;m""")
address = raw_input("Enter IP or Subnet (Eg: 192.168.0.25 or 192.168.0.*): ")
scan_type = raw_input("Agressive Scan (A) or Stealth Scan (S): ")
if (scan_type == "A" or scan_type == "a"):
command = "nmap -sT -sV -v "+address+" "
elif (scan_type == "S" or scan_type == "s"):
command = "nmap -sS -sV -v "+address+" "
else:
print ("Incorrect Choice!!! It was either 'A' or 'S'... Are you thick?!!\n")
sleep(1)
os.system(command)
def idle_scan():
os.system("clear")
print(""" \033[1;36m
┌══════════════════════════════════════════════════════════════┐
█ █
█ Idle or Zombie Scan █
█ █
└══════════════════════════════════════════════════════════════┘ \033[1;m""")
table = [["code","Scan Type"],
["idle","Zombie Scan with unknown zombie (Specific Port) "],
["zomb","Zombie Scan with known zombie (Specific Port)"],
["IDLE","Zombie Scan with unknown zombie (Top 1000 ports)"],
["ZOMB","Zombie Scan with known zombie (Top 1000 ports)"],
["home","Go back to Home"]]
print (tabulate(table, stralign="center",tablefmt="fancy_grid",headers="firstrow"))
print ("")
scan_type = raw_input("dscan/idlescan>> ")
if (scan_type == "idle"):
target = raw_input("Enter Target IP: ")
port = raw_input("Enter Specific Port: ")
make_list()
file = open("/opt/dscan/available_ip_addresses.txt","r")
print("----------------------------------------------------")
for x in file.readline():
command = "nmap -Pn -p "+port+" -sI "+file.readline().strip()+" "+target+" "
print ("\nTarget: "+target+"\nZombie: "+file.readline().strip()+"\nPort: "+port+"\n")
os.system(command)
print("-------------------------------------------------------")
file.close()
elif (scan_type == "zomb"):
target = raw_input("Enter Target IP: ")
zombie = raw_input("Enter Zombie IP: ")
port = raw_input("Enter Specific Port: ")
command = "nmap -Pn -p"+port+" -sI "+zombie+" "+target+" "
print ("[+] Starting Zombie Scan for:\nTarget: "+target+"\nZombie: "+zombie+"\nPort: "+port+"\n")
os.system(command)
print("----------------------------------------------------")
elif (scan_type == "IDLE"):
target = raw_input("Enter Target IP: ")
make_list()
file = open("/opt/dscan/available_ip_addresses.txt","r")
print("----------------------------------------------------")
for x in file.readline():
command = "nmap -Pn -sI "+file.readline().strip()+" "+target+" "
print ("\nTarget: "+target+"\nZombie: "+file.readline().strip()+"\n")
os.system(command)
print("-------------------------------------------------------")
file.close()
elif (scan_type == "ZOMB"):
target = raw_input("Enter Target IP: ")
zombie = raw_input("Enter Zombie IP: ")
command = "nmap -Pn -sI "+zombie+" "+target+" "
print ("[+] Starting Zombie Scan for:\nTarget: "+target+"\nZombie: "+zombie+"\n")
os.system(command)
print("----------------------------------------------------")
elif (scan_type == "home"):
print("\n\n")
pass
else:
print ("Are you thick?! How was that even difficult?!")
sleep (2)
idle_scan()
def evasion():
os.system("clear")
print(""" \033[1;36m
┌══════════════════════════════════════════════════════════════┐
█ █
█ IDS/IPS/Firewall Evasion █
█ █
└══════════════════════════════════════════════════════════════┘ \033[1;m""")
target = raw_input("Enter Target: ")
port = raw_input("Enter specific port: ")
scantype = raw_input("Scan Type (tcp or udp): ")
if (scantype == "tcp" or scantype == "TCP"):
command = "nmap -p"+port+" --script firewall-bypass.nse "+target+" "
elif (scantype == "udp" or scantype == "UDP"):
command = "nmap -p"+port+" -sU --script firewall-bypass.nse "+target+" "
else:
print ("ThickHead!!! It was either tcp or udp... How difficult is that??!")
sleep(2)
evasion()
os.system(command)
def os_detection():
os.system("clear")
print(""" \033[1;36m
┌══════════════════════════════════════════════════════════════┐
█ █
█ OS Detection Scan █
█ █
└══════════════════════════════════════════════════════════════┘ \033[1;m""")
target = raw_input("Enter Target: ")
command = "nmap -O -sX "+target+" "
os.system(command)
except KeyboardInterrupt:
print ("\n[!] Keyboard Interrupt detected!\n")
print ("[-] DonkeyScanner Aborted!")
#-------------------------------------------------------------------------------------------
try:
os.system("clear")
home()
options_list()
command()
except KeyboardInterrupt as k:
print ("\n[*] Keyboard Interrupt Detected!")
command()