Message-ID: <4EZhAf$W1Y@bbs.whnet.edu.cn>
Subject: [zz]�����芽腔�yoda's cryptor1.2
Date: Mon, 11 Oct 2004 14:14:00 +0000
From: Unknown <anon@nohost.local>
Path: 74.82.202.154!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-cn.bbs.comp.hacker.mbox.zip!g2news1.google.com!news1.google.com!news.glorb.com!nntp-server.pubsub.com!maily.cic.tsinghua.edu.cn!whnet.dhs.org!WHNET
Newsgroups: cn.bbs.comp.hacker
Organization: �汉���苹坪�站
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: Encrypt/M.1097504009.A
Lines: 737
Xref: 74.82.202.154 cn.bbs.comp.hacker:902

�����芽腔�yoda's cryptor1.2

kongfoo/2004.5.2-5.15

����yoda's cryptor1.2没��OEP stolen code��Replace code��IAT���堋��侄渭���
��

�习�������没����原����压�������������芽腔����示��������恕�

����������要��一���芽腔�时����缘��羌涌�����原����募����法��知���思���
�法

�涂���直�佣��募����薪��芑�原�������话�����约涌������玫募����法强�群���
要��

��������yoda's cryptor�嵌�态��/���埽�����要����原�谴�����。

������������一�陆����法�������法���羌����法�����法��

010103CF    8BFE            MOV EDI,ESI                       ==�����丫�
去��指��

010103D1    AC              LODS BYTE PTR DS:[ESI]

010103D5    34 F2           XOR AL,0F2

010103DA    2AC1            SUB AL,CL

010103DF    2AC1            SUB AL,CL

010103E1    34 EB           XOR AL,0EB

010103EA    02C1            ADD AL,CL

010103F0    04 36           ADD AL,36

010103F2    FEC8            DEC AL

010103F8    2AC1            SUB AL,CL

010103FC    2AC1            SUB AL,CL

010103FE    C0C8 78         ROR AL,78                                

01010402    AA              STOS BYTE PTR ES:[EDI]

01010403  ^ E2 CC           LOOPD SHORT NOTEPAD2.010103D1

������未����歉��偌庸�堑某���玫��模���Loader���,��yoda's crytptor��L
oader也

���思��埽���么���强�������取����Loader�拇�����埽�����取����原����拇���
���小�

��������yoda's cryptor��源���知����/����时�����某些�凇�

�����芽墙���思路��取����(number of sections)����位�����冢���萁����卸���
����要

���埽����芙冢��倩指�peheader�械�一些值�����去�������拥慕凇�

����源�附��篇���系����没���荽?�?也没�写���CheckSum����目��������
�业�XP��

�涌�时选��Erase PE header��Delete Import Information��API Redirection��
�涌浅���

���������校����约涌�时只选������3�。������苑���只������notepad.exe��
�芽浅���

���?

����写����芽腔�芯�����原���虿⒉��眩������薷�peheader�械���目��������
址������

�潞芊�浅��旨����示��虻サ��芽腔�写������为����一��目��叶�写������������
���遣�要

��笑

  Code: [Copy to clipboard]   

      .486                      ; create 32 bit code

      .model flat, stdcall      ; 32 bit memory model

      option casemap :none      ; case sensitive

;=====include files

      include \masm32\include\windows.inc

      include \masm32\include\masm32.inc

      include \masm32\include\gdi32.inc

      include \masm32\include\user32.inc

      include \masm32\include\kernel32.inc

      include \masm32\include\Comctl32.inc

      include \masm32\include\comdlg32.inc

      include \masm32\include\shell32.inc

      include \masm32\include\oleaut32.inc

