-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathscan.py
More file actions
179 lines (154 loc) · 5.73 KB
/
scan.py
File metadata and controls
179 lines (154 loc) · 5.73 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
#!/usr/bin/python3
"""
d9scan - by Adhrit
https://github.com/xadhrit/d9scan
"""
import socket
import os
import time
import sys
import argparse
import subprocess
import requests
from printcolors import *
from datetime import datetime
from urllib.parse import urljoin
from bs4 import BeautifulSoup as bs
# Main Function
def main():
socket.setdefaulttimeout(0.30)
#argument parser
parser = argparse.ArgumentParser(description='Network Scanning with d9scan')
parser.add_argument('target', type=str, help='Domain or IP address of Target')
args = parser.parse_args()
target = args.target
# Start scan with clear terminal
subprocess.call('clear', shell=True)
#welcome d9scan poison banner.
print("""
@@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@
@@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@@ @@@@@@@@ @@@@ @@@
@@! @@@ @@! @@@ !@@ !@@ @@! @@@ @@!@!@@@
!@! @!@ !@! @!@ !@! !@! !@! @!@ !@!!@!@!
@!@ !@! !!@!!@!! !!@@!! !@! @!@!@!@! @!@ !!@!
!@! !!! !!@!!! !!@!!! !!! !!!@!!!! !@! !!!
!!: !!! !!! !:! :!! !!: !!! !!: !!!
:!: !:! !:! !:! :!: :!: !:! :!: !:!
:::: :: ::::: :: :::: :: ::: ::: :: ::: :: ::
:: : : : : : :: : : :: :: : : : : :: : """)
print(" \n")
print("%s\t\td9scan - Network Scanner with Backdoor Detection + SYN protection filter scanning "%(yellow))
time.sleep(1)
print("\n")
#target = input("Enter your target IP address or URL here: ")
error = ("%sInvalid Input"%red)
try:
t_ip = socket.gethostbyname(target)
except (UnboundLocalError, socket.gaierror):
print("\n%s%sInvalid format. Please use a correct IP or web address\n"%(bad, red))
sys.exit()
print("Scanning target : {} - {} ".format(target,t_ip), end='')
print(" | Time started: "+ str(datetime.now()))
t1 = datetime.now()
def generalscan(target):
s = "nmap -v -A {}".format(target)
os.mkdir(target)
os.chdir(target)
print("%s"%(green))
os.system(s)
generalscan(target)
t2 = datetime.now()
total = t2 - t1
#print("Port scan completed in "+str(total))
print("^" * 60)
print("%s Recommended Nmap scan:"%white)
print("-" * 60)
#print("%snmap -p{ports} -sV -sC -T4 -Pn -oA {ip} {ip}".format(ports=",".join(discovered_ports), ip=target)%blue)
outfile = "nmap -sV --script=http-malware-host {ip}".format(ip=target)
print(outfile)
print("-" * 60)
backdoor = "nmap -sV --script http-dlink-backdoor {ip}".format(ip=target)
ftpbackdoor = "nmap --script ftp-proftpd-backdoor -p 21 {ip}".format(ip=target)
t3 = datetime.now()
total1 = t3 - t1
#Nmap Integration
def automate():
choice = '0'
while choice =='0':
print("Would you like to run Nmap or quit to terminal?")
print("%s0 = Run suggested Nmap scan"%green)
print("%s1 = Run Ftp backdoor Detection "%green)
print("%s2 = Run http-dlink BackDoor Detection"%green)
print("%s3 = Run another d9 scan"%green)
print("%s4 = Exit to terminal"%green)
choice = input("Option Selection: ")
if choice == "0":
try:
#print(yellow+outfile)
os.mkdir(target)
os.chdir(target)
os.system(outfile)
t3 = datetime.now()
total1 = t3 - t1
print("-" * 60)
print("Malware Detection scan completed in "+str(total1))
print("")
print("%sPress 1 to go back or enter to quit..."% white)
input()
except FileExistsError as e:
print(e)
exit()
elif choice == "1":
try:
#print(white+ftpbackdoor)
os.mkdir(target)
os.chdir(target)
os.system(ftpbackdoor)
t3 = datetime.now()
total1 = t3-t1
print("Ftp Backdoor Scan completed in "+str(total1))
print("%sPress 2 to go back and enter to quit..."%white)
uinput = input()
if uinput == '2':
automate()
elif uinput():
exit()
else:
sys.exit(0)
except FileExistsError as e:
print(e)
exit()
elif choice == "2":
try:
#print(red+backdoor)
os.mkdir(target)
os.chdir(target)
os.system(backdoor)
t3 = datetime.now()
total1 = t3-t1
print("Combined scan completed in " + str(total1))
print("%s Press 3 to go back and enter to quit..."%white)
uinput = input()
if uinput == '3':
automate()
elif uinput():
exit()
else:
sys.exit(0)
except FileExistsError as e:
print(e)
exit()
elif choice =="3":
main()
elif choice =="4":
sys.exit()
else:
print("%sPlease make a valid selection"%yellow)
automate()
automate()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("\n%sGoodbye!"%red)
quit()