Rejig platform to use windows instead of win32/win64

bug/bundler_fix
OJ 2016-10-14 10:10:04 +10:00
parent 699a8e91d2
commit 022830634b
No known key found for this signature in database
GPG Key ID: D5DC61FB93260597
44 changed files with 198 additions and 171 deletions

View File

@ -284,7 +284,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client
# #
# Load the stdapi extension. # Load the stdapi extension.
# #
def load_stdapi() def load_stdapi
original = console.disable_output original = console.disable_output
console.disable_output = true console.disable_output = true
console.run_single('load stdapi') console.run_single('load stdapi')
@ -294,9 +294,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client
# #
# Load the priv extension. # Load the priv extension.
# #
def load_priv() def load_priv
original = console.disable_output original = console.disable_output
console.disable_output = true console.disable_output = true
console.run_single('load priv') console.run_single('load priv')
console.disable_output = original console.disable_output = original
@ -310,7 +309,6 @@ class Meterpreter < Rex::Post::Meterpreter::Client
begin begin
self.machine_id = self.core.machine_id(timeout) self.machine_id = self.core.machine_id(timeout)
self.payload_uuid ||= self.core.uuid(timeout)
return true return true
rescue ::Rex::Post::Meterpreter::RequestError rescue ::Rex::Post::Meterpreter::RequestError
@ -325,40 +323,6 @@ class Meterpreter < Rex::Post::Meterpreter::Client
def update_session_info def update_session_info
username = self.sys.config.getuid username = self.sys.config.getuid
sysinfo = self.sys.config.sysinfo sysinfo = self.sys.config.sysinfo
tuple = self.platform.split('/')
#
# Windows meterpreter currently needs 'win32' or 'win64' to be in the
# second half of the platform tuple, in order for various modules and
# library code match on that specific string.
#
if self.platform !~ /win32|win64/
platform = case self.sys.config.sysinfo['OS']
when /windows/i
Msf::Module::Platform::Windows
when /darwin/i
Msf::Module::Platform::OSX
when /freebsd/i
Msf::Module::Platform::FreeBSD
when /netbsd/i
Msf::Module::Platform::NetBSD
when /openbsd/i
Msf::Module::Platform::OpenBSD
when /sunos/i
Msf::Module::Platform::Solaris
when /android/i
Msf::Module::Platform::Android
else
Msf::Module::Platform::Linux
end.realname.downcase
#
# This normalizes the platform from 'python/python' to 'python/linux'
#
self.platform = "#{tuple[0]}/#{platform}"
end
safe_info = "#{username} @ #{sysinfo['Computer']}" safe_info = "#{username} @ #{sysinfo['Computer']}"
safe_info.force_encoding("ASCII-8BIT") if safe_info.respond_to?(:force_encoding) safe_info.force_encoding("ASCII-8BIT") if safe_info.respond_to?(:force_encoding)
@ -505,8 +469,33 @@ class Meterpreter < Rex::Post::Meterpreter::Client
sock sock
end end
attr_accessor :platform #
attr_accessor :binary_suffix # Get a string representation of the current session platform
#
def platform
# TODO: talk about this with the devs because we seem to rely on this
# value when populating the DB before the session is even fully established.
if self.payload_uuid
# return the actual platform of the current session if it's there
self.payload_uuid.to_platform
else
# otherwise just use the base for the session type tied to this handler
self.base_platform
end
end
#
# Get the value to use for file suffixes based on the platform
#
def binary_suffix
self.payload_uuid.binary_suffix
end
# This is the base platform for the original payload, required for when the
# session is first created thanks to the fact that the DB session recording
# happens before the session is even established.
attr_accessor :base_platform
attr_accessor :console # :nodoc: attr_accessor :console # :nodoc:
attr_accessor :skip_ssl attr_accessor :skip_ssl
attr_accessor :skip_cleanup attr_accessor :skip_cleanup

View File

@ -19,8 +19,7 @@ class Meterpreter_Java_Java < Msf::Sessions::Meterpreter
end end
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'java/java' self.base_platform = 'java/java'
self.binary_suffix = 'jar'
end end
end end

View File

@ -19,8 +19,7 @@ class Meterpreter_mipsbe_Linux < Msf::Sessions::Meterpreter
end end
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'mipsbe/linux' self.base_platform = 'mipsbe/linux'
self.binary_suffix = 'lso'
end end
end end

View File

@ -60,7 +60,7 @@ module MeterpreterOptions
session.load_session_info session.load_session_info
end end
if session.platform =~ /win32|win64/i if session.platform =~ /windows/i
session.load_priv rescue nil session.load_priv rescue nil
end end
end end

View File

@ -19,8 +19,7 @@ class Meterpreter_Php_Php < Msf::Sessions::Meterpreter
end end
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'php/php' self.base_platform = 'php/php'
self.binary_suffix = 'php'
end end
end end

View File

@ -86,8 +86,7 @@ class Meterpreter_Python_Python < Msf::Sessions::Meterpreter
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'python/python' self.base_platform = 'python/python'
self.binary_suffix = 'py'
end end
def lookup_error(error_code) def lookup_error(error_code)
@ -116,5 +115,6 @@ class Meterpreter_Python_Python < Msf::Sessions::Meterpreter
false false
end end
end end
end end
end end

View File

@ -19,8 +19,7 @@ class Meterpreter_x64_Mettle_Linux < Msf::Sessions::Meterpreter
end end
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'x64/linux' self.base_platform = 'x64/linux'
self.binary_suffix = 'lso'
end end
end end

View File

@ -14,8 +14,7 @@ module Sessions
class Meterpreter_x64_Win < Msf::Sessions::Meterpreter class Meterpreter_x64_Win < Msf::Sessions::Meterpreter
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'x64/win64' self.base_platform = 'x64/windows'
self.binary_suffix = 'x64.dll'
end end
def lookup_error(code) def lookup_error(code)

View File

@ -13,8 +13,7 @@ module Sessions
class Meterpreter_x86_BSD < Msf::Sessions::Meterpreter class Meterpreter_x86_BSD < Msf::Sessions::Meterpreter
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'x86/bsd' self.base_platform = 'x86/bsd'
self.binary_suffix = 'bso'
end end
end end

