update meterpreter scripts to check the right prerequisites

bug/bundler_fix
Brent Cook 2017-04-25 23:31:39 -05:00
parent 0ae6142b76
commit aa03db1f5c
53 changed files with 57 additions and 62 deletions

View File

@ -102,7 +102,7 @@ cidr2scan = ""
save2log = true save2log = true
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if args.length > 0 if args.length > 0
if save2log if save2log
save_found(arp_scan(cidr2scan)) save_found(arp_scan(cidr2scan))

View File

@ -344,7 +344,7 @@ def qemuchk(session)
end end
if client.platform =~ /win32|win64/ if client.platform == 'windows'
print_status("Checking if target is a Virtual Machine .....") print_status("Checking if target is a Virtual Machine .....")
found = hypervchk(session) found = hypervchk(session)
found = vmwarechk(session) if not found found = vmwarechk(session) if not found

View File

@ -26,14 +26,9 @@ opts.parse(args) { |opt, idx, val|
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
# Collect even without a database to store them. # Collect even without a database to store them.
if client.framework.db.active db_ok = client.framework.db.active
db_ok = true
else
db_ok = false
end
# Make sure we're rockin Priv and Incognito # Make sure we're rockin Priv and Incognito
client.core.use("priv") if not client.respond_to?("priv") client.core.use("priv") if not client.respond_to?("priv")

View File

@ -56,7 +56,7 @@ end
# Create Filename info to be appended to downloaded files # Create Filename info to be appended to downloaded files
filenameinfo = "_" + ::Time.now.strftime("%Y%m%d.%M%S") filenameinfo = "_" + ::Time.now.strftime("%Y%m%d.%M%S")
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
# Create a directory for the logs # Create a directory for the logs
logs = ::File.join(Msf::Config.log_directory, 'scripts','domain_admins') logs = ::File.join(Msf::Config.log_directory, 'scripts','domain_admins')

View File

@ -369,7 +369,7 @@ def get_time(lo_byte, hi_byte)
end end
return time return time
end end
if client.platform =~ /win32|win64/ if client.platform == 'windows'
enum_users(os).each do |user| enum_users(os).each do |user|
if user['userpath'] if user['userpath']
print_status "Extracting lnk files for user #{user['username']} at #{user['userpath']}..." print_status "Extracting lnk files for user #{user['username']} at #{user['userpath']}..."

View File

@ -84,7 +84,7 @@ mul.exploit_simple(
'RunAsJob' => true 'RunAsJob' => true
) )
if client.platform =~ /win32|win64/ if client.platform == 'windows'
server = client.sys.process.open server = client.sys.process.open
print_status("Current server process: #{server.name} (#{server.pid})") print_status("Current server process: #{server.name} (#{server.pid})")

View File

@ -254,7 +254,7 @@ end
kill_frfx = true kill_frfx = true
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if frfxchk if frfxchk
user = @client.sys.config.getuid user = @client.sys.config.getuid
if not is_system? if not is_system?

View File

@ -89,7 +89,7 @@ end
ls_current ls_current
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if args.length == 0 if args.length == 0
print_line "Meterpreter Script for enumerating Current logged users and users that have loged in to the system." print_line "Meterpreter Script for enumerating Current logged users and users that have loged in to the system."
print_line(@@exec_opts.usage) print_line(@@exec_opts.usage)

View File

@ -124,7 +124,7 @@ def enum_powershell
end end
end end
if client.platform =~ /win32|win64/ if client.platform == 'windows'
enum_powershell enum_powershell
else else
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")

View File

@ -91,7 +91,7 @@ def enum_saved_sessions(reg_key_base)
end end
end end
end end
if client.platform =~ /win32|win64/ if client.platform == 'windows'
hkcu_base.each do |hkb| hkcu_base.each do |hkb|
if check_putty(hkb) if check_putty(hkb)
enum_known_ssh_hosts(hkb) enum_known_ssh_hosts(hkb)

View File

@ -297,7 +297,7 @@ def enum_vmwarewrk
end end
end end
end end
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if check_vmsoft if check_vmsoft
vmware_products = check_prods() vmware_products = check_prods()
if vmware_products.include?("VMware VirtualCenter") if vmware_products.include?("VMware VirtualCenter")

