Slashdot Mirror


The Art of Computer Virus Research and Defense

nazarijo writes "I think by now we're all familiar with viruses and worms. It may have been a term paper diskette chewed up by a virus back in college, a family member's computer infected with the latest worm, or your email inbox clogged with a mass mailer of the week. But how do AV researchers dissect such malware, especially when virus writers have devoted so much time to avoiding detection and perfecting their craft with self-decrypting viruses, polymorphic shellcode, and obfuscated loops. Haven't you wanted a peek into how that's done, and how you would analyze such a monster that landed in your computer? Well, Peter Szor's book The Art of Computer Virus Research and Defense (TAOCVRD) has been gaining lots of critical acclaim lately for filling that gap, and rightfully so. (Before we begin, however, I should make one thing perfectly clear: I was a technical reviewer of this book. I enjoyed it when I read it originally, and I'm even more pleased with the final result. And now on to your regularly scheduled review.)" Read on for the rest. The Art of Computer Virus Research and Defense author Peter Szor pages 713 publisher Addison Wesley Longman and Symantec Press rating 9 reviewer Jose Nazario ISBN 0321304543 summary Clear, sweeping coverage of virus history and technical details

TAOCVRD opens with Part 1: Strategies of the attacker. Here we get to start to think about malicious code from the original ideas and viewpoints of its makers. Chapter 1 opens up with various games of the classic computer science world, including Conway's Game of Life and Core Wars, which is still fun after all of these years. From this we can start to think about computer viruses as a natural extension of other self-replicating computer structures. What's great about this chapter is that you can actually understand, and share in, the fascination of replicating code. It's as if you can understand the pure world that some virus writers live in.

Chapter 2 starts off the virus-analysis section, including some of the basics (like the types of malicious programs and their key features), as well as the naming scheme. Chapter 3, "Malicious Code Environments," serves as a lengthy and complete description of how various viruses work. The dependencies that you would expect to see, including OS, CPU, file formats, and filesystems, are all described. Then Szor goes on to describe how viruses work with various languages, from REXX and DCL to Python and even Office macros. Not all of the descriptions are lengthy, but you get to see how flexible the world of writing a virus can be. What I most enjoyed about the book overall is represented in this chapter, namely Szor's command of the history of the virus as well as his technical prowess, which he drops in as appropriate.

Chapter 4 gets a bit more technical and now focuses on infection strategies. Again, Szor isn't afraid to delve into history or technical meat, including a lengthy and valuable section "An In-Depth Look at Win32 Viruses." If you don't feel armed to start dissecting viruses by this point, you're in luck: there's so much more to read. Chapter 5 covers in-memory strategies used by viruses to locate files, processes, and sometimes evade detection. Szor has a list of interrupts and their utility to the virus writer, providing a comprehensive resource to the virus analyst.

Chapters 6 and 7 cover basic and advanced self protection schemes, respectively, used by viruses. TAOCVRD's completeness of information in a usable space, together with very functional examples and descriptions, is again evident. Szor walks you through a basic decryptor routine, for example, showing you how a self-contained virus can be both evasive and functional at the same time. Sadly little attention is given to various virus construction kits at the end of chapter 7, though.

Chapters 8 and 9 get a little less technical and somewhat more historical. These chapters cover virus payloads and their classification (ie benevolent viruses, destructive viruses, etc) and computer worms, respectively. The overview of payloads is almost entirely historical, giving a great overview of how virus writers have used their techniques to cause havoc or just have "fun" from time to time. Chapter 9 gives a concise and valuable overview of computer worms, almost boiling about half of my worms book down into just one chapter in a clear and easy to use fashion.

Part 1 concludes with chapter 10, which covers exploits and attack techniques used by worms and viruses. Again, Szor's clarity of explanation shines as he artfully gives a concise overview of how a buffer overflow attack works (including stack layout and address manipulation), heap-based attacks, format string attacks, and related methods. He then discusses these techniques in light of various historical examples, clearly explaining how they operated and were successful. If you've been yearning for a short overview of attack techniques and how malware has used them, this chapter is for you.