View File

@ -13,8 +13,7 @@ module Sessions
class Meterpreter_x86_Linux < Msf::Sessions::Meterpreter class Meterpreter_x86_Linux < Msf::Sessions::Meterpreter
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'x86/linux' self.base_platform = 'x86/linux'
self.binary_suffix = 'lso'
end end
end end

View File

@ -19,8 +19,7 @@ class Meterpreter_x86_Mettle_Linux < Msf::Sessions::Meterpreter
end end
def initialize(rstream, opts={}) def initialize(rstream, opts={})
super super
self.platform = 'x86/linux' self.base_platform = 'x86/linux'
self.binary_suffix = 'lso'
end end
end end

View File

@ -14,8 +14,7 @@ module Sessions
class Meterpreter_x86_Win < Msf::Sessions::Meterpreter class Meterpreter_x86_Win < Msf::Sessions::Meterpreter
def initialize(rstream,opts={}) def initialize(rstream,opts={})
super super
self.platform = 'x86/win32' self.base_platform = 'x86/windows'
self.binary_suffix = 'x86.dll'
end end
def lookup_error(code) def lookup_error(code)

View File

@ -298,6 +298,52 @@ class Msf::Payload::UUID
].join("/") ].join("/")
end end
#
# Return a string that represents the Meterpreter platform
#
def to_platform
# mini-patch for x86_64 so that it renders x64 instead. This is
# mostly to keep various external modules happy.
arch = self.arch
if arch == ARCH_X86_64
arch = ARCH_X64
end
"#{arch}/#{self.platform}"
end
#
# TODO: Not sure if this is the best place for this to go. Open to
# suggestions for moving it elsewhere
#
def binary_suffix
# generate a file/binary suffix based on the current platform
case self.platform
when 'windows'
# with windows, we also need to care about arch
if self.arch == ARCH_X86
'x86.dll'
else
'x64.dll'
end
when 'android', 'java'
'jar'
when 'ruby'
'rb'
when 'linux' , 'aix' , 'hpux' , 'irix' , 'unix'
'lso'
when 'bsd' , 'openbsd' , 'bsdi' , 'netbsd' , 'freebsd'
'bso'
when 'php'
'php'
when 'python'
'py'
when 'nodejs', 'js'
'js'
else
nil
end
end
# #
# Provides a hash representation of a UUID # Provides a hash representation of a UUID
# #

View File

