2011-07-30 15:11:52 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2011-07-30 15:11:52 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/core/post/windows/services'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
2011-11-06 22:02:26 +00:00
|
|
|
|
2012-11-06 23:30:04 +00:00
|
|
|
include Msf::Post::Windows::Services
|
2011-07-30 15:11:52 +00:00
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => "Windows Gather Service Info Enumeration",
|
|
|
|
'Description' => %q{
|
|
|
|
This module will query the system for services and display name and configuration
|
2011-10-29 00:23:02 +00:00
|
|
|
info for each returned service. It allows you to optionally search the credentials, path, or start
|
2011-07-30 15:11:52 +00:00
|
|
|
type for a string and only return the results that match. These query operations
|
|
|
|
are cumulative and if no query strings are specified, it just returns all services.
|
|
|
|
NOTE: If the script hangs, windows firewall is most likely on and you did not
|
|
|
|
migrate to a safe process (explorer.exe for example).
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
2012-10-23 18:33:01 +00:00
|
|
|
'Platform' => ['win'],
|
2011-07-30 15:11:52 +00:00
|
|
|
'SessionTypes' => ['meterpreter'],
|
|
|
|
'Author' => ['Keith Faber', 'Kx499']
|
|
|
|
))
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('CRED', [ false, 'String to search credentials for' ]),
|
|
|
|
OptString.new('PATH', [ false, 'String to search path for' ]),
|
2011-11-06 22:02:26 +00:00
|
|
|
OptEnum.new('TYPE', [false, 'Service startup Option', 'All', ['All', 'Auto', 'Manual', 'Disabled' ]])
|
2011-07-30 15:11:52 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def run
|
|
|
|
|
|
|
|
# set vars
|
|
|
|
qcred = datastore["CRED"] || nil
|
|
|
|
qpath = datastore["PATH"] || nil
|
|
|
|
if datastore["TYPE"] == "All"
|
|
|
|
qtype = nil
|
|
|
|
else
|
|
|
|
qtype = datastore["TYPE"]
|
|
|
|
end
|
2011-10-17 03:49:49 +00:00
|
|
|
if qcred
|
2011-07-30 15:11:52 +00:00
|
|
|
print_status("Credential Filter: " + qcred)
|
|
|
|
end
|
|
|
|
if qpath
|
|
|
|
print_status("Executable Path Filter: " + qpath)
|
|
|
|
end
|
|
|
|
if qtype
|
|
|
|
print_status("Start Type Filter: " + qtype)
|
|
|
|
end
|
2011-11-06 22:02:26 +00:00
|
|
|
|
2011-07-30 15:11:52 +00:00
|
|
|
print_status("Listing Service Info for matching services:")
|
|
|
|
service_list.each do |sname|
|
|
|
|
srv_conf = {}
|
|
|
|
isgood = true
|
|
|
|
#make sure we got a service name
|
|
|
|
if sname
|
|
|
|
begin
|
|
|
|
srv_conf = service_info(sname)
|
|
|
|
#filter service based on filters passed, the are cumulative
|
|
|
|
if qcred and ! srv_conf['Credentials'].downcase.include? qcred.downcase
|
|
|
|
isgood = false
|
|
|
|
end
|
|
|
|
if qpath and ! srv_conf['Command'].downcase.include? qpath.downcase
|
|
|
|
isgood = false
|
|
|
|
end
|
2013-07-03 16:44:28 +00:00
|
|
|
# There may not be a 'Startup', need to check nil
|
|
|
|
if qtype and ! (srv_conf['Startup'] || '').downcase.include? qtype.downcase
|
2011-07-30 15:11:52 +00:00
|
|
|
isgood = false
|
|
|
|
end
|
2011-11-06 22:02:26 +00:00
|
|
|
|
2011-07-30 15:11:52 +00:00
|
|
|
#if we are still good return the info
|
|
|
|
if isgood
|
|
|
|
vprint_status("\tName: #{sname}")
|
|
|
|
vprint_good("\t\tStartup: #{srv_conf['Startup']}")
|
|
|
|
vprint_good("\t\tCommand: #{srv_conf['Command']}")
|
|
|
|
vprint_good("\t\tCredentials: #{srv_conf['Credentials']}")
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
print_error("An error occured enumerating service: #{sname}")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print_error("Problem enumerating services")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|