Remove unnecessary calls to expand path
When using the Meterpreter Binaries gem to locate the path to the meterpreter DLLs, it's not necessary to use File.expand_path on the result because the gem's code does this already. This commit simple removes those unnecessary calls.bug/bundler_fix
parent
ff43fbd8de
commit
17ff546b0f
|
@ -159,15 +159,13 @@ class ClientCore < Extension
|
||||||
path = MeterpreterBinaries.path(modname, client.binary_suffix)
|
path = MeterpreterBinaries.path(modname, client.binary_suffix)
|
||||||
|
|
||||||
if opts['ExtensionPath']
|
if opts['ExtensionPath']
|
||||||
path = opts['ExtensionPath']
|
path = ::File.expand_path(opts['ExtensionPath'])
|
||||||
end
|
end
|
||||||
|
|
||||||
if path.nil?
|
if path.nil?
|
||||||
raise RuntimeError, "No module of the name #{modname}.#{client.binary_suffix} found", caller
|
raise RuntimeError, "No module of the name #{modname}.#{client.binary_suffix} found", caller
|
||||||
end
|
end
|
||||||
|
|
||||||
path = ::File.expand_path(path)
|
|
||||||
|
|
||||||
# Load the extension DLL
|
# Load the extension DLL
|
||||||
commands = load_library(
|
commands = load_library(
|
||||||
'LibraryFilePath' => path,
|
'LibraryFilePath' => path,
|
||||||
|
|
|
@ -50,8 +50,6 @@ class Priv < Extension
|
||||||
raise RuntimeError, "elevator.#{binary_suffix} not found", caller
|
raise RuntimeError, "elevator.#{binary_suffix} not found", caller
|
||||||
end
|
end
|
||||||
|
|
||||||
elevator_path = ::File.expand_path( elevator_path )
|
|
||||||
|
|
||||||
elevator_data = ""
|
elevator_data = ""
|
||||||
|
|
||||||
::File.open( elevator_path, "rb" ) { |f|
|
::File.open( elevator_path, "rb" ) { |f|
|
||||||
|
|
|
@ -154,37 +154,43 @@ class UI < Rex::Post::UI
|
||||||
def screenshot( quality=50 )
|
def screenshot( quality=50 )
|
||||||
request = Packet.create_request( 'stdapi_ui_desktop_screenshot' )
|
request = Packet.create_request( 'stdapi_ui_desktop_screenshot' )
|
||||||
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_QUALITY, quality )
|
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_QUALITY, quality )
|
||||||
|
|
||||||
# include the x64 screenshot dll if the host OS is x64
|
# include the x64 screenshot dll if the host OS is x64
|
||||||
if( client.sys.config.sysinfo['Architecture'] =~ /^\S*x64\S*/ )
|
if( client.sys.config.sysinfo['Architecture'] =~ /^\S*x64\S*/ )
|
||||||
screenshot_path = MeterpreterBinaries.path('screenshot','x64.dll')
|
screenshot_path = MeterpreterBinaries.path('screenshot','x64.dll')
|
||||||
if screenshot_path.nil?
|
if screenshot_path.nil?
|
||||||
raise RuntimeError, "screenshot.x64.dll not found", caller
|
raise RuntimeError, "screenshot.x64.dll not found", caller
|
||||||
end
|
end
|
||||||
screenshot_path = ::File.expand_path( screenshot_path )
|
|
||||||
screenshot_dll = ''
|
screenshot_dll = ''
|
||||||
::File.open( screenshot_path, 'rb' ) do |f|
|
::File.open( screenshot_path, 'rb' ) do |f|
|
||||||
screenshot_dll += f.read( f.stat.size )
|
screenshot_dll += f.read( f.stat.size )
|
||||||
end
|
end
|
||||||
|
|
||||||
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_BUFFER, screenshot_dll, false, true )
|
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_BUFFER, screenshot_dll, false, true )
|
||||||
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_LENGTH, screenshot_dll.length )
|
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_LENGTH, screenshot_dll.length )
|
||||||
end
|
end
|
||||||
|
|
||||||
# but always include the x86 screenshot dll as we can use it for wow64 processes if we are on x64
|
# but always include the x86 screenshot dll as we can use it for wow64 processes if we are on x64
|
||||||
screenshot_path = MeterpreterBinaries.path('screenshot','x86.dll')
|
screenshot_path = MeterpreterBinaries.path('screenshot','x86.dll')
|
||||||
if screenshot_path.nil?
|
if screenshot_path.nil?
|
||||||
raise RuntimeError, "screenshot.x86.dll not found", caller
|
raise RuntimeError, "screenshot.x86.dll not found", caller
|
||||||
end
|
end
|
||||||
screenshot_path = ::File.expand_path( screenshot_path )
|
|
||||||
screenshot_dll = ''
|
screenshot_dll = ''
|
||||||
::File.open( screenshot_path, 'rb' ) do |f|
|
::File.open( screenshot_path, 'rb' ) do |f|
|
||||||
screenshot_dll += f.read( f.stat.size )
|
screenshot_dll += f.read( f.stat.size )
|
||||||
end
|
end
|
||||||
|
|
||||||
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_BUFFER, screenshot_dll, false, true )
|
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_BUFFER, screenshot_dll, false, true )
|
||||||
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_LENGTH, screenshot_dll.length )
|
request.add_tlv( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_LENGTH, screenshot_dll.length )
|
||||||
|
|
||||||
# send the request and return the jpeg image if successfull.
|
# send the request and return the jpeg image if successfull.
|
||||||
response = client.send_request( request )
|
response = client.send_request( request )
|
||||||
if( response.result == 0 )
|
if( response.result == 0 )
|
||||||
return response.get_tlv_value( TLV_TYPE_DESKTOP_SCREENSHOT )
|
return response.get_tlv_value( TLV_TYPE_DESKTOP_SCREENSHOT )
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue