-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (42 loc) · 1.64 KB
/
main.py
File metadata and controls
45 lines (42 loc) · 1.64 KB
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
import os
import argparse
import requests
from bs4 import BeautifulSoup as BS
from urllib.parse import urlparse
parser = argparse.ArgumentParser()
parser.add_argument("domain", type=str, help="Please include the http URL scheme!")
args = parser.parse_args()
print(f"Initializing on {args.domain}")
directory = os.getcwd()
x = urlparse(args.domain); fix = x.hostname #bit of a hack
if not os.path.exists(f"{directory}/domains/{fix}"):
os.system(f"mkdir {directory}/domains/{fix}")
elif not os.path.exists(f"{directory}/domains/{fix}/scripts"):
os.system(f"mkdir {directory}/domains/{fix}/scripts")
url_dump = open(f"domains/{fix}/urls.txt", "w+")
script_dump = open(f"domains/{fix}/scripts.txt", "w+")
def main():
url = [""]; script = [""]
core = requests.get(args.domain)
response = BS(core.text, "html.parser")
for src in response.find_all("script"):
fetch = src.get("src")
if fetch == None:
script.append(src)
elif not "https://" in fetch:
print(f"\033[0;32mhttps://{fix}/{fetch}\033[0m")
url.append(f"https://{fix}/{fetch}")
else:
print(f"\033[0;32m{fetch}\033[0m")
url.append(fetch)
if script:
for line in script:
print(f"\033[1;33m{line}\033[0m")
script_dump.write(f"{str(line)}\n")
if url:
for line in url:
url_dump.write(f"{str(line)}\n")
for line in url:
if len(line) != 0:
os.system(f"wget -P \"domains/{fix}/scripts\" -U \"Mozilla/5.0 (Windows NT 10.0; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5666.197 Safari/537.36\" {line}")
main()