Problem C-4.3
You are given the task of detecting the occurrences of a polymorphic virus that conceals
itself as follows. The body, C, of the virus code is obfuscated by XORing it with a byte
sequence, T, derived from a six-byte secret key, K, that changes from instance to instance
of the virus in a random way. The sequence Tis derived by merely repeating over and over
the given key K. The length of the body of the virus code is a multiple of six—padding is
added otherwise. Thus, the obfuscated body is T⊕C, where T=K||K|| · · · and || denotes
string concatenation. The virus inserts itself to the infected program at an unpredictable
location. @par An infected file contains a loader that reads the key K, unhides the body
Cof the virus code by XORing the obfuscated version with the sequence T(derived from
K), and finally launches C. The loader code, key K, and the obfuscated body are inserted
at random positions of infected programs. At some point of the execution of the infected
program, the loader gets called, which unhides the virus and then executes it. Assume that
you have obtained the body Cof the virus code and a set of programs that are suspected to
be infected. You want to detect the occurrences of this virus among the suspected programs
without having to actually emulate the execution of the programs. Give an algorithm to do
this in polynomial time in the length of the program. Assume that the loader of the virus
is a short piece of code that can be commonly found in legitimate programs. Therefore, it
cannot be used as a signature of our virus. Hence, looking for the loader is not an acceptable
solution. Remember, the loader is in binary, and as such, extracting information from it is
nontrivial, i.e., wrong.
Solution Take the virus code Cand xor repeated copies of it with the body of the
Problem C-4.4
Suppose there is a new computer virus, H1NQ, which is both polymorphic and metamorphic.
Mike has a new malware-detection program, QSniffer, that is 95% accurate at detecting
H1NQ. That is, if a computer is infected with H1NQ, then QSniffer will correctly detect
this fact 95% of the time, and if a computer is not infected, then QSniffer will correctly
detect this fact 95% of the time. It turns out that the H1NQ virus will only infect any
given computer with a probability of 1%. Nevertheless, you are nervous and run QSniffer
on your computer, and it unfortunately says that your computer is infected with H1NQ.
What is the probability that your computer really is infected?
Solution Think of a campus of 2000 computers. By the properties of H1NQ, 20 of these
22