update meterpreter scripts to check the right prerequisites

This commit is contained in:
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
end
}
if client.platform =~ /win32|win64/
if client.platform == 'windows'
if args.length > 0
if save2log
save_found(arp_scan(cidr2scan))

View File

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

View File

@ -26,14 +26,9 @@ opts.parse(args) { |opt, idx, val|
end
}
if client.platform =~ /win32|win64/
if client.platform == 'windows'
# Collect even without a database to store them.
if client.framework.db.active
db_ok = true
else
db_ok = false
end
db_ok = client.framework.db.active
# Make sure we're rockin Priv and Incognito
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
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
logs = ::File.join(Msf::Config.log_directory, 'scripts','domain_admins')

View File

@ -369,7 +369,7 @@ def get_time(lo_byte, hi_byte)
end
return time
end
if client.platform =~ /win32|win64/
if client.platform == 'windows'
enum_users(os).each do |user|
if 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
)
if client.platform =~ /win32|win64/
if client.platform == 'windows'
server = client.sys.process.open
print_status("Current server process: #{server.name} (#{server.pid})")

View File

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

View File

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

View File

@ -124,7 +124,7 @@ def enum_powershell
end
end
if client.platform =~ /win32|win64/
if client.platform == 'windows'
enum_powershell
else
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
if client.platform =~ /win32|win64/
if client.platform == 'windows'
hkcu_base.each do |hkb|
if check_putty(hkb)
enum_known_ssh_hosts(hkb)

View File

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

View File

@ -204,7 +204,7 @@ opts.parse(args) { |opt, idx, val|
}
# 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
# to default to just running for all logs)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -122,7 +122,7 @@ end
}
# 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_multi_handler(payload_type) if start_handler

View File

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

View File

@ -200,7 +200,7 @@ end
}
# 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 not is_uac_enabled? or is_admin?

View File

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

View File

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

View File

@ -147,7 +147,7 @@ check_update = false
raise Rex::Script::Completed
end
}
unsupported if client.platform !~ /win32|win64/i
unsupported if client.platform != 'windows'
prefetch_local = ::File.join(Msf::Config.data_directory, "prefetch.exe")
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
# for SIZE_T variables being 32bit on x86 and 64bit on x64
mem = nil
if( @client.platform =~ /win32/ )
if( @client.arch == 'x86' )
mem = pmc[12..15].unpack('V').first
elsif( @client.platform =~ /win64/ )
elsif( @client.arch == 'x64' )
mem = pmc[16..23].unpack('Q').first
end
return (mem/1024)
@ -165,7 +165,7 @@ def get_mem_usage( pid )
end
# Main
if client.platform =~ /win32|win64/
if client.platform == 'windows'
if resource
resource.each do |r|
next if r.strip.length < 1

View File

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

View File

@ -241,7 +241,7 @@ password = nil
end
}
if client.platform =~ /win32|win64/
if client.platform != 'windows'
if helpcall == 1
usage()
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}")
if help == 0 && commands.length != 0
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
::FileUtils.mkdir_p(logs)
unsupported if client.platform !~ /win32|win64/i
unsupported if client.platform != 'windows'
begin
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!")
raise Rex::Script::Completed
end
unsupported if client.platform !~ /win32|win64/i
unsupported if client.platform != 'windows'
os = client.sys.config.sysinfo['OS']
targets.each do |t|

View File

@ -60,7 +60,7 @@ def wrong_meter_version(meter = meter_type)
end
# 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

View File

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

View File

@ -70,7 +70,7 @@ end
################## Main ##################
# 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|
case opt

View File

@ -85,7 +85,7 @@ end
}
# 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
if not log_folder

View File

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

View File

@ -93,7 +93,7 @@ def unsupported
print_error("This version of Meterpreter is not supported with this Script!")
raise Rex::Script::Completed
end
unsupported if client.platform !~ /win32|win64/i
unsupported if client.platform != 'windows'
#parsing of Options
file = ""
cmdopt = nil
@ -132,7 +132,7 @@ print_status("Running Upload and Execute Meterpreter script....")
exec = upload(session,file,path)
if sleep_sec
print_status("\tSleeping for #{sleep_sec}s...")
Rex.sleep(sleep_sec)
Rex.sleep(sleep_sec)
end
cmd_on_trgt_exec(session,exec,cmdopt,verbose)
if remove == 1

View File

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

View File

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

View File

@ -307,7 +307,7 @@ downloaded = nil
}
# 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

View File

@ -179,7 +179,7 @@ type = "auto"
}
# 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

View File

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

View File

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

View File

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