-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirectory_enumerator.py
More file actions
33 lines (27 loc) · 936 Bytes
/
directory_enumerator.py
File metadata and controls
33 lines (27 loc) · 936 Bytes
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
import requests
import sys
def print_help():
print("Usage: python script.py <base_url> <path_to_wordlist>")
print("Example: python script.py www.example.com /path/to/wordlist.txt")
def main():
if len(sys.argv) != 3:
print_help()
sys.exit(1)
base_url = sys.argv[1].strip('/')
wordlist_path = sys.argv[2]
try:
with open(wordlist_path, "r") as file:
directories = file.read().splitlines()
except FileNotFoundError:
print(f"Error: Wordlist file '{wordlist_path}' not found.")
sys.exit(1)
for directory in directories:
url = f"http://{base_url}/{directory}.html"
try:
response = requests.get(url)
if response.status_code != 404:
print(f"Valid directory: {url}")
except requests.RequestException as e:
print(f"Error accessing {url}: {e}")
if __name__ == "__main__":
main()