I Guess so, I will there's still more seats up front if anybody wants to grab them rather than stand in the back or anything Oh Is this a good mic placement and everything I just tossed it on myself excellent All right, so I my name is Sean O'Toole and I'm going to be speaking to you about metamorphic viruses And I wanted to stress that I know this whole conference is educational purposes only but I must stress that this one is definitely because I Don't want to see anybody's grandmother not be able to access their email or something because I gave a speech You know you you guys are the computer guys of the your families, so you know if they have a problem You're gonna hear about it And so yeah, I mean my speech on that morphic viruses I'm going to start off with the eye going through like Some pseudo code on how the various modules work and then after that I'll talk about like some of the AV approaches to it and also why I'm the CD I wanted to mention I that I did have some misspellings, but you know It's a late-night presentation that I was putting together after a friend's birthday, so you know what happens So as we go on I just wanted to give you a couple of the definitions one from Peter's or who say I well-known Antivirus person down to like your virus people and it goes from body polymorphics where they swear they've always been around in simpler techniques down to the artist's extreme mutation, so We got that going now I'm going to give a brief description of all the various sections or the main sections that you'll see or are theorized the first one is the disassembler which I mainly usually Has some way of putting something into a structure Something a lot of reverse engineering tools and whatnot then the second is the deep her mutator which I Takes the code that's been shuffled and connected by jumps and puts it straight down to the straightest code eyes that the algorithm can put it back together with and I also the shrinker which takes op codes and I recombine or clusters of opcode and recombines them say like If you have a push ebx pop ecx it becomes a move ecx comma ebx type of thing so These two first or two and three are mainly the ones that get you back down to the skeleton of your virus That it can be expanded on later with it these ones the expanders I which will do the exactly the reverse of the shrinker and The permutator which shuffles the code links it with jumps and so forth and also we get down to the Reassembler the reassembler assembler which I places the virus back together fixes jumps and so forth and These six are the main ones that you'll see are here theorized like a shrinker is very rare Expander permutator those are ones are more used And here's just one that I want to go over really quick is when you're programming these viruses or looking at them You got to think in a I very software engineering type of Thinking towards it because you know you want to think in modules everything separate We just pass this information to this one, so you don't end up getting into this huge project that never finishes So we get down to the disassembler we have two choices one is I one day I haven't really passed across was heavily theorized to make a pseudo language so that you can change like Say if you want to go from elf to I x86 you can change? a few things in there through your pseudo language before you put it back down into The I assembly language and also we have reverse engineering tools Which I the zombie art is the main person that puts those together? The LD was an earlier version of the ade which has a linked list of structures and the structure is I? Actually inside with that module when you get it so you can look at kind of like the manual and that will tell you Basically, what's where you got to deal? With after you run it oh And also that one of the things about the disassembler is also that it's not always able to reverse engineer all Files it just has some so there's it's cuts out some of the selection project process and here's one from I the mental drills article practice on metamorphism that's a Little example of how you can put together your pseudo I language one is that you could I Will you have the opcode the instructions tell you of course which registers and whatnot? Lm which is label marker which tells you later if there's a label that points to that that may be jumped to and this is Very important for shrinkers and so forth because if you shrink an extraction instruction, and there's a label in between that cluster Then you've just basically screwed up the whole thing that is jumping to because you've added too much code into one area also so We have like the idea of how to deal with the opcode you can say that Move is to 40 if you're doing memory to register It's plus 2 so move high memory to register would become 42 and there's also a full list of I The idea of points to op codes like this in the same article So now we get down to the D permutator because I the other choice for the assembler can or disassembler can be found to I in its manual pages and the D Permutator as I said earlier just Deshuffles the code if you will and this can be put in I its own module or can be included in the disassembly process depending on which way you'd like to go and Here's like the pseudo code at the beginning you got the variables like You start out with the entry point? Of the eye which you're disassembling or D permutating You have a path marker which is your buffer for after your D permutating code a label which is 2d words one is the eye Old address of the code and one's the new address of the code which later on some of these won't have an old address Which will I see in this is very important for jump fixing? Later on as well as other things and they future jump label table which has labels that you don't want to deal with yet through the algorithm And you'll of course zero out the path markers, so you don't end up hitting it random my eye Op codes that are just somewhere something that wasn't that buffer so that you think that this could be a portion of what you're D permutating and I you translate the I current I instruction pointer into the ESI and Then I here's what you do for a jump if you have a jump? And you've already D permutated it of course you just jump it back to that and that's that's one of the things about this algorithm That makes you know that you cannot have the same D permutated that virus every time you may have a I jump from a couple generations back that the algorithm never really took out and then if you I have not D permutated yet you put in a no op unless it's just in case if it's being pointed to and then you just go on from where the jump leads you and Then you have the conditional jumps which I a lot of times They're just kept in there, and I they're putting the future label table and whatnot you can see everything here Call same as I conditional jumps returns just goes to the future label table So you move by one I branch up the or one leaf up the code tree and get back to it and Then here's a little Note I wanted to make sure that I we had on there Which is when getting a new EIP from the future label table we check if the labels stored here are already been D Permutated if they are then it we insert the corresponding labels at the at the label table and eliminate the entry and future label tables if not we get the I newly IP continue And also I just had like a little note here for if you're making it stand alone What not you're gonna have to do a lot more I list things if you're doing it stand alone because in two buffers? So that's one of the reasons. It's usually in the disassembler. It will take up less room and here's a little example here, and we see that I accept the triple X's are the I code they meet is meaningful and So the y codes are the ones that are unreachable so this is another thing that your deep permutator will help you do it It'll allow you to put in Worthless code that will never be reached so that it's just in there makes it look different We see this before beforehand. We got the conditional jump. We got some of the other jumps After it runs we got this no more at the wise to our useless instructions once you hit a jump links you straight to the where it that code was goes through there until You've hit it all and that's it's there and then we get to the shrinker which is I extremely rare to find and will reappear in our AV section and This is basically the like I saying the inverse of the expander and It's most I haven't run upon it, so that's why it's not and I I don't have any examples of it anywhere and so We have the pseudo code for that right here Which we can see is basically looking through and seeing if we can find code clusters and switches? you know back to their I most simple ones, which I I do it as if there's a list of five These conversions, but many times. It's just a whole function that just does one thing Then we get to the expander which I is the inverse of the shrinker, okay, and I basically That's usually a standalone thing and usually also those don't use a list Or anything to see what the conversions are mainly. They're just functions are already written out like the when 9x Ramones virus will have some of these I'd so that you can I take a reference point to see how they're done and Here's the pseudo code for that we have five is expandable I forgot to switch it to actual number rather than a boolean, but basically I that the expandable question is How many times can we or how can we expand it three op codes two op codes or just switch op codes and? It goes through and it says okay if we got this random number, and we got this we're going to do it and that's basically that pseudo code, and that's just by telling you about how you can make a Expandable or is expandable type of thing it shows zero There's no high way to expand it seven you expand it all three different ways and up and down the line with the various combinations That's on the same thing So we get to the I permutator which you can see in I the ghost virus C perm as well as in a lot of other zombie viruses and Here's the pseudo code for that which basically Goes through like well this one's when it's actually kind of shuffling beforehand So it just puts the code groups together puts a jump in after that code group and then we come into this one which goes to the jump and Inserts the proper address to jump to the next code group in this sequence oh I also forgot to mention I changed my presentation a little bit, so it's I different from the one on the CD but I If yeah, it's just so if you're following along on a computer just so you don't get lost I've made a lot of changes I In the assembler section the main thing that you have to worry about rather than the whole Like converting all the stuff is the main thing is to do jump relocation fixes Which so I your old sit pointer or your old jump will go to the proper jump once it's reassembled in the new I? new program And here we I usually initialize a couple tables one That's I eight bytes long four bytes for where the new instruction pointer is four bytes for where the old instruction was located and Then we have a jump table Which basically lists I the offsets of our jumps and jumping to the instructions so we can check in there the older jumps? So you can check these old jumps match Now we should change it to this new one And basically that's what this for loop does with the infinite checks to see goes through if there's still I jumps to be processed it goes to the jump table and Goes through until it hits the end and then I comes down and sees if the old I jump table address is the same as the I New earth the old jump table address in the EI P table and then assigns the new one if the old ones match Other ideas that have come up about this is one of them was that I it's been an extremely old idea It's been done a lot even I can't think of any of the DOS viruses, but there have been ones either done that and It's registered change one generation and You have eax doing all these operations for you next generation you may have ebx Doing it which will change if you're doing a signature scan it changes the op code then we have I entry point obscuring techniques which have been fairly popular so that basically that is when you put a I jump or a call at the hosts entrance and Via file and then it jumps straight to the virus code runs it jump? back. And then there was one that's only been seen in the Z-MIST virus, which is unknown entry point. And what that does is it interjects the virus straight into the stream of code, which this can be done with your reassembler after disassembling both the host and the previous generation virus. And then we have other modules that you see a lot of them, like trash code generation that was big during a lot of email spreading viruses and worms and whatnot. And that one can be added, but there's a drawback that will be that your code will keep on growing throughout, which is what always happens with a garbage code generator. But also this can be used to change signatures, and we'll see why this might become important with a new type of AV. And then we have encryption, be it polymorphic, be it just regular encryption. These things are, you can also include them, but you have to be careful how you do it. So that, say like, sometimes a flag will be thrown up because you're using a certain technique to polymorphically encrypt and decrypt your virus. But say a properly done one would be Z-MIST is a great example of that one too, which is one of the greater viruses. And what it does is it acts exactly like a file that will decompress at runtime when it uses its polymorphic engine. So here comes the start of our AV section. I just wanted to put up this quote from an article about Z-MIST that says that metamorphism is something that's going to be pretty crazy and we need to find out something to do for it. And since Z-MIST and I, the I, unexpected entry point, have been written by ZOMBIE, I found an article by ZOMBIE that shows what the implications of doing this would be. And you have your variables, and this is basically saying that if you're doing a signature scan, you have to run through until you know you're definitely on the virus, and you don't know how long that will take. So, while I've been mentioning signature scans, so just to show you that in case if people don't know, I had like a little slide to tell you about signature scans, which is basically the oldest technique for virus finding viruses, and it's just to check a string of bytes or so forth to see if it matches a signature in a database. And if those match, then most likely you have a virus. And there's many other things. Say like, Z-Myst is my major example because that's the one that uses the most metamorphic techniques as a date that I've seen. And in his, he puts a Z in the DOS header, and that is his mark for I've infected that file. And you need these marks so you don't constantly infect the same file, but it's still a constant struggle in between will the virus recognize it, will the AVs recognize it. And one thing is this one's somewhat ambiguous because a Z is allowed in that portion of the header. So that you know sometimes the virus may not infect every file it can. Infecting ones are already not infected. And at the same time the AV will look at it and say, we're really not sure, this could be a legitimate Z, or it could be a Z placed by the virus. And next we come onto geometric scanning, which is one of the downfalls of like polymorphism. And I, but we see with it, Z-Myst, you know, like, it was able to beat it by acting like a runtime self-decompressing file. And so basically what GeometricScan does is check the size changes in the file so they can say, all right, this is acting like this, this is acting like that, because the initialized data section's grown this much. And then we have the possible answers, because we saw that ZMist had beaten the previous ones. And one of them is to combine various techniques and use kind of a heuristic idea. But this fails because it takes a lot of time, and nobody's going to run anything if it takes a lot of time. And also there's always anti-emulation, debugging, all that type of stuff, techniques coming out so that some of these techniques will fail, the AV techniques will fail if they try to use them with these other anti-star, whatever you want to call them, techniques included. And the second, which is a fairly new one, and I actually was looking around the Internet, and I saw that there's somebody that might be talking about this at the Virus Bolton conference. And it's to use a shrinker, like we were talking, one of the parts of the virus, the shrinker and the de-permutator, so that you can have this, virus de-permutated and shrink to its skeleton. And that's where the executable trash generator being left in there could help it out, because at its skeleton you'll still have opcodes that weren't there a generation beforehand. And so, yeah, we see the flaws in the answers. They take too long. You're not able to do some techniques if they include various ways of programming. And, but the shrinker is the closest one. We have, so that's what they have to go with. And I just want to include a section that's why this might be stronger compared to other techniques. And trash generation, of course, you just have worthless code, and the virus grows loads and loads every time it passes a generation. So after a while, a file will get big enough, and they'll know that something's happened. And also in polymorphism, you usually, you can always take like a static picture of the body, or at least portions of the body at times, throughout the running of the virus. So you can know that though it's decrypted now, or it's encrypted now, it always has to decrypt itself. So you have the same code once it's decrypted. Well, I'm sorry, I'm kind of new to speaking to large crowds, so I might have flew through that too fast. But I just wanted to open the floor to question and answer, or anything like that. Yes? Wouldn't most of these viruses be small enough that if you took a snapshot of any part of the body, did that look the same as like another program apart? Are we talking about the, with the polymorphism? I, it's possible that this could happen, but I haven't really checked too much into polymorphism to tell you the truth. I just looked at a few techniques and saw what they did, and, but I haven't really, I haven't really checked too much into polymorphism to tell you the truth. I just looked at a few techniques and saw what they did, and, but I haven't really, I haven't really checked too much into polymorphism to tell you the truth. I just looked at a few techniques and saw what they did, and, but I haven't really checked too much into polymorphism to tell you the truth. I haven't really checked too much into polymorphism to tell you the truth. I just looked at a few techniques and saw what they did, and, but I haven't really checked too much into polymorphism to tell you the truth. I haven't really checked too much into polymorphism to tell you the truth. I just looked at a few techniques and saw what they did, and, but I haven't really checked too much into polymorphism to tell you the truth. I haven't really checked too much into polymorphism to tell you the truth. I just looked at a few techniques and saw what they did, and, but I haven't really checked too much into polymorphism to tell you the truth. Which section were we talking about? I mean, the part that files the process of the decrypting virus during the infection. That's kind of the danger of your virus. I'm sorry, I can't really hear you too well up here, so I kind of miss pieces, and I think they're important. There is a part that is common, or is not encrypted, that is not polymorphic, which is the start of the virus. Is that the signator that can be easily recognized from antivirus software? I will... With the eyes, with the eyes, we have to be... Hey, Sean! Yeah? Repeat the question! Don't put it on the microphone. Well, his question was, if I recognize it correctly, is there a static part in metamorphic viruses that can always be recognized? And the thing is, since it can always be randomly expanded or permutated, you can step through it, but of course you'll still have different opcodes because of the expander or register exchange type of thing. So that's one thing, that's where the strength is with this, is that you can change, like, opcodes, and that's where mainly signatures are strings of opcodes. Do you think that AV software is going to have to run down the road of hash tables like QuickWire to be able to recognize changes? To recognize changes? I haven't looked too much into that, but that sounds like an interesting idea. That could be tried. Because mainly what I've heard is the shrinker idea, which will give you the code skeleton. Yes? This is how it shows how ridiculous viruses have gotten. Say, like, if you have, not even all of the major six I was talking about, but maybe, say, four of them. Say, like, the Z-MIS virus. I remember that being, I want to say, around 70, 80 pages or so. And some of it's also done in C, so, you know, that makes it even bigger. So it's... I'm sorry. Actually, that's a very good question. Okay. Oh, no, no, go ahead. When you do this sort of software engineering, does it make sense to break the C? That's what you might as you go later. Yeah. Is C unoptimized viruses? Just like what the compiler does? Well, the thing is, is with this virus, basically, we wrote something. Or with these viruses, the expander is basically an unoptimizer, which is really funny because, like, you know, not too long ago, everything had to be optimized for a virus. Nowadays, we're writing things to unoptimize them afterwards. So it shows that you really don't need optimization because we have so much room to deal with. So you have more... The techniques, it's no specific technique. Basically, it just looks through, and I... Well, most of them just look through, compare opcodes, because most of them are functions now, and they'll say, like, is this the opcode? If yes, change it to this. Yeah, but it's an expander. What about the shrink? Oh, the... I mean, the shrinker can compress operations. Yeah, well... Yeah, the compression is basically, like, say, for an easy example, I push ebx, pop ecx becomes... I move ecx, comma, ebx. Basically, that's it. Yes, sir? Yes, sir. There's 10. There's 10? Yeah, I haven't opened up the CD, so I... Wow. Are there any other... Yes, sir? I'm sorry, sir. Can you stand up? Yeah. I was... Well, with behavior blockers, I... Yeah, well, I... The thing with behavior scanners is if the behavior is found, of course, anything... Once you see what it will do, you'll know what's happening. But a lot of times, that takes a lot of time. And then, say, like, for emulation, sometimes there's ways that people have found to block emulation. So it'd be more of, like, an integrity scanner than an integrity scanner. Basically, you're already infected, and that's why it knows you're... have been infected. Emulation, I... I don't have my notes on it right now, but there's a few ways to... If I remember correctly, it's... It's placement of, like, variables below the call. So they... And it's, like, one of the hard-coded ones. Like, so if you do... I think it's, like... Usually, if you put the address that you want to put in for your call or jump, and I think it's... If you put in the instruction to do, like, dollar minus four, so it throws it back up in the instruction. If I remember correctly, that was one of them. But I don't know if... It's been a while since I've... If I read up too much on that. Is there a good reference? A good reference? I... Let's see. A good reference is... I'd basically say just reading through code is, like, the best reference. So sometimes... Usually, you can find some that's commented where they say this is... this technique being done type of thing. So that'd be the best start, I'd say, and best reference. So what part is... I... Currently, I know of some places where you can get, like, viruses that have the comments in them and so forth that use anti-emulation. I don't know if... They're still fairly new. And, well, usually, you can go to the same websites that I accessed some of my data off of for metamorphism, and they'll talk about that as well. So say, like... Let's see. The zombie's website, if you go to his, which is... z0mbie.host.sk, and you go to some of his links, you'll probably find some on his page and some on some of his link pages that you can, I, look at. I... Any more questions? Okay. Thank you for coming. Also, I'd like to thank my school because they helped... They're going to most likely help me pay for some of the trip over here. So I wanted to thank Regis University. Thank you. applause