Skip to content

Commit 57d78fd

Browse files
committed
Reformat the code to follow PEP 8
1 parent abba13a commit 57d78fd

25 files changed

+636
-219
lines changed

bugscanx/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import os
12
import threading
2-
from rich import print
33
from pyfiglet import Figlet
4+
from rich import print
5+
46

57
def import_modules():
68
def task():
@@ -9,15 +11,17 @@ def task():
911
from bugscanx.modules.scrapers.subfinder import subfinder
1012
except Exception:
1113
pass
12-
14+
1315
threading.Thread(target=task, daemon=True).start()
1416

17+
1518
figlet = Figlet(font="calvin_s")
1619

20+
1721
def clear_screen():
18-
import os
1922
os.system('cls' if os.name == 'nt' else 'clear')
2023

24+
2125
def banner():
2226
clear_screen()
2327
print("""
@@ -28,11 +32,14 @@ def banner():
2832
[bold magenta] Tᴇʟᴇɢʀᴀᴍ: @BᴜɢSᴄᴀɴX [/bold magenta]
2933
""")
3034

35+
3136
def text_ascii(text, color="bold magenta", indentation=2):
3237
clear_screen()
3338
ascii_banner = figlet.renderText(text)
34-
shifted_banner = "\n".join((" " * indentation) + line for line in ascii_banner.splitlines())
39+
shifted_banner = "\n".join((" " * indentation) + line
40+
for line in ascii_banner.splitlines())
3541
print(f"[{color}]{shifted_banner}[/{color}]")
3642
print()
3743

44+
3845
import_modules()

bugscanx/handler/runner.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,52 @@ def run_1():
22
from bugscanx.modules.scanners_pro import host_scanner_pro
33
host_scanner_pro.main()
44

5+
56
def run_2():
67
from bugscanx.modules.scanners import host_scanner
78
host_scanner.main()
89

10+
911
def run_3():
1012
from bugscanx.modules.scanners import cidr_scanner
1113
cidr_scanner.main()
1214

15+
1316
def run_4():
1417
from bugscanx.modules.scrapers.subfinder import subfinder
1518
subfinder.main()
1619

20+
1721
def run_5():
1822
from bugscanx.modules.scrapers.iplookup import iplookup
1923
iplookup.main()
2024

25+
2126
def run_6():
2227
from bugscanx.modules.others import file_toolkit
2328
file_toolkit.main()
2429

30+
2531
def run_7():
2632
from bugscanx.modules.scanners import open_port
2733
open_port.main()
2834

35+
2936
def run_8():
3037
from bugscanx.modules.others import dns_records
3138
dns_records.main()
3239

40+
3341
def run_9():
3442
from bugscanx.modules.others import host_info
3543
host_info.main()
3644

45+
3746
def run_10():
3847
from bugscanx.modules.others import script_help
3948
script_help.main()
4049

50+
4151
def run_11():
4252
from bugscanx.modules.others import script_updater
4353
script_updater.main()

bugscanx/main.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,33 @@
1414
'9': ("HOST INFO", "bold blue"),
1515
'10': ("HELP", "bold yellow"),
1616
'11': ("UPDATE", "bold magenta"),
17-
'12': ("EXIT", "bold red")
17+
'12': ("EXIT", "bold red"),
1818
}
1919

20+
2021
def main():
2122
try:
2223
while True:
2324
banner()
24-
print('\n'.join(f"[{color}] [{k}]{' ' if len(k)==1 else ''} {desc}"
25-
for k, (desc, color) in MENU_OPTIONS.items()))
25+
menu_items = (
26+
f"[{color}] [{k}]{' ' if len(k)==1 else ''} {desc}"
27+
for k, (desc, color) in MENU_OPTIONS.items()
28+
)
29+
print('\n'.join(menu_items))
2630

2731
choice = input("\n \033[36m[-] Your Choice: \033[0m")
2832
if choice not in MENU_OPTIONS:
2933
continue
30-
34+
3135
if choice == '12':
3236
return
33-
37+
3438
text_ascii(MENU_OPTIONS[choice][0])
3539
try:
36-
module = __import__('bugscanx.handler.runner', fromlist=[f'run_{choice}'])
40+
module = __import__(
41+
'bugscanx.handler.runner',
42+
fromlist=[f'run_{choice}']
43+
)
3744
getattr(module, f'run_{choice}')()
3845
print("\n[yellow] Press Enter to continue...", end="")
3946
input()

bugscanx/modules/others/dns_records.py

Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,61 @@
11
import os
2-
from rich import print
2+
from typing import List, Optional
3+
34
from dns import resolver as dns_resolver
4-
from bugscanx.utils.common import get_input, get_confirm
5+
from rich import print
6+
7+
from bugscanx.utils.common import get_confirm, get_input
8+
59

