1+ import ipaddress
2+ from rich import print
13from bugscanx .utils .prompts import get_input , get_confirm
2- from bugscanx .utils .cidr import read_cidrs_from_file
4+
5+
6+ def read_cidrs_from_file (filepath ):
7+ valid_cidrs = []
8+ try :
9+ with open (filepath , 'r' ) as file :
10+ for line in file :
11+ line = line .strip ()
12+ if not line :
13+ continue
14+ try :
15+ ipaddress .ip_network (line , strict = False )
16+ valid_cidrs .append (line )
17+ except ValueError :
18+ pass
19+
20+ return valid_cidrs
21+ except Exception as e :
22+ print (f"[bold red]Error reading file: { e } [/bold red]" )
23+ return []
324
425
526def get_cidr_ranges_from_input (cidr_input ):
@@ -26,7 +47,7 @@ def get_host_input():
2647 cidr = get_input ("Enter CIDR range(s)" , validators = "cidr" , mandatory = False )
2748 if not cidr :
2849 cidr_file = get_input (
29- "Enter CIDR file" , input_type = "file" )
50+ "Enter CIDR file" , input_type = "file" , validators = "file" )
3051 cidr = read_cidrs_from_file (cidr_file ) if cidr_file else None
3152 return None , cidr
3253 return filename , None
@@ -84,14 +105,14 @@ def get_input_proxy():
84105 if filename is None and cidr is None :
85106 return None , None , None
86107
87- target_url = get_input ("Enter target url" , default = "in1.wstunnel.site" )
108+ target_url = get_input ("Enter target url" , default = "in1.wstunnel.site" , validators = "required" )
88109 default_payload = (
89110 "GET / HTTP/1.1[crlf]"
90111 "Host: [host][crlf]"
91112 "Connection: Upgrade[crlf]"
92113 "Upgrade: websocket[crlf][crlf]"
93114 )
94- payload = get_input ("Enter payload" , default = default_payload )
115+ payload = get_input ("Enter payload" , default = default_payload , validators = "required" )
95116 port_list = get_input ("Enter port(s)" , validators = "number" , default = "80" ).split (',' )
96117 output , threads = get_common_inputs ()
97118
@@ -139,15 +160,15 @@ def get_input_proxy2():
139160 transformer = lambda result : ', ' .join (result ) if isinstance (result , list ) else result
140161 )
141162
142- proxy = get_input ("Enter proxy" , instruction = "(proxy:port)" )
163+ proxy = get_input ("Enter proxy" , instruction = "(proxy:port)" , validators = "required" )
143164
144165 use_auth = get_confirm (" Use proxy authentication?" )
145166 proxy_username = None
146167 proxy_password = None
147168
148169 if use_auth :
149- proxy_username = get_input ("Enter proxy username" )
150- proxy_password = get_input ("Enter proxy password" )
170+ proxy_username = get_input ("Enter proxy username" , validators = "required" )
171+ proxy_password = get_input ("Enter proxy password" , validators = "required" )
151172
152173 if cidr :
153174 try :
0 commit comments