@ -431,40 +431,42 @@ class ClientCore < Extension
# Migrates the meterpreter instance to the process specified # Migrates the meterpreter instance to the process specified
# by pid. The connection to the server remains established. # by pid. The connection to the server remains established.
# #
def migrate(pid, writable_dir = nil, opts = {}) def migrate(target_pid, writable_dir = nil, opts = {})
keepalive = client.send_keepalives keepalive = client.send_keepalives
client.send_keepalives = false client.send_keepalives = false
process = nil target_process = nil
current_process = nil
binary_suffix = nil binary_suffix = nil
old_platform = client.platform
old_binary_suffix = client.binary_suffix
# Load in the stdapi extension if not allready present so we can determine the target pid architecture... # Load in the stdapi extension if not allready present so we can determine the target pid architecture...
client.core.use('stdapi') if not client.ext.aliases.include?('stdapi') client.core.use('stdapi') if not client.ext.aliases.include?('stdapi')
# Determine the architecture for the pid we are going to migrate into... current_pid = client.sys.process.getpid
# Find the current and target process instances
client.sys.process.processes.each { | p | client.sys.process.processes.each { | p |
if p['pid'] == pid if p['pid'] == target_pid
process = p target_process = p
break elsif p['pid'] == current_pid
current_process = p
end end
} }
# We cant migrate into a process that does not exist. # We cant migrate into a process that does not exist.
unless process unless target_process
raise RuntimeError, 'Cannot migrate into non existent process', caller raise RuntimeError, 'Cannot migrate into non existent process', caller
end end
# We cannot migrate into a process that we are unable to open # We cannot migrate into a process that we are unable to open
# On linux, arch is empty even if we can access the process # On linux, arch is empty even if we can access the process
if client.platform =~ /win/ if client.platform =~ /win/
if process['arch'] == nil || process['arch'].empty? if target_process['arch'] == nil || target_process['arch'].empty?
raise RuntimeError, "Cannot migrate into this process (insufficient privileges)", caller raise RuntimeError, "Cannot migrate into this process (insufficient privileges)", caller
end end
end end
# And we also cannot migrate into our own current process... # And we also cannot migrate into our own current process...
if process['pid'] == client.sys.process.getpid if current_process['pid'] == target_process['pid']
raise RuntimeError, 'Cannot migrate into current process', caller raise RuntimeError, 'Cannot migrate into current process', caller
end end
@ -481,7 +483,7 @@ class ClientCore < Extension
# Rex::Post::FileStat#writable? isn't available # Rex::Post::FileStat#writable? isn't available
end end
blob = generate_payload_stub(process) blob = generate_payload_stub(target_process)
# Build the migration request # Build the migration request
request = Packet.create_request('core_migrate') request = Packet.create_request('core_migrate')
@ -507,16 +509,23 @@ class ClientCore < Extension
request.add_tlv(TLV_TYPE_MIGRATE_SOCKET_PATH, socket_path, false, client.capabilities[:zlib]) request.add_tlv(TLV_TYPE_MIGRATE_SOCKET_PATH, socket_path, false, client.capabilities[:zlib])
end end
request.add_tlv( TLV_TYPE_MIGRATE_PID, pid ) request.add_tlv( TLV_TYPE_MIGRATE_PID, target_pid )
request.add_tlv( TLV_TYPE_MIGRATE_LEN, blob.length ) request.add_tlv( TLV_TYPE_MIGRATE_LEN, blob.length )
request.add_tlv( TLV_TYPE_MIGRATE_PAYLOAD, blob, false, client.capabilities[:zlib]) request.add_tlv( TLV_TYPE_MIGRATE_PAYLOAD, blob, false, client.capabilities[:zlib])
if process['arch'] == ARCH_X86_64 if target_process['arch'] == ARCH_X86_64
request.add_tlv( TLV_TYPE_MIGRATE_ARCH, 2 ) # PROCESS_ARCH_X64 request.add_tlv( TLV_TYPE_MIGRATE_ARCH, 2 ) # PROCESS_ARCH_X64
else else
request.add_tlv( TLV_TYPE_MIGRATE_ARCH, 1 ) # PROCESS_ARCH_X86 request.add_tlv( TLV_TYPE_MIGRATE_ARCH, 1 ) # PROCESS_ARCH_X86
end end
# if we change architecture, we need to change UUID as well
if current_process['arch'] != target_process['arch']
client.payload_uuid.arch = target_process['arch']
request.add_tlv( TLV_TYPE_UUID, client.payload_uuid.to_raw )
end
# Send the migration request. Timeout can be specified by the caller, or set to a min # Send the migration request. Timeout can be specified by the caller, or set to a min
# of 60 seconds. # of 60 seconds.
timeout = [(opts[:timeout] || 0), 60].max timeout = [(opts[:timeout] || 0), 60].max
@ -558,30 +567,6 @@ class ClientCore < Extension
end end
end end
# Update the meterpreter platform/suffix for loading extensions as we may
# have changed target architecture
# sf: this is kinda hacky but it works. As ruby doesnt let you un-include a
# module this is the simplest solution I could think of. If the platform
# specific modules Meterpreter_x64_Win/Meterpreter_x86_Win change
# significantly we will need a better way to do this.
case client.platform
when /win/i
if process['arch'] == ARCH_X86_64
client.platform = 'x64/win64'
client.binary_suffix = 'x64.dll'
else
client.platform = 'x86/win32'
client.binary_suffix = 'x86.dll'
end
when /linux/i
client.platform = 'x86/linux'
client.binary_suffix = 'lso'
else
client.platform = old_platform
client.binary_suffix = old_binary_suffix
end
# Load all the extensions that were loaded in the previous instance (using the correct platform/binary_suffix) # Load all the extensions that were loaded in the previous instance (using the correct platform/binary_suffix)
client.ext.aliases.keys.each { |e| client.ext.aliases.keys.each { |e|
client.core.use(e) client.core.use(e)

View File

@ -361,7 +361,7 @@ class DLL
# puts(" # puts("
#=== START of proccess_function_call snapshot === #=== START of proccess_function_call snapshot ===
# { # {
# :platform => '#{native == 'Q' ? 'x64/win64' : 'x86/win32'}', # :platform => '#{native == 'Q' ? 'x64/windows' : 'x86/windows'}',
# :name => '#{function.windows_name}', # :name => '#{function.windows_name}',
# :params => #{function.params}, # :params => #{function.params},
# :return_type => '#{function.return_type}', # :return_type => '#{function.return_type}',

View File

@ -46,7 +46,7 @@ module MockMagic
end end
end end
def make_mock_client(platform = "x86/win32", target_request_tlvs = [], response_tlvs = []) def make_mock_client(platform = "x86/windows", target_request_tlvs = [], response_tlvs = [])
check_request = lambda do |request| check_request = lambda do |request|
target_request_tlvs.each_pair do |type, target_value| target_request_tlvs.each_pair do |type, target_value|
assert_equal(target_value, request.get_tlv_value(type), assert_equal(target_value, request.get_tlv_value(type),
@ -62,7 +62,7 @@ module MockMagic
def mock_function_descriptions def mock_function_descriptions
[ [
{ {
:platform => "x86/win32", :platform => "x86/windows",
:name => "LookupAccountSidA", :name => "LookupAccountSidA",
:params => [ :params => [
["PCHAR","lpSystemName","in"], ["PCHAR","lpSystemName","in"],
@ -101,7 +101,7 @@ module MockMagic
}, },
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'LookupAccountSidA', :name => 'LookupAccountSidA',
:params => [ :params => [
["PCHAR", "lpSystemName", "in"], ["PCHAR", "lpSystemName", "in"],
@ -140,7 +140,7 @@ module MockMagic
}, },
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptAcquireContextW', :name => 'CryptAcquireContextW',
:params => [["PDWORD", "phProv", "out"], ["PWCHAR", "pszContainer", "in"], ["PWCHAR", "pszProvider", "in"], ["DWORD", "dwProvType", "in"], ["DWORD", "dwflags", "in"]], :params => [["PDWORD", "phProv", "out"], ["PWCHAR", "pszContainer", "in"], ["PWCHAR", "pszProvider", "in"], ["DWORD", "dwProvType", "in"], ["DWORD", "dwflags", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -163,7 +163,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "phProv"=>1371080}, :returned_hash => {"GetLastError"=>0, "return"=>true, "phProv"=>1371080},
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptCreateHash', :name => 'CryptCreateHash',
:params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hKey", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phHash", "out"]], :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hKey", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phHash", "out"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -186,7 +186,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "phHash"=>1370736}, :returned_hash => {"GetLastError"=>0, "return"=>true, "phHash"=>1370736},
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptHashData', :name => 'CryptHashData',
:params => [["LPVOID", "hHash", "in"], ["PWCHAR", "pbData", "in"], ["DWORD", "dwDataLen", "in"], ["DWORD", "dwFlags", "in"]], :params => [["LPVOID", "hHash", "in"], ["PWCHAR", "pbData", "in"], ["DWORD", "dwDataLen", "in"], ["DWORD", "dwFlags", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -209,7 +209,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true}, :returned_hash => {"GetLastError"=>0, "return"=>true},
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptDeriveKey', :name => 'CryptDeriveKey',
:params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hBaseData", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phKey", "inout"]], :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hBaseData", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phKey", "inout"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -232,7 +232,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "phKey"=>1416352}, :returned_hash => {"GetLastError"=>0, "return"=>true, "phKey"=>1416352},
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptDecrypt', :name => 'CryptDecrypt',
:params => [["LPVOID", "hKey", "in"], ["LPVOID", "hHash", "in"], ["BOOL", "Final", "in"], ["DWORD", "dwFlags", "in"], ["PBLOB", "pbData", "inout"], ["PDWORD", "pdwDataLen", "inout"]], :params => [["LPVOID", "hKey", "in"], ["LPVOID", "hHash", "in"], ["BOOL", "Final", "in"], ["DWORD", "dwFlags", "in"], ["PBLOB", "pbData", "inout"], ["PDWORD", "pdwDataLen", "inout"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -255,7 +255,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "pbData"=>"q\x00u\x00x\x00", "pdwDataLen"=>6}, :returned_hash => {"GetLastError"=>0, "return"=>true, "pbData"=>"q\x00u\x00x\x00", "pdwDataLen"=>6},
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptDestroyHash', :name => 'CryptDestroyHash',
:params => [["LPVOID", "hHash", "in"]], :params => [["LPVOID", "hHash", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -278,7 +278,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true}, :returned_hash => {"GetLastError"=>0, "return"=>true},
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptDestroyKey', :name => 'CryptDestroyKey',
:params => [["LPVOID", "hKey", "in"]], :params => [["LPVOID", "hKey", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -301,7 +301,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true}, :returned_hash => {"GetLastError"=>0, "return"=>true},
}, },
{ {
:platform => 'x86/win32', :platform => 'x86/windows',
:name => 'CryptReleaseContext', :name => 'CryptReleaseContext',
:params => [["LPVOID", "hProv", "in"], ["DWORD", "dwFlags", "in"]], :params => [["LPVOID", "hProv", "in"], ["DWORD", "dwFlags", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -324,7 +324,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true}, :returned_hash => {"GetLastError"=>0, "return"=>true},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptAcquireContextW', :name => 'CryptAcquireContextW',
:params => [["PDWORD", "phProv", "out"], ["PWCHAR", "pszContainer", "in"], ["PWCHAR", "pszProvider", "in"], ["DWORD", "dwProvType", "in"], ["DWORD", "dwflags", "in"]], :params => [["PDWORD", "phProv", "out"], ["PWCHAR", "pszContainer", "in"], ["PWCHAR", "pszProvider", "in"], ["DWORD", "dwProvType", "in"], ["DWORD", "dwflags", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -347,7 +347,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "phProv"=>1756800}, :returned_hash => {"GetLastError"=>0, "return"=>true, "phProv"=>1756800},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptCreateHash', :name => 'CryptCreateHash',
:params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hKey", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phHash", "out"]], :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hKey", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phHash", "out"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -370,7 +370,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "phHash"=>1680128}, :returned_hash => {"GetLastError"=>0, "return"=>true, "phHash"=>1680128},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptHashData', :name => 'CryptHashData',
:params => [["LPVOID", "hHash", "in"], ["PWCHAR", "pbData", "in"], ["DWORD", "dwDataLen", "in"], ["DWORD", "dwFlags", "in"]], :params => [["LPVOID", "hHash", "in"], ["PWCHAR", "pbData", "in"], ["DWORD", "dwDataLen", "in"], ["DWORD", "dwFlags", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -393,7 +393,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true}, :returned_hash => {"GetLastError"=>0, "return"=>true},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptDeriveKey', :name => 'CryptDeriveKey',
:params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hBaseData", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phKey", "inout"]], :params => [["LPVOID", "hProv", "in"], ["DWORD", "Algid", "in"], ["LPVOID", "hBaseData", "in"], ["DWORD", "dwFlags", "in"], ["PDWORD", "phKey", "inout"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -416,7 +416,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "phKey"=>1680240}, :returned_hash => {"GetLastError"=>0, "return"=>true, "phKey"=>1680240},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptDecrypt', :name => 'CryptDecrypt',
:params => [["LPVOID", "hKey", "in"], ["LPVOID", "hHash", "in"], ["BOOL", "Final", "in"], ["DWORD", "dwFlags", "in"], ["PBLOB", "pbData", "inout"], ["PDWORD", "pdwDataLen", "inout"]], :params => [["LPVOID", "hKey", "in"], ["LPVOID", "hHash", "in"], ["BOOL", "Final", "in"], ["DWORD", "dwFlags", "in"], ["PBLOB", "pbData", "inout"], ["PDWORD", "pdwDataLen", "inout"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -439,7 +439,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true, "pbData"=>"b\x00a\x00z\x00", "pdwDataLen"=>6}, :returned_hash => {"GetLastError"=>0, "return"=>true, "pbData"=>"b\x00a\x00z\x00", "pdwDataLen"=>6},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptDestroyHash', :name => 'CryptDestroyHash',
:params => [["LPVOID", "hHash", "in"]], :params => [["LPVOID", "hHash", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -462,7 +462,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true}, :returned_hash => {"GetLastError"=>0, "return"=>true},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptDestroyKey', :name => 'CryptDestroyKey',
:params => [["LPVOID", "hKey", "in"]], :params => [["LPVOID", "hKey", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',
@ -485,7 +485,7 @@ module MockMagic
:returned_hash => {"GetLastError"=>0, "return"=>true}, :returned_hash => {"GetLastError"=>0, "return"=>true},
}, },
{ {
:platform => 'x64/win64', :platform => 'x64/windows',
:name => 'CryptReleaseContext', :name => 'CryptReleaseContext',
:params => [["LPVOID", "hProv", "in"], ["DWORD", "dwFlags", "in"]], :params => [["LPVOID", "hProv", "in"], ["DWORD", "dwFlags", "in"]],
:return_type => 'BOOL', :return_type => 'BOOL',

View File

@ -639,7 +639,7 @@ class Util
# Returns true if given platform has 64bit architecture # Returns true if given platform has 64bit architecture
# expects client.platform # expects client.platform
def is_64bit_platform?(platform) def is_64bit_platform?(platform)
platform =~ /win64/ platform =~ /x64/
end end
# #

View File

@ -3,6 +3,7 @@
require 'rex/post/meterpreter/packet_response_waiter' require 'rex/post/meterpreter/packet_response_waiter'
require 'rex/logging' require 'rex/logging'
require 'rex/exceptions' require 'rex/exceptions'
require 'msf/core/payload/uuid'
module Rex module Rex
module Post module Post
@ -244,6 +245,13 @@ module PacketDispatcher
# removed. This happens if the waiter timed out above. # removed. This happens if the waiter timed out above.
remove_response_waiter(waiter) remove_response_waiter(waiter)
# wire in the UUID for this, as it should be part of every response
# packet
if response && !self.payload_uuid
uuid = response.get_tlv_value(TLV_TYPE_UUID)
self.payload_uuid = Msf::Payload::UUID.new({:raw => uuid}) if uuid
end
# Return the response packet, if any # Return the response packet, if any
return response return response
end end

View File

@ -41,7 +41,7 @@ class MetasploitModule < Msf::Post
when /osx/ when /osx/
@platform = :osx @platform = :osx
paths = enum_users_unix paths = enum_users_unix
when /win/ when /windows/
@platform = :windows @platform = :windows
drive = session.sys.config.getenv('SystemDrive') drive = session.sys.config.getenv('SystemDrive')
os = session.sys.config.sysinfo['OS'] os = session.sys.config.sysinfo['OS']

View File

@ -47,7 +47,7 @@ class MetasploitModule < Msf::Post
user_base = "/home/#{user}/" user_base = "/home/#{user}/"
end end
dbvis_file = "#{user_base}.dbvis/config70/dbvis.xml" dbvis_file = "#{user_base}.dbvis/config70/dbvis.xml"
when /win/ when /windows/
if session.type =~ /meterpreter/ if session.type =~ /meterpreter/
user_profile = session.sys.config.getenv('USERPROFILE') user_profile = session.sys.config.getenv('USERPROFILE')
else else
@ -63,7 +63,7 @@ class MetasploitModule < Msf::Post
case session.platform case session.platform
when /linux/ when /linux/
dbvis_file = "#{user_base}.dbvis/config/dbvis.xml" dbvis_file = "#{user_base}.dbvis/config/dbvis.xml"
when /win/ when /windows/
dbvis_file = user_profile + "\\.dbvis\\config\\dbvis.xml" dbvis_file = user_profile + "\\.dbvis\\config\\dbvis.xml"
end end
unless file?(dbvis_file) unless file?(dbvis_file)

View File

@ -46,7 +46,7 @@ class MetasploitModule < Msf::Post
end end
case session.platform case session.platform
when /win/i when /windows/i
cmd = "nslookup" cmd = "nslookup"
when /solaris/i when /solaris/i
cmd = "/usr/sbin/host " cmd = "/usr/sbin/host "
@ -62,7 +62,7 @@ class MetasploitModule < Msf::Post
r = cmd_exec(cmd, "#{n.strip}.#{domain}") r = cmd_exec(cmd, "#{n.strip}.#{domain}")
case session.platform case session.platform
when /win/ when /windows/
proccess_win(r, "#{n.strip}.#{domain}") proccess_win(r, "#{n.strip}.#{domain}")
else else
process_nix(r, "#{n.strip}.#{domain}") process_nix(r, "#{n.strip}.#{domain}")

View File

@ -45,7 +45,7 @@ class MetasploitModule < Msf::Post
end end
case session.platform case session.platform
when /win/i when /windows/i
cmd = "nslookup" cmd = "nslookup"
when /solaris/i when /solaris/i
cmd = "/usr/sbin/host" cmd = "/usr/sbin/host"
@ -59,7 +59,7 @@ class MetasploitModule < Msf::Post
next if ip_add.nil? next if ip_add.nil?
r = cmd_exec(cmd, " #{ip_add}") r = cmd_exec(cmd, " #{ip_add}")
case session.platform case session.platform
when /win/ when /windows/
if r =~ /(Name)/ if r =~ /(Name)/
r.scan(/Name:\s*\S*\s/) do |n| r.scan(/Name:\s*\S*\s/) do |n|
hostname = n.split(": ") hostname = n.split(": ")

View File

@ -56,7 +56,7 @@ class MetasploitModule < Msf::Post
a = [] a = []
case session.platform case session.platform
when /win/i when /windows/i
ns_opt = " -query=srv " ns_opt = " -query=srv "
cmd = "nslookup" cmd = "nslookup"
when /solaris/i when /solaris/i
@ -74,7 +74,7 @@ class MetasploitModule < Msf::Post
r = cmd_exec(cmd, ns_opt + "#{srv}#{domain}") r = cmd_exec(cmd, ns_opt + "#{srv}#{domain}")
case session.platform case session.platform
when /win/ when /windows/
if r =~ /\s*internet\saddress\s\=\s/ if r =~ /\s*internet\saddress\s\=\s/
nslookup_srv_consume("#{srv}#{domain}", r).each do |f| nslookup_srv_consume("#{srv}#{domain}", r).each do |f|
print_good("\t#{f[:srv]} #{f[:target]} #{f[:port]} #{f[:ip]}") print_good("\t#{f[:srv]} #{f[:target]} #{f[:port]} #{f[:ip]}")

View File

@ -28,7 +28,7 @@ class MetasploitModule < Msf::Post
end end
def run def run
if session.platform =~ /win/ if session.platform =~ /windows/
if session.type == 'meterpreter' if session.type == 'meterpreter'
begin begin
res = cmd_exec('c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage', 'list -l vms') res = cmd_exec('c:\\Program Files\\Oracle\\VirtualBox\\vboxmanage', 'list -l vms')

View File

@ -35,7 +35,7 @@ class MetasploitModule < Msf::Post
def get_env_shell def get_env_shell
print_line @output if @output print_line @output if @output
if session.platform =~ /win/ if session.platform =~ /windows/
@ltype = "windows.environment" @ltype = "windows.environment"
cmd = "set" cmd = "set"
else else

View File

@ -36,7 +36,8 @@ class MetasploitModule < Msf::Post
when /osx/ when /osx/
@platform = :osx @platform = :osx
paths = enum_users_unix paths = enum_users_unix
when /win/ when /windows/
@platform = :windows
profiles = grab_user_profiles() profiles = grab_user_profiles()
profiles.each do |user| profiles.each do |user|
next if user['AppData'] == nil next if user['AppData'] == nil

View File

@ -77,7 +77,7 @@ class MetasploitModule < Msf::Post
@platform = :unix @platform = :unix
when /osx/ when /osx/
@platform = :osx @platform = :osx
when /win/ when /windows/
if session.type != "meterpreter" if session.type != "meterpreter"
print_error "Only meterpreter sessions are supported on Windows hosts" print_error "Only meterpreter sessions are supported on Windows hosts"
return return
@ -367,7 +367,7 @@ class MetasploitModule < Msf::Post
loot_file = Rex::Text::rand_text_alpha(6) + ".txt" loot_file = Rex::Text::rand_text_alpha(6) + ".txt"
case @platform case @platform
when /win/ when /windows/
unless got_root || session.sys.config.sysinfo['OS'] =~ /xp/i unless got_root || session.sys.config.sysinfo['OS'] =~ /xp/i
print_warning("You may need SYSTEM privileges on this platform for the DECRYPT option to work") print_warning("You may need SYSTEM privileges on this platform for the DECRYPT option to work")
end end
@ -560,7 +560,7 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
args.insert(0, "\"#{@paths['ff']}firefox --display=:0 ") args.insert(0, "\"#{@paths['ff']}firefox --display=:0 ")
args << "\"" args << "\""
cmd = "su #{user} -c" cmd = "su #{user} -c"
elsif @platform =~ /win|osx/ elsif @platform =~ /windows|osx/
cmd = @paths['ff'] + "firefox" cmd = @paths['ff'] + "firefox"
# On OSX, run in background # On OSX, run in background
args << "& sleep 5 && killall firefox" if @platform =~ /osx/ args << "& sleep 5 && killall firefox" if @platform =~ /osx/

View File

@ -38,7 +38,7 @@ class MetasploitModule < Msf::Post
end end
def run def run
if session.platform =~ /win/ && session.type == "shell" # No Windows shell support if session.platform =~ /windows/ && session.type == "shell" # No Windows shell support
print_error "Shell sessions on Windows are not supported" print_error "Shell sessions on Windows are not supported"
return return
end end
@ -79,7 +79,7 @@ class MetasploitModule < Msf::Post
cookies_path_map = {} cookies_path_map = {}
case platform case platform
when /win/ when /windows/
browser_path_map = { browser_path_map = {
'Chrome' => "#{user_profile['LocalAppData']}\\Google\\Chrome\\User Data\\Default\\databases\\chrome-extension_hdokiejnpimakedhajhdlcegeplioahd_0", 'Chrome' => "#{user_profile['LocalAppData']}\\Google\\Chrome\\User Data\\Default\\databases\\chrome-extension_hdokiejnpimakedhajhdlcegeplioahd_0",
'Firefox' => "#{user_profile['AppData']}\\Mozilla\\Firefox\\Profiles", 'Firefox' => "#{user_profile['AppData']}\\Mozilla\\Firefox\\Profiles",
@ -194,7 +194,7 @@ class MetasploitModule < Msf::Post
"LocalAppData" => "/Users/#{user_name}/Library/Application Support" "LocalAppData" => "/Users/#{user_name}/Library/Application Support"
) )
end end
when /win/ when /windows/
user_profiles |= grab_user_profiles user_profiles |= grab_user_profiles
else else
print_error "OS not recognized: #{os}" print_error "OS not recognized: #{os}"
@ -807,6 +807,6 @@ class MetasploitModule < Msf::Post
# Returns OS separator in a session type agnostic way # Returns OS separator in a session type agnostic way
def system_separator def system_separator
return session.platform =~ /win/ ? '\\' : '/' return session.platform =~ /windows/ ? '\\' : '/'
end end
end end

View File

@ -32,7 +32,7 @@ class MetasploitModule < Msf::Post
case session.platform case session.platform
when /unix|linux|bsd|osx/ when /unix|linux|bsd|osx/
files = enum_user_directories.map {|d| d + "/.pgpass"}.select { |f| file?(f) } files = enum_user_directories.map {|d| d + "/.pgpass"}.select { |f| file?(f) }
when /win/ when /windows/
if session.type != "meterpreter" if session.type != "meterpreter"
print_error("Only meterpreter sessions are supported on windows hosts") print_error("Only meterpreter sessions are supported on windows hosts")
return return

View File

@ -44,8 +44,8 @@ class MetasploitModule < Msf::Post
when /osx/ when /osx/
@platform = :osx @platform = :osx
paths = enum_users_unix paths = enum_users_unix
when /win/ when /windows/
@platform = :win @platform = :windows
profiles = grab_user_profiles() profiles = grab_user_profiles()
profiles.each do |user| profiles.each do |user|
next if user['AppData'] == nil next if user['AppData'] == nil
@ -107,7 +107,7 @@ class MetasploitModule < Msf::Post
print_status("Checking for Pidgin profile in: #{purpledir}") print_status("Checking for Pidgin profile in: #{purpledir}")
session.fs.dir.foreach(purpledir) do |dir| session.fs.dir.foreach(purpledir) do |dir|
if dir =~ /\.purple/ if dir =~ /\.purple/
if @platform == :win if @platform == :windows
print_status("Found #{purpledir}\\#{dir}") print_status("Found #{purpledir}\\#{dir}")
path = "#{purpledir}\\#{dir}" path = "#{purpledir}\\#{dir}"
else else

View File

@ -42,7 +42,7 @@ class MetasploitModule < Msf::Post
end end
case session.platform case session.platform
when /win/i when /windows/i
count = " -n 1 " count = " -n 1 "
cmd = "ping" cmd = "ping"
when /solaris/i when /solaris/i

View File

@ -61,7 +61,7 @@ class MetasploitModule < Msf::Post
process_db(db_in_loot,p['name']) process_db(db_in_loot,p['name'])
end end
end end
elsif (session.platform =~ /win/ and session.type =~ /meter/) elsif (session.platform =~ /windows/ and session.type =~ /meter/)
# Iterate thru each user profile in a Windows System using Meterpreter Post API # Iterate thru each user profile in a Windows System using Meterpreter Post API
grab_user_profiles().each do |p| grab_user_profiles().each do |p|
if check_skype(p['AppData'],p['UserName']) if check_skype(p['AppData'],p['UserName'])

View File

@ -48,7 +48,7 @@ class MetasploitModule < Msf::Post
when /osx/ when /osx/
user = session.shell_command("whoami").chomp user = session.shell_command("whoami").chomp
base = "/Users/#{user}/Library/Thunderbird/Profiles/" base = "/Users/#{user}/Library/Thunderbird/Profiles/"
when /win/ when /windows/
if session.type =~ /meterpreter/ if session.type =~ /meterpreter/
user_profile = session.sys.config.getenv('APPDATA') user_profile = session.sys.config.getenv('APPDATA')
else else
@ -65,7 +65,7 @@ class MetasploitModule < Msf::Post
# Steal! # Steal!
profiles.each do |profile| profiles.each do |profile|
next if profile =~ /^\./ next if profile =~ /^\./
slash = (session.platform =~ /win/) ? "\\" : "/" slash = (session.platform =~ /windows/) ? "\\" : "/"
p = base + profile + slash p = base + profile + slash
# Download the database, and attempt to process the content # Download the database, and attempt to process the content
@ -98,7 +98,7 @@ class MetasploitModule < Msf::Post
f.close f.close
end end
elsif session.type =~ /shell/ elsif session.type =~ /shell/
cmd_show = (session.platform =~ /win/) ? 'type' : 'cat' cmd_show = (session.platform =~ /windows/) ? 'type' : 'cat'
# The type command will add a 0x0a character in the file? Pff. # The type command will add a 0x0a character in the file? Pff.
# Gotta lstrip that. # Gotta lstrip that.
loot = cmd_exec(cmd_show, "\"#{p+item}\"").lstrip loot = cmd_exec(cmd_show, "\"#{p+item}\"").lstrip
@ -210,11 +210,11 @@ class MetasploitModule < Msf::Post
tb_profiles << subdir tb_profiles << subdir
end end
else else
cmd = (session.platform =~ /win/) ? "dir \"#{path}\"" : "ls -ld #{path}*/" cmd = (session.platform =~ /windows/) ? "dir \"#{path}\"" : "ls -ld #{path}*/"
dir = cmd_exec(cmd) dir = cmd_exec(cmd)
dir.each_line do |line| dir.each_line do |line|
line = line.strip line = line.strip
next if session.platform =~ /win/ and line !~ /<DIR>((.+)\.(\w+)$)/ next if session.platform =~ /windows/ and line !~ /<DIR>((.+)\.(\w+)$)/
next if session.platform =~ /linux|osx/ and line !~ /(\w+\.\w+)/ next if session.platform =~ /linux|osx/ and line !~ /(\w+\.\w+)/
tb_profiles << $1 if not $1.nil? tb_profiles << $1 if not $1.nil?
end end

View File

@ -109,7 +109,7 @@ class MetasploitModule < Msf::Post
# Run Method for when run command is issued # Run Method for when run command is issued
def run def run
case session.platform case session.platform
when /win/i when /windows/i
listing = cmd_exec('netsh wlan show networks mode=bssid') listing = cmd_exec('netsh wlan show networks mode=bssid')
if listing.nil? if listing.nil?
print_error("Unable to generate wireless listing.") print_error("Unable to generate wireless listing.")

View File

@ -67,7 +67,7 @@ class MetasploitModule < Msf::Post
user_base = "/home/#{user}/" user_base = "/home/#{user}/"
end end
dbvis_file = "#{user_base}.dbvis/config70/dbvis.xml" dbvis_file = "#{user_base}.dbvis/config70/dbvis.xml"
when /win/ when /windows/
user_profile = session.sys.config.getenv('USERPROFILE') user_profile = session.sys.config.getenv('USERPROFILE')
dbvis_file = "#{user_profile}\\.dbvis\\config70\\dbvis.xml" dbvis_file = "#{user_profile}\\.dbvis\\config70\\dbvis.xml"
end end
@ -76,16 +76,18 @@ class MetasploitModule < Msf::Post
#File not found, we next try with the old config path #File not found, we next try with the old config path
print_status("File not found: #{dbvis_file}") print_status("File not found: #{dbvis_file}")
print_status("This could be an older version of dbvis, trying old path") print_status("This could be an older version of dbvis, trying old path")
case session.platform case session.platform
when /linux/ when /linux/
dbvis_file = "#{user_base}.dbvis/config/dbvis.xml" dbvis_file = "#{user_base}.dbvis/config/dbvis.xml"
when /win/ when /windows/
dbvis_file = "#{user_profile }\\.dbvis\\config\\dbvis.xml" dbvis_file = "#{user_profile }\\.dbvis\\config\\dbvis.xml"
end end
unless file?(dbvis_file) unless file?(dbvis_file)
print_error("File not found: #{dbvis_file}") print_error("File not found: #{dbvis_file}")
return return
end end
old_version = true old_version = true
end end
@ -162,7 +164,7 @@ class MetasploitModule < Msf::Post
else else
print_good("Dbviscmd found : #{dbvis}") print_good("Dbviscmd found : #{dbvis}")
end end
when /win/ when /windows/
# Find program files # Find program files
progfiles_env = session.sys.config.getenvs('ProgramFiles(X86)', 'ProgramFiles') progfiles_env = session.sys.config.getenvs('ProgramFiles(X86)', 'ProgramFiles')
progfiles_x86 = progfiles_env['ProgramFiles(X86)'] progfiles_x86 = progfiles_env['ProgramFiles(X86)']

View File

@ -56,13 +56,15 @@ class MetasploitModule < Msf::Post
when /linux/ when /linux/
user = session.shell_command("whoami") user = session.shell_command("whoami")
print_status("Current user is #{user}") print_status("Current user is #{user}")
if (user =~ /root/) if (user =~ /root/)
user_base = "/root/" user_base = "/root/"
else else
user_base = "/home/#{user}/" user_base = "/home/#{user}/"
end end
dbvis_file = "#{user_base}.dbvis/config70/dbvis.xml" dbvis_file = "#{user_base}.dbvis/config70/dbvis.xml"
when /win/ when /windows/
user_profile = session.sys.config.getenv('USERPROFILE') user_profile = session.sys.config.getenv('USERPROFILE')
dbvis_file = "#{user_profile}\\.dbvis\\config70\\dbvis.xml" dbvis_file = "#{user_profile}\\.dbvis\\config70\\dbvis.xml"
end end
@ -71,16 +73,19 @@ class MetasploitModule < Msf::Post
#File not found, we next try with the old config path #File not found, we next try with the old config path
print_status("File not found: #{dbvis_file}") print_status("File not found: #{dbvis_file}")
print_status("This could be an older version of dbvis, trying old path") print_status("This could be an older version of dbvis, trying old path")
case session.platform case session.platform
when /linux/ when /linux/
dbvis_file = "#{user_base}.dbvis/config/dbvis.xml" dbvis_file = "#{user_base}.dbvis/config/dbvis.xml"
when /win/ when /windows/
dbvis_file = "#{user_profile }\\.dbvis\\config\\dbvis.xml" dbvis_file = "#{user_profile }\\.dbvis\\config\\dbvis.xml"
end end
unless file?(dbvis_file) unless file?(dbvis_file)
print_error("File not found: #{dbvis_file}") print_error("File not found: #{dbvis_file}")
return return
end end
old_version = true old_version = true
end end
@ -150,7 +155,7 @@ class MetasploitModule < Msf::Post
else else
print_good("Dbviscmd found : #{dbvis}") print_good("Dbviscmd found : #{dbvis}")
end end
when /win/ when /windows/
# Find program files # Find program files
progfiles_env = session.sys.config.getenvs('ProgramFiles(X86)', 'ProgramFiles') progfiles_env = session.sys.config.getenvs('ProgramFiles(X86)', 'ProgramFiles')
progfiles_x86 = progfiles_env['ProgramFiles(X86)'] progfiles_x86 = progfiles_env['ProgramFiles(X86)']

View File

@ -111,7 +111,7 @@ class MetasploitModule < Msf::Post
case session.platform case session.platform
when /osx/ when /osx/
osx_start_video(id) osx_start_video(id)
when /win/ when /windows/
win_start_video(id) win_start_video(id)
when /linux/ when /linux/
linux_start_video(id) linux_start_video(id)

View File

@ -74,7 +74,7 @@ class MetasploitModule < Msf::Post
case session.platform case session.platform
when /osx/ when /osx/
osx_set_wallpaper(file) osx_set_wallpaper(file)
when /win/ when /windows/
win_set_wallpaper(file) win_set_wallpaper(file)
when /android/ when /android/
android_set_wallpaper(file) android_set_wallpaper(file)

View File

@ -80,8 +80,8 @@ class MetasploitModule < Msf::Post
# Handle platform specific variables and settings # Handle platform specific variables and settings
case session.platform case session.platform
when /win/i when /windows/i
platform = 'win' platform = 'windows'
payload_name = 'windows/meterpreter/reverse_tcp' payload_name = 'windows/meterpreter/reverse_tcp'
lplat = [Msf::Platform::Windows] lplat = [Msf::Platform::Windows]
larch = [ARCH_X86] larch = [ARCH_X86]
@ -139,7 +139,7 @@ class MetasploitModule < Msf::Post
end end
case platform case platform
when 'win' when 'windows'
if session.type == 'powershell' if session.type == 'powershell'
template_path = File.join(Msf::Config.data_directory, 'templates', 'scripts') template_path = File.join(Msf::Config.data_directory, 'templates', 'scripts')
psh_payload = case datastore['Powershell::method'] psh_payload = case datastore['Powershell::method']

View File

@ -92,7 +92,7 @@ class MetasploitModule < Msf::Post
# If we want WINAPI egress, make sure winsock is loaded # If we want WINAPI egress, make sure winsock is loaded
if type == 'WINAPI' if type == 'WINAPI'
unless client.railgun.ws2_32 && client.platform =~ /win/ unless client.railgun.ws2_32 && client.platform =~ /windows/
print_error("The WINAPI method requires Windows, railgun and support for winsock APIs. Try using the NATIVE method instead.") print_error("The WINAPI method requires Windows, railgun and support for winsock APIs. Try using the NATIVE method instead.")
return return
end end

View File

@ -153,8 +153,8 @@ class MetasploitModule < Msf::Post
#Make sure we are on a Windows host #Make sure we are on a Windows host
if client.platform !~ /win32|win64/ if client.platform !~ /windows/
print_status "This module does not support this meterpreter type" print_error('This module does not support this platform.')
return return
end end

View File

@ -33,7 +33,7 @@ class MetasploitModule < Msf::Post
end end
def unsupported def unsupported
print_error("This version of Meterpreter is not supported with this script!") print_error("This platform is not supported with this script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
@ -41,7 +41,7 @@ class MetasploitModule < Msf::Post
technique = datastore['TECHNIQUE'].to_i technique = datastore['TECHNIQUE'].to_i
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform !~ /windows/i
if is_system? if is_system?
print_good("This session already has SYSTEM privileges") print_good("This session already has SYSTEM privileges")

View File

@ -37,7 +37,7 @@ class MetasploitModule < Msf::Post
end end
def unsupported def unsupported
print_error("This version of Meterpreter is not supported with this Script!") print_error("This platform is not supported with this Script!")
raise Rex::Script::Completed raise Rex::Script::Completed
end end
@ -55,7 +55,7 @@ class MetasploitModule < Msf::Post
{ :sig => "8bff558bec83ec50a1", :sigoffset => 0x97d3, :orig_code => "32c0", :patch => "b001", :patchoffset => 0x9878, :os => /Windows XP.*Service Pack 3 - spanish/ } { :sig => "8bff558bec83ec50a1", :sigoffset => 0x97d3, :orig_code => "32c0", :patch => "b001", :patchoffset => 0x9878, :os => /Windows XP.*Service Pack 3 - spanish/ }
] ]
unsupported if client.platform !~ /win32|win64/i unsupported if client.platform !~ /windows/i
os = client.sys.config.sysinfo['OS'] os = client.sys.config.sysinfo['OS']
targets.each do |t| targets.each do |t|

View File

@ -54,8 +54,8 @@ class MetasploitModule < Msf::Post
screenshot = Msf::Config.get_config_root + "/logs/" + host + ".jpg" screenshot = Msf::Config.get_config_root + "/logs/" + host + ".jpg"
migrate_explorer migrate_explorer
if session.platform !~ /win32|win64/i if session.platform !~ /windows/i
print_error("Unsupported Platform") print_error('Unsupported Platform')
return return
end end