Exploit database

GH-9dc504b8e28c55415e7f17b0471203fc

d1a0y1bb/php2shell-poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-109618

413 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files10
d1a0y1bb/php2shell-pocRevision a9d3ebefc209

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

poc/i087_video_fingerprint/instr.py

Python · 10,283 bytes
import gdb, atexit

OUT = open('/tmp/i087/logs/gdb_events.log', 'w', buffering=1)
phase = 'INIT'
req = 0
counts = {}
zcf_n = 0
zvdt_logged = 0
MAPS = []
CHUNK = 0
LIBPHP = 0
ZCF_MAX = 500
ZVDT_MAX = 500

def out(s):
    OUT.write(s + "\n")

def region(addr):
    global CHUNK, LIBPHP
    try:
        rsp = int(gdb.parse_and_eval('$rsp'))
    except Exception:
        rsp = 0
    if CHUNK and CHUNK <= addr < CHUNK + 0x200000:
        return 'CHUNK+%#x' % (addr - CHUNK)
    if LIBPHP and LIBPHP <= addr < LIBPHP + 0x1000000:
        return 'LIBPHP+%#x' % (addr - LIBPHP)
    if rsp and abs(addr - rsp) < 0x800000:
        return 'STACK(delta=%#x)' % (addr - rsp)
    return 'OTHER'

def in_stack(addr):
    return region(addr).startswith('STACK')

def zstr(ptr):
    try:
        if not ptr:
            return ''
        s = gdb.parse_and_eval('(char*)((zend_string*)%d)->val' % ptr).string()
        return s if s is not None else ''
    except Exception:
        return ''

def u32(addr):
    try:
        return int(gdb.parse_and_eval('*(unsigned int*)%d' % addr))
    except Exception:
        return -1

def u64(addr):
    try:
        return int(gdb.parse_and_eval('*(unsigned long*)%d' % addr))
    except Exception:
        return 0

def ztype(zv):
    return u32(zv + 8) & 0xff

def zvalptr(zv):
    return u64(zv)

def caller(depth=1):
    try:
        f = gdb.newest_frame()
        for _ in range(depth):
            f = f.older()
            if f is None:
                return '?'
        nm = f.name()
        return '%s@%#x' % (nm if nm else '?', f.pc())
    except Exception as e:
        return 'ERR:%s' % e

class PhaseBP(gdb.Breakpoint):
    def __init__(self, spec, name):
        super().__init__(spec, internal=True)
        self.silent = True
        self.nm = name
    def stop(self):
        global phase, req
        phase = self.nm
        if self.nm == 'STARTUP':
            req += 1
            try:
                mm = int(gdb.parse_and_eval('(unsigned long)alloc_globals.mm_heap'))
                lb = int(gdb.parse_and_eval('(unsigned long)&zend_call_function')) - 0x52a9d0
                global CHUNK, LIBPHP
                CHUNK = mm - 0x40
                LIBPHP = lb
                out('BASEINFO req=%d mm_heap=%#x chunkbase=%#x libphp_base=%#x zif_passthru=%#x' % (req, mm, mm - 0x40, lb, lb + 0x3ddaa0))
                if req > 1:
                    out('REQSTATS prev_req=%d counts=%s' % (req - 1, sorted(counts.items())))
            except Exception as e:
                out('BASEINFO req=%d ERR %s' % (req, e))
            if req == 1:
                for bp in gdb.breakpoints() or []:
                    try:
                        locs = ','.join('%#x' % l.address for l in bp.locations) if bp.locations else '-'
                    except Exception:
                        locs = '?'
                    out('BP %s enabled=%s hit=%s locs=%s' % (bp.location, bp.enabled, bp.hit_count, locs))
        return False

