Virus "Add-Ons" Tutorial
by Opic [Codebreakers,1998]

"Virus Add-Ons" Tutorial revision by GeneCode


Let me first say that this tutorial is directed at the newbie, and not for experienced coders. That being said this tutorial is to aid you in coding the "features" of your virus. Which, when you think about it, is pretty fucking important! (please note that I will not be dealing with encryption or the main virus body as Sea4 and Horny Toad have already covered these)It is one of the only things that makes your virus unique. So throughout this tutorial remember that you should not be cutting and pasting code here, I want you to take the example I give you and expand upon them, make them better or code them in a new way; in other words make it interesting and be creative (why else might you code virii anyways?). The article is divided into two sections: the first will be on techniques that are utilitary in nature (they will add features to how the virus functions), the second will be on payload and payload activation ideas and techniques.

SECTION 1.

CHANGING DIRECTORYS

Ok, the first technique I will show you is the simple DotDot method of changing directories. This allows your runtime infecting virus to infect from its starting directory all the way up to root infecting each directory and its first subdirectory. We plug this into our virus by modifying our find-first routine to jump to our DotDot routine, I'll include the minor change in code so that it is blindingly clear to you what I mean. Here is the the DotDot routine with our slightly modified find first:

understand? hopefully you do :) basically instead of exiting after infecting just one dir we change to the next one infect it and its first subdir and so on until we hit root, then exit. Likewise we can use 3Bh to infect (or do anything we like to) a certain directory or subdirectory. I'm sure you can all think of a directory alot of people have and you would like to infect :) Well if you cant then don't worry, I've got your back covered on this one: how 'bout Windows\Command? here's an example of how to change directories to a specific directory:

No big change right? Good! Enough said, you can use the DotDot routine in combination with infecting specific directories which are likely to be present on most systems to get a wider infection rate. Also consider other directories which you may want to "modify" (such as your favorite AV scanner etc.).

SIMPLE ANTI-HEURISTICS LOOP

The next technique I'd like to show you is a simple loop to kill some heuristic scanners. This can be effective when paired with encryption, but doesn't perform well as a single measure against AV scanners.This one should be pretty self explanatory so I wont say much about it other then you should place it at the beginning of your virus ;)

Not much else I can say about this one except credits go to spo0ky for resurrecting this old technique and giving it a makeover ;)

RESTORING TIME/DATE STAMPS

Want to make your virus a little less noticeable? It looks awfully strange when all the infected files have the same time/date stamp doesnt it? Well its a very simple procedure to save the time/date stamps and restore them after infecting the file. Heres how simple it really is:

Get Time/Date stamps:

This should be done after you open the file but BEFORE you infect or modify the file in any way.

Restore Time/Date stamps:

This should be done right before you close the file.

CONTROLING RATE OF INFECTION

Too much of a good thing can be bad right? Same goes for infecting files, we want to infect as many of them as we can but we may not want to do it all at one time as it may appear suspicious to the user that all his files have suddenly grown by however many bytes your virus is. So lets take our time and infect only so many files per run, the way we do this is via a infection counter. The counter is a pretty versatile thing, we can use it for whatever we want (example: we could also use it as a payload activation; payload activates ever 15 runs or whatever) just use your imagination. At any rate we will use it as a counter in this example which infects 10 files per run.

The counter portion of the example should be placed at the end of your infection routine, after you close the infected file. The "Clear" routine should lie somewhere outside of the exit code so it is not executed when it shouldn't be.

CHECKING VICTUM FILE SIZE

Heres one of many ways you can check the victims filesize to see if it should be infected. files that are too large should not be infected as they will corrupt due to the change in size your virus makes(an good example is command.com which is not a "real" .com per say and can corrupt if more bytes are added) Files too small should be avoided due to obvious reasons. This code would be placed somewhere after we open the file and get file info. In this example we are checking to see if the file is bigger the 4000 bytes or smaller then 40 (purely random numbers to illustrate the method, I dont recommend you use these particular figures for your standard size check ;)