Part 2 covers the defender's strategies. Chapter 11 serves as a nice introduction to this section by describing many of the current and advanced defense techniques such as some of the first and second generation scanners, code and system emulation, and metamorphic virus detection. This is all covered in nice technical detail, always at a reasonable level to not leave everyone in the dust. Through it all small examples are constantly given, which reinforce the text nicely. Chapter 12 is very similar, this time focusing on in-memory scanning and analysis techniques.

Chapter 13 covers worm blocking techniques, focusing on host-based methods which can prevent the buffer overflow from being successful or the code from arbitrarily gaining network access again. Chapter 14 complements this with network specific defenses, including ACLs and firewalls, IDS systems, honeypots, and even counterattacks. These two chapters are a lot less technical than the previous two, but still quite valuable.

By this point I'm sure you're ready to try your hand at virus analysis, and Szor is eager to help you out. In chapter 15 he gives you a great setup for virus analysis, including various tools and examples of how they work and what kind of information they give you. Finally, in chapter 16 you have the obligatory (and valuable) resource roundup which complements the references given in every chapter, as well.

Overall I find Szor's book to be amazing, both in terms of its technical prowess over so many specifics in the field but also for its presentation. Without dumbing it down, Szor's able to communicate to most readers with clarity in a manner they'll understand, learn from, and be able to use. I think that many of us, especially those of us who get plundered in our email inboxes with malware, are curious to spend some time dissecting these beasts using techniques AV professionals use, and Szor's book does an exemplary job of introducing that world to us all. I consider this to be one of the most important computer security books I own due to it's clarity and completeness of coverage.

You can purchase The Art of Computer Virus Research and Defense from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

