-
Notifications
You must be signed in to change notification settings - Fork 1
/
basicFunctions.py
82 lines (63 loc) · 2.09 KB
/
basicFunctions.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
from termcolor import *
import colorama
colorama.init()
portRange = []
default_ports = []
clean_range = []
split = []
def manualPorts():
while True:
user_ports = input("Enter ports separated with comma ',': ")
def_ports = user_ports.split(",")
try:
for p in def_ports:
portRange.append(int(p))
except:
cprint("Invalid Ports detected!!!", "red")
portRange[:] = []
for q in portRange:
if q > 0 and q <= 65535:
return portRange
continue
else:
cprint("Invalid Ports detected!!!", "red")
portRange[:] = []
break
def preDefinedPorts():
default_ports = [21, 22, 23, 25, 53, 80, 110, 137, 138, 139, 445, 443, 554, 8080]
portRange = default_ports
return portRange
def manualRange():
while True:
mrange = input("Enter Port range separated by '-' ")
if mrange.count("-") == 1:
split = mrange.split("-")
if len(split) == 2:
try:
for i in split:
clean_range.append(int(i))
for j in range(clean_range[0], clean_range[1]+1):
portRange.append(int(j))
except:
cprint("Invalid Port range detected!!! ", "red")
clean_range[:] = []
portRange[:] = []
continue
for q in portRange:
if q > 0 and q <= 65535:
return portRange
continue
else:
cprint("Invalid Ports detected!!!", "red")
portRange[:] = []
clean_range[:] = []
break
else:
cprint("Invalid Port range detected!!!", "red")
continue
else:
cprint("Invalid Port range detected!!!", "red")
continue
def unknownAction():
return False
# print manualRange()