View File

@ -204,7 +204,7 @@ opts.parse(args) { |opt, idx, val|
} }
# Check for Version of Meterpreter # Check for Version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
# Print usage & exit if the user didn't specify an action # Print usage & exit if the user didn't specify an action
# to default to just running for all logs) # to default to just running for all logs)

View File

@ -33,7 +33,7 @@ def usage
end end
# Check that we are running under the right type of Meterpreter # Check that we are running under the right type of Meterpreter
if client.platform =~ /win32|win64/ if client.platform == 'windows'
# Parse the options # Parse the options
if args.length > 0 if args.length > 0
@opts.parse(args) { |opt, idx, val| @opts.parse(args) { |opt, idx, val|

View File

@ -62,7 +62,7 @@ opts.parse(args) { |opt, idx, val|
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
app_list app_list
else else
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")

View File

@ -40,7 +40,7 @@ opts.parse(args) { |opt, idx, val|
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
list_env_vars(var_names) list_env_vars(var_names)
else else
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")

View File

@ -150,7 +150,7 @@ def enum_users(os)
end end
################## MAIN ################## ################## MAIN ##################
if client.platform =~ /win32|win64/ if client.platform == 'windows'
print_status("Running Meterpreter FileZilla Credential harvester script") print_status("Running Meterpreter FileZilla Credential harvester script")
print_status("All services are logged at #{dest}") print_status("All services are logged at #{dest}")
enum_users(os).each do |u| enum_users(os).each do |u|

View File

@ -183,7 +183,7 @@ end
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
################## MAIN ################## ################## MAIN ##################
if client.platform =~ /win32|win64/ if client.platform == 'windows'
print_status("Running Meterpreter Pidgin Credential harvester script") print_status("Running Meterpreter Pidgin Credential harvester script")
print_status("All services are logged at #{dest}") print_status("All services are logged at #{dest}")
enum_users(os).each do |u| enum_users(os).each do |u|

View File

@ -38,7 +38,7 @@ end
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
print_status("Searching for community strings...") print_status("Searching for community strings...")
strs = get_community(session) strs = get_community(session)
if strs if strs

View File

@ -364,7 +364,7 @@ killfw = false
end end
} }
# get the version of windows # get the version of windows
if client.platform =~ /win32|win64/ if client.platform == 'windows'
wnvr = session.sys.config.sysinfo["OS"] wnvr = session.sys.config.sysinfo["OS"]
print_status("Running Getcountermeasure on the target...") print_status("Running Getcountermeasure on the target...")
check(session,avs,killbt) check(session,avs,killbt)

View File

@ -151,7 +151,7 @@ frwrd = nil
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if args.length > 0 if args.length > 0
if enbl or (usr and pass) if enbl or (usr and pass)
message message

View File

@ -155,7 +155,7 @@ enbl = nil
} }
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
if enbl or (usr!= nil && pass != nil) if enbl or (usr!= nil && pass != nil)
message message

View File

