Skip to content

Commit f89437c

Browse files
committed
refactor: rename text_ascii to ascii and update references; rename handlers to handler and minor formatings
1 parent 3e79ff1 commit f89437c

11 files changed

Lines changed: 44 additions & 50 deletions

File tree

bugscanx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def banner():
3333
""")
3434

3535

36-
def text_ascii(text, color="bold magenta", indentation=2):
36+
def ascii(text, color="bold magenta", indentation=2):
3737
clear_screen()
3838
ascii_banner = figlet.renderText(text)
3939
shifted_banner = "\n".join((" " * indentation) + line

bugscanx/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from rich import print
3-
from bugscanx import banner, text_ascii, handlers
3+
from . import banner, ascii, handler
44

55

66
MENU_OPTIONS = {
@@ -34,9 +34,9 @@ def main():
3434
if choice == '0':
3535
return
3636

37-
text_ascii(MENU_OPTIONS[choice][0])
37+
ascii(MENU_OPTIONS[choice][0])
3838
try:
39-
getattr(handlers, f'run_{choice}')()
39+
getattr(handler, f'run_{choice}')()
4040
print("\n[yellow] Press Enter to continue...", end="")
4141
input()
4242
except KeyboardInterrupt:

bugscanx/modules/others/file_toolkit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from rich.padding import Padding
1010
from rich.progress import Progress, TimeElapsedColumn
1111
from bugscanx.utils.prompts import get_input, get_confirm, clear_screen
12-
from bugscanx import text_ascii
12+
from bugscanx import ascii
1313

1414

1515
def read_lines(file_path):
@@ -287,7 +287,7 @@ def main():
287287

288288
action = options.get(choice)
289289
if not action:
290-
text_ascii("FILE TOOLKIT")
290+
ascii("FILE TOOLKIT")
291291
continue
292292

293293
desc, func, color = action
@@ -304,4 +304,4 @@ def main():
304304
except KeyboardInterrupt:
305305
pass
306306
finally:
307-
text_ascii("FILE TOOLKIT")
307+
ascii("FILE TOOLKIT")

bugscanx/modules/others/host_info.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
import socket
33
import http.client
44
from concurrent.futures import ThreadPoolExecutor, as_completed
5-
65
import requests
76
from rich import print
8-
97
from bugscanx.utils.prompts import get_input
108

119

bugscanx/modules/others/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def main():
172172
manager.restart_application()
173173
else:
174174
manager.console.print(
175-
f"[yellow] Stable update available: {version_info.current_version}{version_info.latest_stable}"
175+
f"[yellow] Update available: {version_info.current_version}{version_info.latest_stable}"
176176
)
177177
if not get_confirm(" Update now"):
178178
return

bugscanx/modules/scanners/host_scanner.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
import ipaddress
2+
from rich import print
13
from 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

526
def 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:

bugscanx/modules/scrapers/iplookup/iplookup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def main():
8585
ips.extend(process_file(file_path))
8686
default_output = f"{file_path.rsplit('.', 1)[0]}_domains.txt"
8787

88-
output_file = get_input("Enter output filename", default=default_output)
88+
output_file = get_input("Enter output filename", default=default_output, validators="required")
89+
print()
8990
iplookup = IPLookup()
9091
iplookup.run(ips, output_file)

bugscanx/modules/scrapers/subfinder/subfinder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def main():
9191
domains = [d.strip() for d in f if DomainValidator.is_valid_domain(d.strip())]
9292
default_output = f"{file_path.rsplit('.', 1)[0]}_subdomains.txt"
9393

94-
output_file = get_input("Enter output filename", default=default_output)
94+
output_file = get_input("Enter output filename", default=default_output, validators="required")
95+
print()
9596
subfinder = SubFinder()
9697
subfinder.run(domains, output_file, sources)

bugscanx/utils/cidr.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)