SECTION 2.

PAYLOADS AND PAYLOAD CRITERIA

This is the portion of your virus in which you should make it as unique and interesting as possible. Not only to hone your creative mentality but also to make your virus noticed After all there are thousands of virii out there and the majority of them dont do ANYTHING interesting! And as a consequence they are thrown into AV programs as Virus.874 (if they even make it into a scanners library) simply because your virus did not have many unique aspects which makes it interesting for the AV researcher to investigate.So make it interesting and challenging and meanwhile you will be making a name for yourself :) And remember that this is the only part of your virus that the viewing audience will actually be able to see and possibly even appreciate (or despise).

As for my opinion on destructive payloads;

I am not in favor of them, so if you want to learn how to format a disk then go look for another tutorial. Destructive payloads have for starters been done to death! Peoples hard drives have been fucked up by virii in just about every way imaginable and its not all that impressive, and its VERY easy to code(it takes 5 lines of code to format a disk)and thus shows little ability on your part. But if you are dead set on making a destructive payload I urge you to make it something which will alter the system without destroying personal data, and one that is easily fixed (such as hindering windows by removing the Windows\System dir which kills windows but can be fixed by replacing the dir from the users Windows CD or whatever). OK, enough about that.

Payload Criteria

There is an infinite number of activation routines. I obviously won't cover them all but will show you a few common ones which you can incorporate and adjust in your virii.

Date activation:

This is a very common way that virii activate. Heres how it breaks down: we check the system date with int 21/2a, our returns we will want to compare with are as follows:

simple huh? Ill provide a few examples to be sure you understand.

Want to activate your virus only on Mondays?

Want your payload active on the 15th of every month?

Ok, but what about seconds and minutes you say? easy enough, Lets say you wanted your payload to go off at 30 minutes when the seconds are less then 40:

Alright, thats enough about time/date activation. Another common payload activation routine is based upon infection count ie: the payload is activated every certain number of infections. This is quite easily done via another counter (please see CONTROLING RATE OF INFECTION for code).

You can also mix these two method for a more random payload activation, such as after 15 files have been infected checking if the seconds are less then 20 to activate your payload, giving your payload a seemingly random occurence rate. Play with these techniques and explore new ones of your own.

Payloads:

Im obviously not going to show you full payloads to incorporate into your virii but rather I will give you useful ideas and techniques for you to incorporate into your payloads. Remember this is your window of opportunity to do or say anything you want to the people who experience your virus, so I urge you to make it good! please dont write some lame payload that makes virii writers look like children writing with crayons on the wall ;) Be poetic or artistic or political, or anything besides then lame, childish and egotistical. And remember the more impressive and interesting your payloads are, the more your virus will be noticed.

Displaying a message to the screen:

This is a pretty basic thing you should know.

How about printing something out of the printer?

Graphics:

O.K, let me start by saying that programming graphics in ASM is pretty goddamn difficult in my opinion. And Im NOT going to show you how to do alot with graphics right now (this is a virus tut not a graphics one right?) But I will show you some code to give you an idea of how graphics in ASM work. Heres a bit of code that will create a blue pixel in the center of your screen.

Remember this is just the tip of the iceberg, creating good graphics in ASM shows a tremendous amount of skill and patience, and is sure to dazzle your audience :)

Heres a few other neat little things you could do if you wanted to be a bit more subtle.

Changing the date:

Create a new subdirectory:

I think this one is kind of fun, just create a new subdirectory which you could place on the desktop :)

This should get you well on your way to writing more sophisticated and interesting virii. Take the time and energy to make interesting code and you will enjoy yourself that much more. Take the time to learn how to write songs and graphics in asm if you are so inclined, they are challenging and will improve your coding abilities. You could consider your virii "living works of art" dont cheat them by writing a great virus with a half-assed payload or visa versa. And above all enjoy whatever it is you create. That's all for now.

- Opic [Codebreakers,98]
email: opic@thepentagon.com