Move xdg_open to multi module

GSoC/Meterpreter_Web_Console
Eliott Teissonniere 2018-06-18 06:54:13 +00:00
parent c4af2aca53
commit 8342751b05
2 changed files with 73 additions and 33 deletions

View File

@ -1,33 +0,0 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Post
include Msf::Post::Linux::System
def initialize(info={})
super( update_info( info,
'Name' => 'Linux Admin XDG open',
'Description' => %q{
This module will open any local resource in the target system via the 'xdg-open' command.
},
'License' => MSF_LICENSE,
'Author' => ['DeveloppSoft'],
'Platform' => ['linux'],
'SessionTypes' => ['shell', 'meterpreter']
))
register_options([
OptString.new('RES', [true, 'Resource to open, URL or file.'])
])
end
def run
unless command_exists? 'xdg-open'
print_error 'xdg-open is not available'
return
end
cmd_exec("xdg-open #{datastore['RES']} > /dev/null")
end
end

View File

@ -0,0 +1,73 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Post
include Msf::Post::File
def initialize(info={})
super( update_info( info,
'Name' => 'Open a file or URL on the target computer',
'Description' => %q{
This module will open any file or URL specified with the URI format on the
target computer via the embedded commands such as 'open' or 'xdg-open'.
},
'License' => MSF_LICENSE,
'Author' => [ 'Eliott Teissonniere'],
'Platform' => [ 'osx', 'linux' ],
'SessionTypes' => [ 'shell', 'meterpreter' ]
))
register_options(
[
OptString.new('URI', [true, 'URI path to open'])
])
end
#
# The OSX version simply uses 'open'
#
def osx_open(uri)
begin
cmd_exec("open #{uri}")
rescue EOFError
return false
end
true
end
#
# The Linux version relies on 'xdg-open'
#
def linux_open(uri)
begin
cmd_exec("xdg-open #{uri}")
rescue EOFError
return false
end
true
end
def open(uri)
case session.platform
when 'osx'
return osx_open(uri)
when 'linux'
return linux_open(uri)
end
end
def run
uri = datastore['URI']
print_status("Opening #{uri}")
if open(uri)
print_good('Success')
else
print_error('Command failed')
end
end
end