9 Exploitation With Ruby
9 Exploitation With Ruby
In this case, ELS Echo Server has a common C++ programming bug.
The size of the received data from the user is not checked causing
a buffer overflow possibility.
caller FRAME …
local buff_ov_variable
variables
input_copy FRAME
old EBP
Return Address
arguments myinput
caller FRAME …
This holds because ESP stores the top of the stack and when the
RET is executed, the input_copy frame is erased and the top of the
stack contains our malicious code executed next by the CALL ESP.
local NOP,NOP,NOP
variables
input_copy FRAME
NOP
CALL ESP address
arguments NOP
Once we know the buffer overflow stack space, using Ruby to send
the exploit will be very easy.
https://www.immunityinc.com/products/debugger/ http://www.ollydbg.de/
https://www.hex-rays.com/products/ida/
Penetration Testing Professional 5.0 – Caendra Inc. © 2018
Since we own the source code and the executable of the ELS Echo
service too, we will show how to use Immunity Debugger in
conjunction with some useful tools provided by the Metasploit
framework. We will map the ELS Echo Server stack and detect the
return address position or the function input_copy.
ESP points to the top of the stack that contains some NOPs
followed by the malicious payload.
local NOP,NOP,NOP
variables
input_copy FRAME
NOP
CALL ESP address
arguments NOP,NOP,NOP
NOP,NOP,NOP
caller FRAME
Malicious payload
Ollydbg
http://www.ollydbg.de/