6-
def configure_resolver(custom_nameservers=None):
10+
def configure_resolver(custom_nameservers: Optional[List[str]] = None):
711
dns_obj = dns_resolver.Resolver()
8-
12+
913
if custom_nameservers and len(custom_nameservers) > 0:
1014
dns_obj.nameservers = custom_nameservers
11-
print(f"[yellow]Using custom DNS servers: {', '.join(custom_nameservers)}[/yellow]")
15+
print(
16+
f"[yellow]Using custom DNS servers: "
17+
f"{', '.join(custom_nameservers)}[/yellow]"
18+
)
1219
return dns_obj
13-
14-
is_termux = 'com.termux' in os.environ.get('PREFIX', '') or os.path.exists('/data/data/com.termux')
15-
20+
21+
is_termux = "com.termux" in os.environ.get(
22+
"PREFIX", ""
23+
) or os.path.exists("/data/data/com.termux")
24+
1625
if is_termux:
17-
dns_obj.nameservers = ['8.8.8.8', '8.8.4.4', '1.1.1.1']
18-
26+
dns_obj.nameservers = ["8.8.8.8", "8.8.4.4", "1.1.1.1"]
27+
1928
return dns_obj
2029

21-
def resolve_and_print(domain, record_type, custom_nameservers=None):
30+
31+
def resolve_and_print(
32+
domain: str, record_type: str, custom_nameservers: Optional[List[str]] = None
33+
):
2234
print(f"\n[green] {record_type} Records:[/green]")
2335
try:
2436
dns_obj = configure_resolver(custom_nameservers)
2537
answers = dns_obj.resolve(domain, record_type)
2638
found = False
2739
for answer in answers:
2840
found = True
29-
if record_type == 'MX':
30-
print(f"[cyan]- {answer.exchange} (priority: {answer.preference})[/cyan]")
31-
elif record_type == 'SOA':
41+
if record_type == "MX":
42+
print(
43+
f"[cyan]- {answer.exchange} "
44+
f"(priority: {answer.preference})[/cyan]"
45+
)
46+
elif record_type == "SOA":
3247
print(f"[cyan]- Primary NS: {answer.mname}")
3348
print(f" Responsible: {answer.rname}")
3449
print(f" Serial: {answer.serial}")
3550
print(f" Refresh: {answer.refresh}")
3651
print(f" Retry: {answer.retry}")
3752
print(f" Expire: {answer.expire}")
3853
print(f" Minimum TTL: {answer.minimum}[/cyan]")
39-
elif record_type == 'SRV':
40-
print(f"[cyan]- Priority: {answer.priority}, Weight: {answer.weight}")
54+
elif record_type == "SRV":
55+
print(
56+
f"[cyan]- Priority: {answer.priority}, "
57+
f"Weight: {answer.weight}"
58+
)
4159
print(f" Port: {answer.port}, Target: {answer.target}[/cyan]")
4260
else:
4361
print(f"[cyan]- {answer.to_text()}[/cyan]")
@@ -48,42 +66,51 @@ def resolve_and_print(domain, record_type, custom_nameservers=None):
4866
except Exception:
4967
print(f"[yellow] Error fetching {record_type} record[/yellow]")
5068

51-
def nslookup(domain, custom_nameservers=None):
69+
70+
def nslookup(domain: str, custom_nameservers: Optional[List[str]] = None):
5271
print(f"[cyan]\n Performing NSLOOKUP for: {domain}[/cyan]")
53-
72+
5473
record_types = [
55-
'A',
56-
'AAAA',
57-
'CNAME',
58-
'MX',
59-
'NS',
60-
'TXT',
61-
'SOA',
62-
'PTR',
63-
'SRV',
64-
'CAA',
65-
'DNSKEY',
66-
'TLSA'
74+
"A",
75+
"AAAA",
76+
"CNAME",
77+
"MX",
78+
"NS",
79+
"TXT",
80+
"SOA",
81+
"PTR",
82+
"SRV",
83+
"CAA",
84+
"DNSKEY",
85+
"TLSA",
6786
]
68-
87+
6988
for record_type in record_types:
7089
resolve_and_print(domain, record_type, custom_nameservers)
7190

91+
7292
def main():
7393
domain = get_input("Enter the domain to lookup")
7494
if not domain:
7595
print("[red] Please enter a valid domain.[/red]")
7696
return
77-
97+
7898
use_custom_dns = get_confirm(" Want to use custom DNS servers?")
7999
custom_nameservers = None
80-
100+
81101
if use_custom_dns:
82-
nameservers_input = get_input("Enter DNS servers separated by commas (e.g., 8.8.8.8,1.1.1.1)")
102+
nameservers_input = get_input(
103+
"Enter DNS servers separated by commas (e.g., 8.8.8.8,1.1.1.1)"
104+
)
83105
if nameservers_input:
84-
custom_nameservers = [server.strip() for server in nameservers_input.split(',')]
85-
print(f"[cyan] Will use custom DNS servers: {', '.join(custom_nameservers)}[/cyan]")
86-
106+
custom_nameservers = [
107+
server.strip() for server in nameservers_input.split(",")
108+
]
109+
print(
110+
f"[cyan] Will use custom DNS servers: "
111+
f"{', '.join(custom_nameservers)}[/cyan]"
112+
)
113+
87114
try:
88115
nslookup(domain, custom_nameservers)
89116
except Exception as e:

0 commit comments

Comments
 (0)