|
|||||||
| Pentesting Specific topics related to legal penetration testing |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
So I have BT4 running in a Virtual Machine, and I have Windows 7 as the host computer. I'm trying to write my own Buffer Overflow exploit for an old, vulnerable, version of 3COM FTP, but I'm stuck. I figured out which bytes overwrite the EIP, but I can't figure out where to go from here. I can't find a register that points back into my buffer. I am new to this topic, so if there's another way of getting back into my buffer, please excuse my lack of knowledge.
Last edited by oib111; 10-12-2009 at 07:28 AM. |
|
|||
|
Ah, thanks for those suggestions, I'll look into that right now.
EDIT: Ok, couldn't find any registers that referred to an address that pointed back to my buffer, but I did find something in the stack that points back into my buffer. Not sure how to get to it though, here's a picture: ![]() Looks like it'd take 27 POPs to get to the pointer... :S Last edited by oib111; 10-12-2009 at 04:28 PM. |
|
||||
|
The third entry down on the stack appears to contain an address (01DBFBC0) that points near the start of your buffer (at least the section of it I can see from your screenshot). Whats in that memory location and how far away is it from where memory is overwritten by characters you can control? Look at that memory in disassembler mode too so you can see what instructions would run if you redirected execution there - depending on what they are you may be able to let those instructions run and then have execution passed to the shellcode in your buffer.
Also, what is located in the first four bytes of data in the memory location referred to by register EBP (01DBF498)? And one more thing, what happens if you make your buffer larger? Can you manage to overwrite SEH? (You can see the SEH handler address in the 7th entry down on your stack).
__________________
Nancy Astor: If I were your wife I would put poison in your coffee! Winston Churchill: Madam, if I were your husband I would drink it. Last edited by lupin; 10-13-2009 at 05:36 AM. |
|
|||
|
I checked the four bytes at the address pointed to by ESP and EBP and neither seem to be near or in my buffer. That address on the stack you pointed out works great (kind of). I scanned the file using msfpescan and found a POP POP RET. The only problem is the buffer points to the part of my buffer that comes right before the return address, so it would start executing commands four bytes before the return address which is fine because I can NOP out the four bytes before the return address, but then it tries to executed the return address as a command...anyway to avoid this? I was thinking I could use a short jump (0xEB if I'm not mistaken) to jump past the return address.
Last edited by oib111; 10-13-2009 at 07:28 AM. |
|
||||
|
Quote:
Do you then have adequate space in the buffer after the return address for your shellcode? Its obviously dependent on what shellcode you want to use, but the common Metasploit Windows reverse shell usually needs between 315-400 bytes, depending on encoding requirements.
__________________
Nancy Astor: If I were your wife I would put poison in your coffee! Winston Churchill: Madam, if I were your husband I would drink it. Last edited by lupin; 10-14-2009 at 06:13 AM. |
|
|||
|
Thanks, that's work although I did it slightly differently (put the NOPs first) and there are some extra bytes to account for. But, something isn't working. My overflow buffer is:
Code:
jmp = '\x90\x90\xEB\x0A' ret = '\x84\x18\x41\x00' buffer = '\x41' * 230 + jmp + ret + '\xCC' * 962 ![]() Pretty obvious that something's going wrong. Even weirder, I set a BP on 0x411884 just to see if it was even being jumped to, and the BP was never hit... Last edited by oib111; 10-14-2009 at 07:16 AM. |
|
||||
|
Quote:
You are most likely running into a problem with that \x00 in your ret address (null is a string terminator and depending on your input method it can mangle the buffer). Find a POP, POP, RET in one of the dlls called by that app that doesnt contain a zero in the address, and try that instead. Id start with checking user32.dll or shell32.dll if your vulnerable program calls them - they are usually good prospects.
__________________
Nancy Astor: If I were your wife I would put poison in your coffee! Winston Churchill: Madam, if I were your husband I would drink it. Last edited by lupin; 10-14-2009 at 08:57 AM. |
|
|||
|
I know I tested to see if it'd crash on 0x42424242 but I don't remember the results and I can't test right now because my network is down and can't get Virtual PC working with my neighbors network. Also, I used msfpescan to find the pop pop ret, and I don't think there was a single one that didn't start off with 00... :S
EDIT: I tested it and if I overwrite EIP with 0x42424242 it does the same thing. But if I remove the the jump it works...? Last edited by oib111; 10-15-2009 at 05:26 AM. |
|
||||
|
Quote:
If you are trying the USER one, and my memory is serving me correctly, there you need an SEH in place. Go manually looking through the reported DLL's that have been loaded, there should be one in ntdll for you that works just fine (it starts with 0x77 rather than 0x00). Then you should be able to construct your attack string quite simply as you have been - \x90 * howevermanytopadwith + poppopret + jmpecx + \x90 * 14 + \xCC * 500 You should land somewhere in your \xCC's if all things continue to operate. Something to note about testing SEH exploits in Olly - you need to hit the play/run button once after the "crash" occurs, as you fall into the SEH handler and then later on fall into your EIP overwrite. Have a play around and you should get what I mean. Finally: Doing this sort of development will be easiest for you on an XP SP 2 or earlier machine, 7, Vista and perhaps even Virtual Machine, have protections built in place. You also don't technically need Backtrack for this exercise (except for the actual shellcode generation/acceptance component)
__________________
Never underestimate the power of human stupidity - it is like a force of nature, capable of destroying even the most well laid plans. |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|