@ -81,7 +81,7 @@ keytosearch = nil
keytosearch = val keytosearch = val
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if keytosearch == nil if keytosearch == nil
print_status("Searching for VNC Passwords in the registry....") print_status("Searching for VNC Passwords in the registry....")
keys.each { |key| keys.each { |key|

View File

@ -244,7 +244,7 @@ def decrypt_user_hash(rid, hbootkey, enchash, pass)
d1o << d2.final d1o << d2.final
d1o + d2o d1o + d2o
end end
if client.platform =~ /win32|win64/ if client.platform == 'windows'
begin begin
print_status("Obtaining the boot key...") print_status("Obtaining the boot key...")

View File

@ -74,7 +74,7 @@ def cleardnscach(session)
print_status("Clearing the DNS Cache") print_status("Clearing the DNS Cache")
session.sys.process.execute("cmd /c ipconfig /flushdns",nil, {'Hidden' => true}) session.sys.process.execute("cmd /c ipconfig /flushdns",nil, {'Hidden' => true})
end end
if client.platform =~ /win32|win64/ if client.platform == 'windows'
@@exec_opts.parse(args) { |opt, idx, val| @@exec_opts.parse(args) { |opt, idx, val|
case opt case opt
when "-e" when "-e"

View File

@ -196,7 +196,7 @@ kill = false
kill = true kill = true
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if (captype.to_i == 2) if (captype.to_i == 2)
if startkeylogger(session) if startkeylogger(session)
keycap(session, keytime, logfile) keycap(session, keytime, logfile)

View File

@ -42,7 +42,7 @@ rport = 31337
install = false install = false
autoconn = false autoconn = false
remove = false remove = false
if client.platform =~ /win32|win64/ if client.platform == 'windows'
# #
# Option parsing # Option parsing

View File

@ -61,7 +61,7 @@ end
### Main ### ### Main ###
if client.platform =~ /win32|win64/ if client.platform == 'windows'
server = client.sys.process.open server = client.sys.process.open
original_pid = server.pid original_pid = server.pid
print_status("Current server process: #{server.name} (#{server.pid})") print_status("Current server process: #{server.name} (#{server.pid})")

View File

@ -122,7 +122,7 @@ end
} }
# Check for version of Meterpreter # Check for version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
# Create a exploit/multi/handler if desired # Create a exploit/multi/handler if desired
create_multi_handler(payload_type) if start_handler create_multi_handler(payload_type) if start_handler

View File

@ -311,7 +311,7 @@ srvrc = nil
end end
} }
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if pngsp == 1 if pngsp == 1
if range != nil if range != nil
message(logs) message(logs)

View File

@ -200,7 +200,7 @@ end
} }
# Check for Version of Meterpreter # Check for Version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
if !int_id.nil? or !list_int.nil? if !int_id.nil? or !list_int.nil?
if not is_uac_enabled? or is_admin? if not is_uac_enabled? or is_admin?

View File

@ -62,7 +62,7 @@ end
if rhost.nil? or rport.nil? if rhost.nil? or rport.nil?
usage usage
elsif client.platform =~ /win32|win64/ elsif client.platform == 'windows'
client.sys.process.get_processes().each do |m| client.sys.process.get_processes().each do |m|
if ( m['name'] =~ /PAVSRV51\.EXE/ ) if ( m['name'] =~ /PAVSRV51\.EXE/ )

View File

@ -63,7 +63,7 @@ end
if rhost.nil? or rport.nil? if rhost.nil? or rport.nil?
usage usage
if client.platform =~ /win32|win64/ if client.platform == 'windows'
client.sys.process.get_processes().each do |m| client.sys.process.get_processes().each do |m|
if ( m['name'] =~ /HPZipm12\.exe/ ) if ( m['name'] =~ /HPZipm12\.exe/ )

View File

@ -147,7 +147,7 @@ check_update = false
raise Rex::Script::Completed raise Rex::Script::Completed
end end
} }
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
prefetch_local = ::File.join(Msf::Config.data_directory, "prefetch.exe") prefetch_local = ::File.join(Msf::Config.data_directory, "prefetch.exe")
if !(::File.exist?(prefetch_local)) if !(::File.exist?(prefetch_local))

View File

@ -147,9 +147,9 @@ def get_mem_usage( pid )
# Note: As we get the raw structure back from railgun we need to account # Note: As we get the raw structure back from railgun we need to account
# for SIZE_T variables being 32bit on x86 and 64bit on x64 # for SIZE_T variables being 32bit on x86 and 64bit on x64
mem = nil mem = nil
if( @client.platform =~ /win32/ ) if( @client.arch == 'x86' )
mem = pmc[12..15].unpack('V').first mem = pmc[12..15].unpack('V').first
elsif( @client.platform =~ /win64/ ) elsif( @client.arch == 'x64' )
mem = pmc[16..23].unpack('Q').first mem = pmc[16..23].unpack('Q').first
end end
return (mem/1024) return (mem/1024)
@ -165,7 +165,7 @@ def get_mem_usage( pid )
end end
# Main # Main
if client.platform =~ /win32|win64/ if client.platform == 'windows'
if resource if resource
resource.each do |r| resource.each do |r|
next if r.strip.length < 1 next if r.strip.length < 1

View File