;=====libraries

      includelib \masm32\lib\masm32.lib

      includelib \masm32\lib\gdi32.lib

      includelib \masm32\lib\user32.lib

      includelib \masm32\lib\kernel32.lib

      includelib \masm32\lib\Comctl32.lib

      includelib \masm32\lib\comdlg32.lib

      includelib \masm32\lib\shell32.lib

      includelib \masm32\lib\oleaut32.lib

      FUNC MACRO parameters:VARARG

        invoke parameters

        EXITM <eax>

      ENDM

      include \masm32\include\dialogs.inc

      unyc PROTO :DWORD,:DWORD,:DWORD,:DWORD

    .data

        hInstance dd 0

        hFile     dd 0      

        dwFsize   dd 0

        pMem      dd 0

        OEP       dd 0

        EP        dd 0

        NOofSecs  dd 0     ;NumberOfSections

        FirstSec  dd 0     ;offset First Section

        pe_header dd 0

        Vir2Raw   dd 0

        IIDs      dd 0

        LastSecSize  dd 0

        dwBytesRead  dd 0

        LastSecRawSize dd 0

        szFname   db MAX_PATH dup (0) 

        ofn       OPENFILENAME <>        

    .const

        szFilter  db "*.exe",0,"*.exe",0

        szCurDir  db ".",0

        msgSucc   db "Decrypt success.",0

        msgInfo   db "Info...",0

    .code

;==============================================

start:

      mov hInstance, FUNC(GetModuleHandle,NULL)

      call main

      invoke ExitProcess,eax

;=============================================

main proc

    Dialog "Decryptor for yc1.2 - DEMO /user4.2004515", \           ; ca
ption

           "MS Sans Serif",10, \            ; font,pointsize

            WS_OVERLAPPED or \              ; styles for

            WS_SYSMENU or DS_CENTER, \      ; dialog window

            5, \                            ; number of controls

            50,50,200,80, \                 ; x y co-ordinates

            1024                            ; memory buffer size

    DlgButton "Quit",WS_TABSTOP,138,40,50,15,IDCANCEL

    ;                             x,y,width,height

    DlgButton "decrypt",WS_TABSTOP,18,40,50,15,IDOK

    DlgButton "open",WS_TABSTOP,168,8,20,10,IDYES

    DlgEdit WS_TABSTOP,18,20,170,8,10000

    DlgStatic "Choose File:",SS_LEFT,18,8,70,9,100

    CallModalDialog hInstance,0,unyc,NULL

    ret

main endp

;=============================================

unyc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

  .if uMsg == WM_INITDIALOG

    invoke SendMessage,hWin,WM_SETICON,1,FUNC(LoadIcon,NULL,IDI_ASTERISK
)

  .elseif uMsg == WM_COMMAND

    .if wParam == IDCANCEL

      jmp quit_dialog

    .elseif wParam == IDOK

       ;=========decryption beginning===========================

       invoke CreateFile,offset szFname,GENERIC_WRITE + GENERIC_READ,FIL
E_SHARE_WRITE + FILE_SHARE_READ,\

                      NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0

       mov hFile, eax

       invoke GetFileSize,hFile,0

       mov dwFsize,eax

       invoke GlobalAlloc,GPTR,dwFsize

       mov pMem,eax

       invoke ReadFile,hFile,pMem,dwFsize,offset dwBytesRead,NULL ;���募�
���诖��涂��������艽����恕�

        mov eax,pMem

        ;==��一����取��Loader�慕�����并�����Loader

        mov ebx,[eax+3ch] ;取pe_header偏��

        add ebx,pMem      ;ebx��位��pe_header

        mov pe_header,ebx

        xor eax,eax

        mov ax,word ptr [ebx+14h] ;e+14:SizeOfOptionalHeader

        add eax,18h

        add eax,ebx       ;eax��位����一���诒�

        mov FirstSec,eax

        xor ecx,ecx

        mov cx,word ptr [ebx+6]   ;e+6:NmberOfSections

        dec ecx

        mov NOofSecs,ecx

        push eax

        mov eax,40       ;每���诒�40�纸诔�

        mul ecx

        mov ecx,eax

        pop eax

        add eax,ecx      ;��位�����一���诒?�����拥慕诒�

        mov ebx,[eax+20] ;取������位��

        mov ecx,[eax+08h]

        mov LastSecSize,ecx    ;取�������小������要��

        mov ecx,[eax+10h]

        mov LastSecRawSize,ecx ;取�������小��������

        add ebx,pMem     ;��位�����一�诩������拥慕�

        add ebx,60h      ;��位�������

        mov EP,ebx

        jmp OverDecryptCode

      DecryptCode:

        CodesFromShell db 40h dup(90h) ;�����糯涌前�����慕������

      OverDecryptCode:

        mov ecx,7

      MakeMBI:

        push 0

        dec ecx

        jnz MakeMBI

        mov edi,esp

        invoke VirtualQuery,offset DecryptCode,edi,28

        invoke VirtualProtect,offset DecryptCode,1024,PAGE_READWRITE,edi


        add esp,28

        mov edx,EP

        mov esi,edx

        add edx,14

        push [edx]   ;Loader�拇�小�������霉潭�值97b

        mov edx,esi

        add edx,4eh  ;要���艿拇���目�始��址,���艽���潭���30h�纸冢��偌�
��������长��

        lea edi,DecryptCode

        add esi,1ah  ;��位�����艽���

        mov ecx,34h

        rep movsb byte ptr [edi],byte ptr [esi]  ;�����艽��复�乒���

        mov byte ptr [edi],0c3h

        pop ecx

        mov esi,edx

        mov edi,esi

        call DecryptCode  ;执��Loader����慕���

        ;==�诙�������Loader��取����原����拇��并����原����

        mov edx,EP        

        add edx,371h      ;��位������原����拇���,��������芽腔������1.
2��模������霉潭�值也�薹�

        mov ecx,34h

        lea edi,DecryptCode

        mov esi,edx

        rep movsb byte ptr [edi],byte ptr [esi]  ;����

        push NOofSecs     ;��������丫���1���������堑�一����

        mov eax,FirstSec

      DecryptSecs:

        cmp dword ptr [eax],63727372h  ;���������为rsrc�慕�

        je SkipDecryptSec

        cmp dword ptr [eax],7273722eh  ;.rsr

        je SkipDecryptSec

        cmp dword ptr [eax],6f6c6572h  ;relo

        je SkipDecryptSec

        cmp dword ptr [eax],6c65722eh  ;.rel

        je SkipDecryptSec

        cmp dword ptr [eax],6164652eh  ;.eda

        je SkipDecryptSec

        cmp dword ptr [eax+14h],0      ;������指����效������位�玫慕�

        je SkipDecryptSec

        cmp dword ptr [eax+10h],0      ;�����������小为0�慕�

        je SkipDecryptSec

        push eax

        mov ecx,[eax+10h]  ;�诖�小

        mov edi,[eax+14h]  ;��位��

        add edi,pMem

        mov esi,edi

        call DecryptCode

        pop eax

      SkipDecryptSec:

        add eax,28h        ;指����一���诒�

        dec dword ptr [esp]

        jne DecryptSecs

        add esp,4          ;push NOofSecs

        ;==����指�peheader�械���荩�����������冢�������址�������


        mov eax,EP

        mov eax,[eax+77bh]   ;�前�OEP�����诠潭�位��

        mov ebx,pe_header

        mov dword ptr [ebx+28h],eax  ;�指�OEP

        

        mov eax,FirstSec

        add eax,28h       ;指��诙����冢���址���诘诙�����

        push [eax+14h]    ;��Raw Offset

        mov eax,[eax+0ch] ;��Virtual Offset

        sub eax,[esp]

        mov dword ptr [esp],eax

        mov eax,EP

        add eax,78fh

        mov IIDs,eax

        mov ebx,[eax]    ;�����址�������执���址���校����������涂����业�
�����

        sub ebx,[esp]

        add ebx,pMem

        mov eax,FirstSec

        mov ecx,[eax+14h]  ;Raw Offset

        add ecx,[eax+10h]  ;Raw Size

        add ecx,pMem

        cmp ebx,ecx        ;��址���欠��诘�一�冢��牵��玫�一�诘�VO-RO����
