repl.it
@AzureScripts/

Subdomain Scanner

Python

No description

fork
loading
Files
  • main.py
  • domains.txt
main.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
# Credit goes to @Rshields for improving this a bunch!

import requests, asyncio, concurrent, socket

def check(a):
    try:
        https_a = "https://" + a
        r = requests.get(https_a)
        # This checks to see the status code
        if r.status_code == 200 or r.status_code == 301 or r.status_code == 302:
            print("[FOUND] " + https_a + " (" + socket.gethostbyname(a) + ")")
        else:
            pass
    except:
        pass

async def main():
    domain_list = open('domains.txt', "r").read().splitlines()

    print("Azure's subdomain scanner")
    print("Please enter a domain to scan! (e.g. google.com)")
    print("Credit to RShields for the MEGA improvements")
    print("")
    website = input("Domain: ")
    print("Searching...")

    with concurrent.futures.ThreadPoolExecutor(max_workers=500) as executor:
        loop = asyncio.get_event_loop()
        # This actually runs the code
        futures = [
            loop.run_in_executor(
                executor,
                check,
                domain + "." + website
            )
            for domain in domain_list
        ]
        # This waits for it to finish
        await asyncio.wait(futures, timeout=3)
        print("")
        print("Can't find any more!")

asyncio.get_event_loop().run_until_complete(main())
?