@ -144,7 +144,7 @@ def helpmsg
@@exec_opts.usage) @@exec_opts.usage)
end end
################## MAIN ################## ################## MAIN ##################
if client.platform =~ /win32|win64/ if client.platform == 'windows'
localos = session.sys.config.sysinfo localos = session.sys.config.sysinfo
# Check that the command is not being ran on a Win2k host # Check that the command is not being ran on a Win2k host

View File

@ -241,7 +241,7 @@ password = nil
end end
} }
if client.platform =~ /win32|win64/ if client.platform != 'windows'
if helpcall == 1 if helpcall == 1
usage() usage()
elsif cmd == nil && file == nil elsif cmd == nil && file == nil

View File

@ -153,7 +153,7 @@ end
} }
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
print_status("Meterpreter session running as #{session.sys.config.getuid}") print_status("Meterpreter session running as #{session.sys.config.getuid}")
if help == 0 && commands.length != 0 if help == 0 && commands.length != 0
abuse(session,targets,commands,username,password,delay) abuse(session,targets,commands,username,password,delay)

View File

@ -77,7 +77,7 @@ logs = ::File.join(Msf::Config.log_directory, 'scripts','scraper', host + "_" +
# Create the log directory # Create the log directory
::FileUtils.mkdir_p(logs) ::FileUtils.mkdir_p(logs)
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
begin begin
tmp = client.sys.config.getenv('TEMP') tmp = client.sys.config.getenv('TEMP')

View File

@ -43,7 +43,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
os = client.sys.config.sysinfo['OS'] os = client.sys.config.sysinfo['OS']
targets.each do |t| targets.each do |t|

View File

@ -60,7 +60,7 @@ def wrong_meter_version(meter = meter_type)
end end
# Check for Version of Meterpreter # Check for Version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
session = client session = client

View File

@ -83,7 +83,7 @@ def unsupported
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
# Get arguments # Get arguments
basedir = args[0] || "C:\\" basedir = args[0] || "C:\\"
filter = args[1] || "office" filter = args[1] || "office"

View File

@ -70,7 +70,7 @@ end
################## Main ################## ################## Main ##################
# Check for Version of Meterpreter # Check for Version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
@exec_opts.parse(args) { |opt, idx, val| @exec_opts.parse(args) { |opt, idx, val|
case opt case opt

View File

@ -85,7 +85,7 @@ end
} }
# Check for Version of Meterpreter # Check for Version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
# Create Folder for logs and get path for logs # Create Folder for logs and get path for logs
if not log_folder if not log_folder

View File

@ -51,7 +51,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
# #
# Option parsing # Option parsing
# #

View File

@ -93,7 +93,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
#parsing of Options #parsing of Options
file = "" file = ""
cmdopt = nil cmdopt = nil

View File

@ -27,7 +27,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
# Spawn calculator # Spawn calculator
pid = client.sys.process.execute("calc.exe", nil, {'Hidden' => 'true'}).pid pid = client.sys.process.execute("calc.exe", nil, {'Hidden' => 'true'}).pid

View File

@ -88,7 +88,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
# #
# Create the raw payload # Create the raw payload

View File

@ -60,7 +60,7 @@ opts.parse(args) { |opt, idx, val|
end end
} }
if !(client.platform =~ /win32|win64/) if client.platform != 'windows'
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end

View File

@ -307,7 +307,7 @@ downloaded = nil
} }
# Check for Version of Meterpreter # Check for Version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
if not rhost or not username if not rhost or not username

View File

@ -179,7 +179,7 @@ type = "auto"
} }
# Check for Version of Meterpreter # Check for Version of Meterpreter
wrong_meter_version(meter_type) if meter_type !~ /win32|win64/i wrong_meter_version(meter_type) if meter_type != 'windows'
# #
# Uninstall if selected # Uninstall if selected

View File

@ -150,7 +150,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
################## MAIN ################## ################## MAIN ##################

View File

@ -569,7 +569,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
################## MAIN ################## ################## MAIN ##################

View File

@ -127,7 +127,7 @@ end
if args.length == 0 if args.length == 0
usage usage
end end
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform != 'windows'
if outfile == nil if outfile == nil
print_status wmicexec(session,commands) print_status wmicexec(session,commands)