-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3buckets.py
executable file
·50 lines (45 loc) · 1.37 KB
/
s3buckets.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
45
46
47
48
49
50
import requests
import time
bucketList = []
def exists(url):
try:
# if this raises an ERROR, that means the bucket does not exist
response = requests.get(url)
code = response.status_code
if code == 200 or code == 403:
bucketList.append(url)
except requests.ConnectionError:
# if the bucket does not exist, just pass, print nothing
pass
else:
pass
def bucketfinder(domain):
import threading
bucketList.clear()
# read all buckets
file = open("./wordlists/common_bucket_prefixes.txt")
# read all words in the file
wordlist = file.read()
# split by new lines
buckets = wordlist.splitlines()
mythreads = []
# t = threading.Thread(target=exists,kwargs={'url':'https://abc.domain'})
# t.start()
exists(f'http://{domain}.s3.amazonaws.com')
for bucket in buckets:
url = f"http://{domain}-{bucket}.s3.amazonaws.com"
t = threading.Thread(target=exists, kwargs={'url': url})
mythreads.append(t)
t.start()
for th in mythreads:
th.join()
try:
with open('output/buckets/result.txt', 'w+') as f:
if(len(bucketList) == 0):
f.write("No buckets found")
else:
for x in bucketList:
f.write(x + "\n")
return True
except:
return False