Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions SDomDiscover.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class c:
UNDERLINE = '\033[4m'

def ctrl_c(sig, frame):
sys.exit(c.RED + "[!] Interrupt handler received, exiting..." + c.END)
sys.exit(f"{c.RED}[!] Interrupt handler received, exiting...{c.END}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ctrl_c refactored with the following changes:


signal.signal(signal.SIGINT, ctrl_c)

def banner():
print(c.YELLOW + ' _____ ')
print(f'{c.YELLOW} _____ ')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function banner refactored with the following changes:

print(' .-" "-. ')
print(' / o o \ ')
print(' / \ / \ ')
Expand Down Expand Up @@ -92,24 +92,34 @@ def axfr(domain):
sleep(0.5)
ns_answer = dns.resolver.resolve(domain, 'NS')
for server in ns_answer:
print(c.YELLOW + "[*] Found NS: {}".format(server) + c.END)
print(c.YELLOW + f"[*] Found NS: {server}" + c.END)
ip_answer = dns.resolver.resolve(server.target, 'A')
for ip in ip_answer:
print(c.YELLOW + "[*] IP for {} is {}".format(server, ip) + c.END)
print(c.YELLOW + f"[*] IP for {server} is {ip}" + c.END)
try:
zone = dns.zone.from_xfr(dns.query.xfr(str(ip), domain))
for host in zone:
print(c.YELLOW + "[" + c.END + c.GREEN + "+" + c.END + c.YELLOW + "] Found Host: {}".format(host) + c.END)
print(
f"{c.YELLOW}[{c.END}{c.GREEN}+{c.END}{c.YELLOW}"
+ f"] Found Host: {host}"
+ c.END
)

except Exception as e:
print(c.YELLOW + "[" + c.END + c.RED + "-" + c.END + c.YELLOW + "] NS {} refused zone transfer!".format(server) + c.END)
print(
f"{c.YELLOW}[{c.END}{c.RED}-{c.END}{c.YELLOW}"
+ f"] NS {server} refused zone transfer!"
+ c.END
)

Comment on lines -95 to +114
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function axfr refactored with the following changes:

continue

def SDom(domain,filename):
banner()
print(c.BLUE + "\n[" + c.END + c.GREEN + "+" + c.END + c.BLUE + "] Discovering valid subdomains...\n" + c.END)
sleep(0.5)

r = requests.get("https://crt.sh/?q=" + domain + "&output=json", timeout=20)
r = requests.get(f"https://crt.sh/?q={domain}&output=json", timeout=20)
Comment on lines -112 to +122
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SDom refactored with the following changes:

formatted_json = json.dumps(json.loads(r.text), indent=4)
domains = re.findall(r'"common_name": "(.*?)"', formatted_json)

Expand All @@ -118,31 +128,31 @@ def SDom(domain,filename):
if filename != None:
f = open(filename, "a")

print(c.YELLOW + "+" + "-"*39 + "+")
print(f"{c.YELLOW}+" + "-"*39 + "+")
for value in doms:
if not value.startswith('*' + "." + domain):

if len(value) >= 10 and len(value) <= 14:
l = len(value)
print("| " + value + " \t\t\t|")
print(f"| {value}" + " \t\t\t|")
if filename != None:
f.write(value + "\n")

if len(value) >= 15 and len(value) <= 19:
l = len(value)
print("| " + value + "\t\t\t|")
print(f"| {value}" + "\t\t\t|")
if filename != None:
f.write(value + "\n")

if len(value) >= 20 and len(value) <= 24:
l = len(value)
print("| " + value + " \t\t|")
print(f"| {value}" + " \t\t|")
if filename != None:
f.write(value + "\n")

if len(value) >= 25 and len(value) <= 29:
l = len(value)
print("| " + value + "\t\t|")
print(f"| {value}" + "\t\t|")
if filename != None:
f.write(value + "\n")

Expand Down