�玫诙��诘�VO-RO

        ja FindImp1

        add esp,4

        push [eax+14h]    ;��Raw Offset

        mov eax,[eax+0ch] ;��Virtual Offset

        sub eax,[esp]

        mov dword ptr [esp],eax

      FindImp1:

        dec ebx

        cmp dword ptr [ebx],0

        je FoundImp1

        jmp FindImp1

      FoundImp1:

        cmp dword ptr [ebx-4],0

        jne FindImp1

        sub ebx,14h

        mov ecx,[ebx]

      FindImp2:

        cmp dword ptr [ebx-4],ecx

        jne FoundImp2

        sub ebx,4

        jmp FindImp2

      FoundImp2:

        mov edx,ebx

        sub edx,pMem

        add edx,[esp]

        mov eax,pe_header

        mov dword ptr [eax+80h],edx  ;�指�������址

        mov eax,ebx                  ;指��原����������

        mov edx,IIDs                 ;指���摘取��原�������������

      RestoreImport:         ;�指���������

        cmp dword ptr [edx],0

        je RestoreImportOK

        mov ecx,[edx+8]

        mov dword ptr [eax],ecx

        mov ecx,-1

        mov dword ptr [eax+4],ecx

        mov dword ptr [eax+8],ecx

        mov ecx,[edx]

        mov dword ptr [eax+0ch],ecx

        mov ecx,[edx+4]

        mov dword ptr [eax+10h],ecx

        add edx,0ch

        add eax,14h

        jmp RestoreImport

      RestoreImportOK:

        add esp,4

        add eax,16

      FindStrings:  

        add eax,4

        cmp dword ptr [eax],0

        jne FindStrings

        cmp byte ptr [eax+5],0

        jne FindStrings

        add eax,5

        mov ebx,eax

      DecryptStrings:   ;�指������艿�API�执�

        inc ebx

        mov esi,ebx

        mov edi,ebx

        lods byte ptr [esi]

        ror al,4

        stos byte ptr [edi]

        cmp dword ptr [ebx],0

        je CheckEnd1

        jmp DecryptStrings

      CheckEnd1:

        cmp dword ptr [ebx+4],0

        jne DecryptStrings

        mov eax,pe_header

        mov ecx,NOofSecs

        mov word ptr [eax+6],cx      ;�指�����

        mov ebx,[eax+50h]        ;SizeOfImage

        sub ebx,LastSecSize      ;��去�墙诖�小

        mov dword ptr [eax+50h],ebx  ;�指�影���小

        mov eax,dwFsize

        sub eax,LastSecRawSize

        mov dwFsize,eax          ;�����募���小

                

        ;==���牟���写��原�募�������yoda's cryptor��源�即��

        invoke SetFilePointer,hFile,0,NULL,FILE_BEGIN

        invoke WriteFile,hFile,pMem,dwFsize,offset dwBytesRead,NULL

        invoke SetFilePointer,hFile,dwFsize,NULL,FILE_BEGIN

        invoke SetEndOfFile,hFile

        

        invoke CloseHandle,hFile

        invoke GlobalFree,pMem

        invoke MessageBox,hWin,offset msgSucc,offset msgInfo,0

     .elseif wParam == IDYES  ;���募�������yoda's cryptor��源��

        mov ofn.lStructSize,SIZEOF ofn 

        mov ofn.lpstrFilter,offset szFilter

        push hWin

        pop ofn.hwndOwner

        mov ofn.lpstrFile, offset szFname 

        mov ofn.nMaxFile,SIZEOF szFname

        mov ofn.lpstrInitialDir,offset szCurDir

        mov ofn.Flags, OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST or OFN_LON
GNAMES or OFN_HIDEREADONLY

        push offset ofn

        call GetOpenFileName

        test eax,eax

        jz @@ExitDlgProc

        invoke SetDlgItemText,hWin,10000,offset szFname  

      @@ExitDlgProc:

     .endif

  .elseif uMsg == WM_CLOSE

    quit_dialog:

    invoke EndDialog,hWin,0

  .endif

  xor eax, eax

  ret

unyc endp

end start 

 


--
一�������频�说����TMD���冶�MM���耍��� 
��一��说������������玫��耍��冶��艿�时����MM�慕����嵌���说�摹��� 
�员叩母���说�������������耍��冶��艿���息��通��女�����掖����������遥������腋���
�����业摹��� 
���一��说�������蓿��冶��艿���息��������学校BBS�摹�����十���看���模����� 
�� ��源:���汉���苹坪�站 bbs.whnet.edu.cn��[FROM:木讷*诗--��]