18 of 100 comments (clear)

  1. Is it just me... by udderly · · Score: 2, Insightful

    Is it just me or does this sound like it would be a really cool job--especially if you like sleuthing.

    1. Re:Is it just me... by Asshat+Canada · · Score: 2, Funny

      I was about to say yes until I realized you didn't say slutting.

  2. Avoid The Obvious Punctuation Error... by devphaeton · · Score: 3, Interesting

    But how do AV researchers dissect such malware, especially when virus writers have devoted so much time to avoiding detection and perfecting their craft with self-decrypting viruses, polymorphic shellcode, and obfuscated loops.

    I have a theory that probably 90% of the worms we see are written by the AV companies themselves.

    Either that, or they're REALLY DAMN GOOD at getting hold of some fledgling outbreak, no matter how obscure, and reverse engineering it and learning all its minute details. Sometimes they claim to do this within a couple of hours of its first known incident.

    I dunno.. maybe i'm a conspiratorist... I still say that Norton Internet Security is the most effective piece of malware out there.

    --


    do() || do_not(); // try();
    1. Re:Avoid The Obvious Punctuation Error... by MrPower · · Score: 2, Insightful
      Either that, or they're REALLY DAMN GOOD at getting hold of some fledgling outbreak

      I suspect that many of these "fledgling outbreaks" that the AV companies most quickly defeat are the variants that have just been edited by script kiddies.

      Tweak the engine a little and viola, they have defeated a virus in 10 minutes!

    2. Re:Avoid The Obvious Punctuation Error... by Tipa · · Score: 3, Informative

      Considering Symantec would instantly cease to exist as a company if it were ever found doing something like this, you can bet they aren't. There are top secret mailing lists used by AV companies and researchers where they pass around stuff as soon as they find it. Honeynet computers can catch viruses pretty quickly as well, and you can bet that all those AV companies have honeynets of their own just waiting to be infected.

    3. Re:Avoid The Obvious Punctuation Error... by bluGill · · Score: 2, Informative

      Script kiddies generally get bored before they get a working virus. If indeed the can follow the instructions to begin with.

      Most viruses these days are written by organized crime. (Actually worm or trojan might be better terms) They create networks of infected computers, and then sell the network. spam is often sent from infected machines. There are a few other ways to earn money from an infected machine, but spam is the money maker.

  3. Practice makes perfect by kaosrain · · Score: 4, Insightful

    But how do AV researchers dissect such malware, especially when virus writers have devoted so much time to avoiding detection and perfecting their craft with self-decrypting viruses, polymorphic shellcode, and obfuscated loops.

    It is important to note that virus authors who have perfected their craft create viruses that are not found.

  4. wormholes by Doc+Ruby · · Score: 2, Interesting

    I remember the early 1980s, when a funny little VMS program called "worms" would carve circular holes in text files, like a bookworm would in paper. It didn't selfreplicate or anything, and it destroyed the wormy file. But it was a real laugh when it wasn't your file. FWIW, the purely funny version backed up the original file in its own subdirectory.

    --

    --
    make install -not war

  5. Re:How to defend against computer viruses... by Jeremi · · Score: 2, Insightful
    Don't download random crap and execute it.


    That's easy to say, but harder to do. Any non-trivial program that connects to the Internet is going to download something... that's what makes it useful. And if the program wasn't 100% correctly written, there may be a way to make it execute the thing it downloaded. Voila, all the conditions are there to catch a virus, without the user ever realizing he was "downloading random crap" at all. (For examples, see: every web browser ever written)

    --


    I don't care if it's 90,000 hectares. That lake was not my doing.
  6. Uh huh. by Telastyn · · Score: 2, Interesting

    But how do AV researchers dissect such malware, especially when virus writers have devoted so much time to avoiding detection and perfecting their craft with self-decrypting viruses, polymorphic shellcode, and obfuscated loops. sic.

    They don't. All they need to do is watch the thing go by on the wire and pick out something that vaguely looks like a unique signature for their dumb as dirt detection engines. And that assumes that such techniques are commonly used, which they're not.

  7. Conspiracies? by Spy+der+Mann · · Score: 3, Informative

    I'm an old-schooler, I've read Norton's books like "Inside the IBM PC", when he spoke about bits, bytes, sectors, clusters, etc.

    I remember using the famous Norton Utilities for say, defragging my HD or repairing the DOS FAT table.

    Norton didn't enter the antivirus business until much later. The de-facto standard for cleaning up viruses was McAffee viruscan for DOS.

    And I was shocked at the massive amount of viruses being written... or actually, the amount of viruses that the McAffee antivirus SAID had been written (this was BEFORE the internet as we know it; we used to get the antivirus from BBS's or in issues of computer magazines). I'm talking about 300 or more viruses being written PER MONTH.

    The rumour of McAffee hiring virus writers was pretty extended.

    Today is very different. Antivirus companies DON'T NEED to hire virus writers (they don't need to create their own market, Microsoft has done them the favor :). With websites dedicated to virii and similar stuff, irc channels, mailing lists, and specially the number of Windows vulnerabilities, it's almost as if virii wrote themselves.

    Also, the jerks in the world seem to be multipying. And virus-writing tools are relatively easy to find. All it takes is a script kiddie and a virus writing toolkit. The real geniuses writing virii, are rare. However, all it takes is one original virus for several variants to appear in the next months.

    So, conspiracy theories? I don't think so.
    A bunch of self-organizing lamers? Very possible. Just look at the wikitorial invasion.

  8. Missing something fundamental by tyates · · Score: 3, Insightful

    From the review, it sounds like the book's missing something critical.
    1. The fact that viruses even exist today is a testament to crappy OS Design. OS X and Linux don't even get viruses. And then if you put crappy application design on top of crappy OS design, you get viruses you don't even have to execute, like Outlook and Word macro viruses.
    2. Worms and viruses are totally different. Worms attack you from the outside. But the odds of you getting a worm on a patched, up-to-date system that's behind a firewall is practically nil. (see for example, Apple Software Update.)
    In other words, in a "sane" world with decent operating systems and applications, viruses and worms wouldn't even exist.

    --
    Tristan Yates
    1. Re:Missing something fundamental by Redwin · · Score: 2, Insightful

      Um, the first ever computer viruses were written in Unix. Exploits to raise user permissions are well known, copying files to overwrite other files of the same access level would do it for exmaple.

      see http://www.cybersoft.com/whitepapers/papers/print/ networks_print.html
      for more information :-)

      --
      Warning, comments may not have been passed by the sanity department of my brain.
    2. Re:Missing something fundamental by pyrrhonist · · Score: 2, Informative
      Please show me how an application run from a user account can modify an executable owned by bin or root, for example.

      You can use a local root exploit, such as the mremap(2) exploit. This exploit will allow any unprivileged account to gain root privileges and can be used to execute arbitrary code with kernel level access.

      This is just an example. There are much better unpatched exploits if you look hard enough. A far simpler method is to just scan for improper file permissions.

      Some applications or libraries (zlib) have overflow and stack exploits that can be triggered by improperly formatted user data. If you provide a user with a data file to exploit this (i.e. a zip archive), you can then have the application run code to take advantage of the local root exploit.

      Then show me how that process would continue to other executables.

      Once you gain root access, you can easily replace executables, shutdown services, install kernel modules, etc. The way many distros are set up, you don't even need root access to do some rather malicious things.

      Then show me how that would spread from machine to machine, over the Internet.

      There's a lot more remote exploits out there than you think. One of my favorites involves the Buffalo LinkStation. The Buffalo LinkStation is a network appliance that runs Linux and uses Samba to serve files. There's a really fun exploit on it that will allow you run any command as root simply by sending it a properly formatted UDP packet. At this point, you can drop an auto-run installer into the SMB shares and infect every Windows machine that connects to the LinkStation, but I digress...

      Then please show me a case where that's actually happened.

      Well, it basically all started with the Morris Worm.

      Here are some Linux specific cases:

      Viruses: Staog, Bliss, Osf, RST, Binom, Alfa, Lindose, Adrastea, Amalthea, Btrq, Brunfly, BTM, Califax, Cassini, Debilove, Etap.d, Gildo, Glaurung, Guile, Gzid, Mcmd, Metis, Millen, Nel, Neox, Ovets, Satyr, Sickabs, Snoopy, Thebe, Winter, Xone

      Worms: Adm, Cheese, Mighty, Ramen, Slapper, Lion, Scalper, Adore, Kork, Mighty,

      --
      Show me on the doll where his noodly appendage touched you.
  9. This book was absolutely terrible. by weevlos · · Score: 2, Interesting

    Once again, what whitehat sources call detailed descriptions of "advanced" techniques really barely makeup a decent FAQ on an infosec subject. The infamous PHC Production "The Real Scriptkiddies" never fails to be relevant: http://seclists.org/lists/fulldisclosure/2002/Aug/ 0482.html I really wish Slashdot would mark it's article-based advertisements with some sort of flag so that I may filter them out in the same manner I do it's bannerads.

  10. Re:bookreview by GT_Alias · · Score: 2, Informative

    I'm only 1/3rd of the way through it, but up to this point the book has been about execution environments and infection strategies of both existing and theoretical viruses. I bought the book mostly to look at his analysis techniques, it looks like that part comes later. But if you care about a 1/3rd opinion, I've enjoyed everything I've read so far. It's been fascinating to see the different techniques applied to past viruses, you can appreciate the creativity virus writers put into their creations.

  11. Too Much Joy by Gary+W.+Longsine · · Score: 4, Interesting

    I think you have hit the nail on the head here.

    Reverse engineering malware is so much fun, and appeals to techie and tech-savvy manager types so much that it has been a terrific and terrible distraction. I've seen the effect firsthand -- companies waste precious limited mitigation and response talent and time trying to analyze malware when they should be taking immediate action to contain the spread of a worm.

    Corporations and government agencies have been so thoroughly trained by the AntiVirus industry that they have a hard time coping in an age of the zero day worm, flash worm, or even the boring ordinary retread worm with 800 variants that do different things and propagate through a dozen different old defects. In fact, in the last year it's become clear that worms targeting many old defects can spread widely, slipping in under the radar of AntiVirus definitions with dozens of daily variants. (It's hard to patch a large network, and the industry hasn't woke up to the fact that it's also hard to keep it patched.)

    What does it matter, which of the 800 strains of Spybot or Rxbot is smacking your PC's around? Well, if it were possible to quickly assess exactly what a given strain might do on a computer, it might be. But typically it's not possible.

    In fact, it's gotten to the point where the AntiVirus vendors themselves have all but given up on detailed analysis of the many variants emerging each hour. Sometimes critical features of a strain (what ports does it probe, etc.) are missing entirely from the public analysis of the strain for weeks after it was first detected. Sometimes one vendor will describe a feature while others don't. Obvious cut-and-paste errors in the analysis of major vendors can also be observed, if one pays close attention.

    The AntiVirus industry can't keep up the analysis of every minor strain, but they do continue the practice because it's a proven effective strategy for keeping mindshare. To their credit, they do a pretty reasonable job of rapid analysis and signature development on quite a few variants every day. Unfortunately, the stakes are pretty high and getting higher.

    The bottom line for big networks: focus on prevention and containment. Cleanup is very costly, so do your own analysis if you must, but don't let it delay or sap resources from containment efforts when a worm hits. Other damages might be mounting while the mitigation effort stalls out because an incident response team is bogged down trying to answer the question: "Does the variant that hit your network today have a keystroke logger?"

    With several variants of various worms released each day, are you *sure* that you've been hit with only one variant?

    Even if you think you are sure, in fact, you typically can't be sure quickly enough. Well staffed, well funded, and highly experienced labs at the major AntiVirus vendors can't keep up with detailed analysis of the zillions of variants. Neither can the overburdened IT staffs of the world. They need to stop trying.

    Disclaimer: As the founder of Intrinsic Security I am clearly convinced enough in the limitations of the AntiVirus approach that I started a company and developed an alternative (complementary) approach. All of my opinions, well reasoned and otherwise, are my own, although they may be shared by others.

    --
    If you mod me down, I shall become more powerful than you could possibly imagine.
  12. Fall of The Legend (was: Conspiracies?) by Gary+W.+Longsine · · Score: 2, Interesting
    For many years variants of this legend have floated around the net, taking different forms. The least conspiratorial version that I've heard is told as follows:
    "__Fill in the blank with one of the early players in the antivirus market__ had an ill-conceived bonus program in place for a while which rewarded employees for being the first to discover a virus. The incentives created by the program obviously ran counter to the long term interests of the company and their clients, and the bonus program was discontinued when an employee was caught writing their own viruses for submission."
    This is so dilbertesque that it seems almost likely to become true someday, even if it wasn't when the rumor started. It just sounds like something that would happen in a big company. I half expect one day to wake up to a headline, "Former AntiVirus executive admits to creating legendary bonus incentive program to find viruses in the early days of computing".

    However, it's probably just as likely that the rumor was started in usenet by the other major antivirus company, only to have it backfire in the form of some general level of mistrust of the AntiVirus industry.

    The legend has since mutated into the simpler but unlikely "AntiVirus vendors write most of the viruses" form of the legend. AntiVirus vendors today have far too much to lose. I'm confident that like all good corporations, they have policy in place which would lead not only to instant dismissal of employees caught releasing viruses "into the wild" to borrow their expression, but also probably to prosecution as well.

    By the way, this was also the earliest, well more precisely, the first form that I ever heard. It might be fun to trace this rumor back to its origins and analyze the meme propagation, as was done regarding the damaging misquotation that Al Gore claimed to invent the internet. The analysis would probably require more effort, since it goes back possibly twenty years or more.
    --
    If you mod me down, I shall become more powerful than you could possibly imagine.