class ZCF(gdb.Breakpoint):
    def __init__(self):
        super().__init__('zend_call_function', internal=True)
        self.silent = True
    def stop(self):
        global zcf_n
        zcf_n += 1
        counts['zcf_' + phase] = counts.get('zcf_' + phase, 0) + 1
        if zcf_n > ZCF_MAX and phase not in ('BODY', 'STARTUP'):
            return False
        try:
            fci = int(gdb.parse_and_eval('$rdi'))
            fcc = int(gdb.parse_and_eval('$rsi'))
            size = u64(fci)
            pc = u32(fci + 48)
            objp = u64(fci + 40)
            fnz = u32(fci + 8) & 0xff
            fnp = u64(fci + 16)
            fnh = u64(fcc) if fcc else 0
            extra = ''
            if not in_stack(fci):
                qs = ' '.join('%#x' % u64(fci + 8 * i) for i in range(8))
                extra = ' fci_qwords=[%s]' % qs
                if fcc:
                    qs2 = ' '.join('%#x' % u64(fcc + 8 * i) for i in range(3))
                    extra += ' fcc_qwords=[%s]' % qs2
            out('ZCF req=%d phase=%s fci=%#x[%s] stack=%d size=%d params=%d obj=%#x fn_type=%d fn=%#x"%s" fcc=%#x handler=%#x[%s] caller=%s%s'
                % (req, phase, fci, region(fci), 1 if in_stack(fci) else 0, size, pc, objp,
                   fnz, fnp, zstr(fnp) if fnz == 6 else '', fcc, fnh, region(fnh), caller(1), extra))
        except Exception as e:
            out('ZCF req=%d phase=%s ERR %s' % (req, phase, e))
        return False

class ZVDT(gdb.Breakpoint):
    def __init__(self):
        super().__init__('zval_ptr_dtor', internal=True)
        self.silent = True
    def stop(self):
        global zvdt_logged
        counts['zvdt_' + phase] = counts.get('zvdt_' + phase, 0) + 1
        if phase not in ('STARTUP', 'BODY'):
            return False
        try:
            zv = int(gdb.parse_and_eval('$rdi'))
            ti = ztype(zv)
            vp = zvalptr(zv)
            c = caller(1)
            if zvdt_logged < ZVDT_MAX:
                zvdt_logged += 1
                out('ZVDT req=%d phase=%s zval=%#x[%s] ti=%#x ptr=%#x[%s] caller=%s'
                    % (req, phase, zv, region(zv), ti, vp, region(vp), c))
        except Exception as e:
            out('ZVDT req=%d phase=%s ERR %s' % (req, phase, e))
        return False

class PASSTHRU(gdb.Breakpoint):
    def __init__(self):
        super().__init__('zif_passthru', internal=True)
        self.silent = True
    def stop(self):
        try:
            ed = int(gdb.parse_and_eval('$rdi'))
            rv = int(gdb.parse_and_eval('$rsi'))
            out('HIT_PASSTHRU req=%d phase=%s ed=%#x[%s] rv=%#x caller=%s'
                % (req, phase, ed, region(ed), rv, caller(1)))
        except Exception as e:
            out('HIT_PASSTHRU ERR %s' % e)
        return False

class RCDTOR(gdb.Breakpoint):
    def __init__(self):
        super().__init__('rc_dtor_func', internal=True)
        self.silent = True
    def stop(self):
        try:
            p = int(gdb.parse_and_eval('$rdi'))
            t = u32(p + 4) & 0xf
            counts['rcdtor_%s_type%d' % (phase, t)] = counts.get('rcdtor_%s_type%d' % (phase, t), 0) + 1
            if phase in ('STARTUP', 'BODY') and t in (7, 8, 0xa):
                out('RCDTOR req=%d phase=%s p=%#x[%s] type=%d rc=%d caller=%s'
                    % (req, phase, p, region(p), t, u32(p), caller(1)))
        except Exception:
            pass
        return False

