-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpack-a-punch.py
72 lines (61 loc) · 2.12 KB
/
pack-a-punch.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Advanced Script 1: Asynchronous Subdomain Discovery
import asyncio
import aiohttp
async def check_subdomain(domain, subdomain):
url = f"https://{subdomain}.{domain}"
async with aiohttp.ClientSession() as session:
try:
async with session.get(url) as resp:
if resp.status != 404:
print(f"Discovered subdomain: {url}")
except Exception as e:
pass
async def subdomain_discovery(domain):
tasks = []
with open('subdomains_wordlist.txt', 'r') as file:
for line in file:
subdomain = line.strip()
task = asyncio.ensure_future(check_subdomain(domain, subdomain))
tasks.append(task)
await asyncio.gather(*tasks)
asyncio.run(subdomain_discovery("example1.com"))
# Advanced Script 2: Concurrent Directory Bruteforce
import asyncio
import aiohttp
async def check_directory(domain, directory):
url = f"https://{domain}/{directory}"
async with aiohttp.ClientSession() as session:
try:
async with session.get(url) as resp:
if resp.status == 200:
print(f"Found directory: {url}")
except Exception as e:
pass
async def dir_bruteforce(domain):
tasks = []
with open('directory_wordlist.txt', 'r') as file:
for line in file:
directory = line.strip()
task = asyncio.ensure_future(check_directory(domain, directory))
tasks.append(task)
await asyncio.gather(*tasks)
asyncio.run(dir_bruteforce("example2.com"))
# Advanced Script 3: Asynchronous Port Scanner
import asyncio
import socket
async def scan_port(ip, port):
conn = asyncio.open_connection(ip, port)
try:
reader, writer = await asyncio.wait_for(conn, timeout=1)
print(f"Port {port}: Open")
writer.close()
await writer.wait_closed()
except:
pass
async def port_scanner(target):
tasks = []
for port in range(1, 65535):
task = asyncio.ensure_future(scan_port(target, port))
tasks.append(task)
await asyncio.gather(*tasks)
asyncio.run(port_scanner("example3.com"))