Skip to content

Instantly share code, notes, and snippets.

@c0d3x27
Created November 11, 2020 18:51
Show Gist options
  • Save c0d3x27/c98c5ae6d6985706cacb11f3d892a1f2 to your computer and use it in GitHub Desktop.
Save c0d3x27/c98c5ae6d6985706cacb11f3d892a1f2 to your computer and use it in GitHub Desktop.
import requests,re
from urllib.parse import unquote
import checkdomains
domains = open("Domains-to-test.txt","r")
for domain in domains.readlines():
subdomains = open(domain.rstrip("\n")+"_subdomains.txt","r")
for subdomain in subdomains.readlines():
buckets = []
urls = checkdomains.isdomainlive(subdomain.rstrip("\n"))
if urls:
for url in urls:
print("checking - "+url)
try:
html=requests.get(url=url,timeout=20,verify=False).content
try:
html=unquote(str(html))
except Exception as e:
print(e)
regjs=r"(?<=src=['\"])[a-zA-Z0-9_\.\-\:\/]+\.js"
regs3=r"[\w\-\.]+\.s3\.?(?:[\w\-\.]+)?\.amazonaws\.com|(?<!\.)s3\.?(?:[\w\-\.]+)?\.amazonaws\.com\\?\/[\w\-\.]+"
js=re.findall(regjs,html)
s3=re.findall(regs3,html)
buckets=buckets+s3
if len(js)>0:
for i in js:
if i.startswith('//'):
jsurl=i.replace('//','http://')
elif i.startswith('http'):
jsurl=i
else:
jsurl=url+'/'+i
try:
jsfile=requests.get(jsurl,timeout=20).content
s3=re.findall(regs3,jsfile)
except Exception as y:
pass
if s3:
buckets=buckets+s3
except Exception as x:
pass
for bucket in buckets:
print(bucket)
@sabeesh03
Copy link

Generates error
File "s3_BucketFinder.py", line 3, in
import checkdomains
ModuleNotFoundError: No module named 'checkdomains'

@akinsola123
Copy link

Hi, how do i fix "ModuleNotFoundError: No module named 'checkdomains'"

@c0d3x27
Copy link
Author

c0d3x27 commented Oct 1, 2021

Generates error File "s3_BucketFinder.py", line 3, in import checkdomains ModuleNotFoundError: No module named 'checkdomains'

I'm sorry for the delayed response. that module doesn't exist because that is the file you make from where the script will take the URLs

@c0d3x27
Copy link
Author

c0d3x27 commented Oct 1, 2021

Hi, how do i fix "ModuleNotFoundError: No module named 'checkdomains'"

I'm sorry for the delayed response. that module doesn't exist because that is the file you make from where the script will take the URLs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment