forked from NAWAK01/DevilScan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DevilScan.py
241 lines (204 loc) · 7.69 KB
/
DevilScan.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
# -*- coding: utf-8 -*-
import time
import socket
import os
import re
import subprocess
import sys
from datetime import datetime
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def mainmenu():
print bcolors.WARNING
print " . . ________ _______________ ____.___.____ "
print " /( )` \______ \ \_ _____/\ \ / /| | | "
print " \ \___ / | | | \ | __)_ \ Y / | | | "
print " /- _ `-/ ' | ` \| \ \ / | | |___"
print " (/\/ \ \ /\ /_______ /_______ / \___/ |___|_______ \ "
print " / / | ` \ \/ \/ \/ "
print " O O ) / | _________ _________ _____ _______ "
print " `-^--'`< ' / _____/ \_ ___ \ / _ \ \ \ "
print " (_.) _ ) / \_____ \ / \ \/ / /_\ \ / | \ "
print " `.___/` / / \ \ \____/ | \/ | \ "
print " `-----' / /_______ / \______ /\____|__ /\____|__ / "
print " <----. __ / __ \ \/ \/ \/ \/ "
print " <----|====O)))==) \) /==== "
print " <----' `--' `.__,' \ type 1 for open port testing"
print " | | type 2 for scann all ip connected to your network"
print " \ / type 3 to find hostname with ip"
print " ______( (_ / \___"
print " ,' ,-----' | \ "
print " `--{__________) \/ "
print " "
print bcolors.ENDC
choice = input("enter your choice : > ")
def choice1():
# Clear the screen
subprocess.call('clear', shell=True)
ipcheck = raw_input("Enter your network ip adress > ")
print "type 1 to display all ports witch are in testing"
print "type 2 to display only open ports"
print "type 3 to test only one specific port"
print "type 4 to test all port between to values"
print " "
choicescan = input("enter your choice > ")
if choicescan == 1:
print "wait, it will take a moment..."
for port in xrange(1, 65536):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((ipcheck, port))
if result == 0:
print bcolors.OKGREEN + ">>> Port ", port, " is open on network ", ipcheck
else:
print bcolors.WARNING + "Port ", port, " is not open"
choix = raw_input("Press [Q] to quit, [M] to go to previous menu, and [D] to go to main menu > ")
if choix in ("q", "Q"):
subprocess.Popen("exit", shell=True)
elif choix in ("m", "M"):
choice1()
elif choix in ("d", "D"):
mainmenu()
else:
print "invalid choice, exiting..."
time.sleep(3)
subprocess.Popen("exit", shell=True)
if choicescan == 2:
print "wait, it will take a moment..."
for port in xrange(1, 65536):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((ipcheck, port))
if result == 0:
print bcolors.OKGREEN + ">>> Port ", port, " is open on network ", ipcheck
choix = raw_input("Press [Q] to quit, [M] to go to previous menu, and [D] to go to main menu > ")
if choix in ("q", "Q"):
subprocess.Popen("exit", shell=True)
elif choix in ("m", "M"):
choice1()
elif choix in ("d", "D"):
mainmenu()
else:
print "invalid choice, exiting..."
time.sleep(3)
subprocess.Popen("exit", shell=True)
if choicescan == 3:
port = input("enter a port to check > ")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((ipcheck, port))
if result == 0:
print bcolors.OKGREEN + ">>> Port ", port, " is open on network ", ipcheck
else:
print bcolors.WARNING + "Port ", port, " is not open"
choix = raw_input("Press [Q] to quit, [M] to go to previous menu, and [D] to go to main menu > ")
if choix in ("q", "Q"):
subprocess.Popen("exit", shell=True)
elif choix in ("m", "M"):
choice1()
elif choix in ("d", "D"):
mainmenu()
else:
print "invalid choice, exiting..."
time.sleep(3)
subprocess.Popen("exit", shell=True)
if choicescan == 4:
rangemin = input("enter the minimum port value > ")
rangemax = input("enter the maximum port value > ")
for port in xrange(rangemin, rangemax):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((ipcheck, port))
if result == 0:
print bcolors.OKGREEN + ">>> Port ", port, " is open on network ", ipcheck
else:
print bcolors.WARNING + "Port ", port, " is not open"
choix = raw_input("Press [Q] to quit, [M] to go to previous menu, and [D] to go to main menu > ")
if choix in ("q", "Q"):
subprocess.Popen("exit", shell=True)
elif choix in ("m", "M"):
choice1()
elif choix in ("d", "D"):
mainmenu()
else:
print "invalid choice, exiting..."
time.sleep(3)
subprocess.Popen("exit", shell=True)
def choice2():
print "type 1 for display all ip witch are in testing"
print "type 2 for display only when a host is found"
choiceip = input("enter your choice > ")
if choiceip == 1:
with open(os.devnull, "wb") as limbo:
inputip = raw_input("enter your network ip like that : '192.168.1.' > ")
for n in xrange(1, 255):
ip=inputip + "{0}".format(n)
result=subprocess.Popen(["ping", "-c", "1", "-n", "-W", "2", ip],
stdout=limbo, stderr=limbo).wait()
if result:
print bcolors.OKBLUE +ip + bcolors.WARNING + " inactive"
else:
print bcolors.OKGREEN + ip + " active > HOST FOUND"
choix = raw_input("Press [Q] to quit, [M] to go to previous menu, and [D] to go to main menu > ")
if choix in ("q", "Q"):
subprocess.Popen("exit", shell=True)
elif choix in ("m", "M"):
choice2()
elif choix in ("d", "D"):
mainmenu()
else:
print "invalid choice, exiting..."
time.sleep(3)
subprocess.Popen("exit", shell=True)
if choiceip == 2:
with open(os.devnull, "wb") as limbo:
inputip = raw_input("enter your network ip like that : '192.168.1.' > ")
for n in xrange(1, 255):
ip=inputip + "{0}".format(n)
result=subprocess.Popen(["ping", "-c", "1", "-n", "-W", "2", ip],
stdout=limbo, stderr=limbo).wait()
if result:
time.sleep(0)
else:
print bcolors.OKGREEN + ip + " active > HOST FOUND"
choix = raw_input("Press [Q] to quit, [M] to go to previous menu, and [D] to go to main menu > ")
if choix in ("q", "Q"):
subprocess.Popen("exit", shell=True)
elif choix in ("m", "M"):
choice2()
elif choix in ("d", "D"):
mainmenu()
else:
print "invalid choice, exiting..."
time.sleep(3)
subprocess.Popen("exit", shell=True)
def choice3():
print "for find ip adress you can use function 2 of the main menu"
ip = raw_input("enter an ip > ")
try:
name, a, b = socket.gethostbyaddr(ip)
except:
name = "Not found"
if name != "Not found":
print name
choix = raw_input("Press [Q] to quit, and [D] to go to main menu > ")
if choix in ("q", "Q"):
subprocess.Popen("exit", shell=True)
elif choix in ("m", "M"):
choice3()
elif choix in ("d", "D"):
mainmenu()
else:
print "invalid choice, exiting..."
time.sleep(3)
subprocess.Popen("exit", shell=True)
if choice == 1:
choice1()
if choice == 2:
choice2()
if choice == 3:
choice3()
mainmenu()