class ARRDEST(gdb.Breakpoint):
    def __init__(self):
        super().__init__('zend_array_destroy', internal=True)
        self.silent = True
    def stop(self):
        try:
            ht = int(gdb.parse_and_eval('$rdi'))
            pd = u64(ht + 48)
            counts['arrdest_' + phase] = counts.get('arrdest_' + phase, 0) + 1
            if phase in ('STARTUP', 'BODY'):
                out('ARRDEST req=%d phase=%s ht=%#x[%s] flags=%#x used=%d elems=%d pd=%#x[%s] caller=%s'
                    % (req, phase, ht, region(ht), u32(ht + 8), u32(ht + 24), u32(ht + 28), pd, region(pd), caller(1)))
        except Exception as e:
            out('ARRDEST ERR %s' % e)
        return False

class MARK(gdb.Breakpoint):
    def __init__(self, spec, name):
        super().__init__(spec, internal=True)
        self.silent = True
        self.nm = name
    def stop(self):
        try:
            z = int(gdb.parse_and_eval('$rdi'))
        except Exception:
            z = 0
        counts[self.nm] = counts.get(self.nm, 0) + 1
        extra = ''
        if self.nm == 'TRACK_INIT':
            try:
                hv = int(gdb.parse_and_eval('(unsigned long)&ps_globals.http_session_vars'))
                hp = u64(hv)
                extra = ' hsv=%#x hsv_val=%#x[%s] hsv_ti=%#x' % (hv, hp, region(hp), u32(hv + 8))
                if u32(hv + 8) == 0x30a and CHUNK <= hp < CHUNK + 0x200000:
                    qs = ' '.join('%#x' % u64(hp + 8 * i) for i in range(8))
                    extra += ' DQWORDS=[%s]' % qs
                    # locate zend_string allocations whose body starts with LLLL
                    try:
                        mem = gdb.selected_inferior().read_memory(CHUNK, 0x200000).tobytes()
                        cands = []
                        for off in range(0, 0x200000 - 0x40, 8):
                            if mem[off:off+4] != b'\x01\x00\x00\x00':
                                continue
                            if mem[off+4:off+8] != b'\x16\x00\x00\x00':
                                continue
                            ln = int.from_bytes(mem[off+16:off+24], 'little')
                            if not (1000 <= ln <= 100000):
                                continue
                            ds = off + 0x18
                            if mem[ds:ds+16] == b'L' * 16:
                                cands.append((CHUNK + ds, ln))
                                if len(cands) >= 8:
                                    break
                        if cands:
                            extra += ' M0CAND=' + ','.join('%#x[%s,len=%d]' % (a, region(a), ln) for a, ln in cands)
                    except Exception as e2:
                        extra += ' scanERR %s' % e2
                    except Exception as e2:
                        extra += ' scanERR %s' % e2
            except Exception as e:
                extra = ' hsvERR %s' % e
        out('MARK %s req=%d phase=%s arg=%#x[%s] caller=%s%s' % (self.nm, req, phase, z, region(z), caller(1), extra))
        return False

PhaseBP('php_request_startup', 'STARTUP')
PhaseBP('php_hash_environment', 'BODY')
PhaseBP('zend_activate_modules', 'RINIT')
PhaseBP('php_request_shutdown', 'SHUTDOWN')
ZCF()
ZVDT()
PASSTHRU()
RCDTOR()
ARRDEST()
MARK('php_session_track_init', 'TRACK_INIT')
MARK('php_session_rfc1867_callback', 'RFC1867_CB')
MARK('php_session_initialize', 'SESS_INIT')
MARK('php_rinit_session', 'RINIT_SESSION')
MARK('zend_user_unserialize', 'USER_UNSERIALIZE')
MARK('zend_call_method', 'CALL_METHOD')
MARK('zend_objects_destroy_object', 'OBJ_DESTROY')

def summary():
    out('=== SUMMARY reqs=%d zcf_total=%d counts=%s ===' % (req, zcf_n, sorted(counts.items())))
    OUT.flush()

atexit.register(summary)
gdb.execute('set pagination off')
gdb.execute('set confirm off')
out('=== i071 instrumentation started pid=%d ===' % gdb.selected_inferior().pid)