Field of the Invention
[0001] The present invention relates to the field of malware detection. More particularly,
the invention relates to malware signature generation and detection.
Background of the Invention
[0002] Detecting a malicious software (hereinafter, "malware"- which is any program or file
that is harmful to a computer) by a signature is a common practice in any software
security tool. By generating a signature which uniquely identifiers a malware, one
may prevent the propagation of this malware through networks and stop it from spreading
to other computers.
[0003] A signature of an executable (a file that contains a program and that is capable
of being executed or run as a program in the computer) may be generated in any number
of techniques. For example, one may use an inherent binary sequence in the executable
and hash this sequence using a cryptographic hash function such as MD5 (an algorithm
that is used to verify data integrity through the creation of a 128-bit message digest
from unique data input as a fingerprint is to the specific individual) or SHA1 (a
cryptographic hash function). The generated hash can be used as a signature. Another
common technique is to incorporate details which reside in the executable headers.
For example, the libraries it is linked to.
[0004] The generated signature must be as reliable as possible. The false positive and false
negative rate must equal zero (or get as close as possible to zero). To achieve this
goal, signature generation is usually performed by experts, and involves rigorous
inspection of the suspected code. Only after identifying a common code (a code that
is generated by compilers, linked libraries etc.) the expert can extract the pieces
of code which uniquely identify the malware itself.
[0005] One of the most obvious shortcomings of signature based detection is handling new,
still in the wild, malware. A signature specifically tailored to a given executable
is designed not to match other executables, which leaves an open door for newly generated
malware.
[0006] Another obvious problem is the sheer amount of signatures one must maintain and check
against, when inspecting suspected executables.
[0007] Current techniques for generating signatures are either manual (expert driven) or
automatic. Experts rely on their ability to disassemble the suspected executable,
analyze the flow of the code and identify code sections which are unique to the suspect
executable. Automated systems cannot rely on flow analysis and resort to data mining
(or similar) techniques. For example, the Polygraph (
James Newsome, Brad Karp, Dawn Song, "Polygraph: Automatically Generating Signatures
for Polymorphic Worms," S&P05, pp. 226-241, 2005) system tries to find matching patterns in a flow of suspected network traffic. Such
common patterns are then converted to signatures.
[0008] It is therefore an object of the present invention to reduce the number of signatures
used to detect malwares, thus speeding-up the malware-detection process.
[0009] It is another object of the present invention, to be able to detect new unknown malware.
[0010] Other objects and advantages of the invention will become apparent as the description
proceeds.
Summary of the Invention
[0011] The present invention is directed to a method for implementing malware signature
builder and detection for executable codes, according to which the op-codes of the
executables are inspected, while disregarding other parameters of the executables.
Signatures are generated from common engines of executable codes and a large number
of malwares of the same family are represented by a small number of signatures. Then
known and unknown malwares are identified using the small number of signatures.
[0012] In one embodiment, benign executables are disassembled by a disassembler and the
op-code sequences of the benign executable are stored in a first DB and each malware
executable is disassembled by the disassembler to a sequence of op-codes. All common
op-codes substrings are found by a string comparator (e.g., using an LCS process)
for each pair of malware executables. A set of common op-codes substrings between
any two malware executables is composed by the string comparator, which also checks
which of the op-code substrings appear in at least one benign executable op-code sequence
stored in the first DB. The common op-code sub-strings are ignored and a set of common
op-code substrings, which do not appear in any benign executable op-code for each
pair of malware executables is identified by the string comparator. All sets of common
op-code substrings are stored in a second DB, as candidate signatures.
[0013] The string comparator may be used to find, for each candidate signature, the malwares
in which the candidate signature appears as well as the minimal set of candidate signatures
identifying all the malware executables. Then the minimal set is stored in the second
DB.
[0014] The op-code sequences may be converted into regular expressions, which can be matched
using binary sequences.
[0015] A single file signature may be generated by finding, for each offset in the op-code
string of the file, the shortest substring starting at this offset, which does not
appear in any clean file.
[0016] The shortest substring starting at this offset, which does not appear in any clean
file, may be found by receiving as an input, a malware executable and a benign set
of files; disassembling each benign executable by a disassembler; storing the op-code
sequences of the benign executable into the first DB disassembling the malware executable
into an op-code sequence; and generating by the string comparator, all common op-code
substrings between the op-code sequence of the malware and each op-code sequence f
the benign files stored in the first DB. The exact offsets in the malwares' op-code
sequence from which the common substring started are recorded by the string comparator,
for each common substring generated. A possible signature being the shortest string
starting from this offset which is not contained in a common op-code substring is
denoted by the string comparator, for each offset in the malwares' op-code sequence.
Then the set of possible signatures is stored in the second DB and the op-code sequences
are converted into regular expressions, to be matched as binary sequences.
[0017] Signatures may be converted to regular expressions by extracting by the string converter,
op-code substrings (signatures) from the second DB and converting the op-code substrings
into regular expressions using a lookup table; reducing the length of the resulting
regular expressions by string converter by adding "binary masks" as matchable elements;
and storing the regular expressions in the second DB.
[0018] Signatures may be detected on executables by disassembling by the disassembler any
examined executable file into a sequence of op-codes; detecting by the string comparator
if one of the signature regular expressions stored in the second DB exists in the
examined executable op-code sequence and issuing a corresponding "passed" or "failed"
indication. Whenever the string comparator finds at least one signature regular expression
in the examined executable op-code sequence, a "failed" indication is issued and the
examined executable is classified as malware. Otherwise, a "passed" indication is
issued and the examined executable is classified as safe.
[0019] Signature regular expressions may be checked by the string comparator for similarity
by defining a similarity relation between strings and matching by the string comparator,
a signature regular expression to similar strings in the examined executable file.
Whenever a high similarity value is found, a "failed" indication is issued and the
examined executable is classified as malware. Whenever a low similarity value is found,
a "passed" indication is issued and the examined executable is classified as safe.
[0020] Executables may be inspected while being in-transit at the network layer by creating
several versions from each extracted signature and by generating smaller signatures
from each of the signatures stored in the second DB, using a sliding window technique.
[0021] Whenever the number of smaller signatures is limited, executables may be inspected
by generating by the string converter, two small signature for the start and end of
the examined executable; determining a reasonable minimum packet size and discarding
each packet breaching the minimum. Whenever at least one of the two signature regular
expressions are found in the examined executable op-code sequence, a "failed" indication
is issued and the examined executable is classified as malware. Whenever none of the
two signature regular expression is found in the examined executable op-code sequence,
a "passed" indication is issued and the examined executable is classified as safe.
Brief Description of the Drawings
[0022] The above and other characteristics and advantages of the invention will be better
understood through the following illustrative and non-limitative detailed description
of preferred embodiments thereof, with reference to the appended drawings, wherein:
- Fig. 1 illustrates a system for reducing the number of signatures used to detect malwares,
according to an embodiment of the invention;
- Fig. 2 is a flow diagram illustrating the generation of signatures for a family of
malwares;
- Fig. 3 is a flow diagram form illustrating the generation of a small set of signatures
for a family of malwares;
- Fig. 4 is a flow diagram form illustrating the generation of signature for a single
malware; and
- Fig. 5 illustrates a detection process that is carried out on a suspected executable.
Detailed Description of Preferred Embodiments
[0023] The present invention discloses a method and use for signature extraction from malwares.
Accordingly, families of malwares, such that two members of the same family that share
a common "engine", are identified.
[0024] It is well known that there are malware generation utilities which use a common engine
to create new malware. The preset invention proposes to generate signatures from said
engine, thus allowing a large number of malwares of the same family and even still
unknown members of the same family to be identified by a small number of signatures.
Using a small number of signatures to represent a large number of malwares alleviates
the malware detection process, making it more efficient both in terms of resource
allocated, CPU usage and time complexity. Moreover, future malware designers, that
will use the same shared engine, will also be detectable by the proposed generated
signatures.
[0025] According to the present invention, only the portion of a machine language instruction
that specifies the operation to be performed (hereinafter "op-codes") of an executable
are inspected, while disregarding any parameters given. This is a new technique, which
has not been considered before. The reasoning behind it is that one must be aware
that malware designers will strive to hide such common engines using a broad range
of techniques. For example, these common engines may be located in different locations
inside different executables, they may be mapped to different addresses in memory
or even perturbed slightly. By using the op-codes, methods used by malware designers
can be overcome.
Multiple Files Signature Generation
[0026] A system for reducing the number of signatures used to detect malwares according
to an embodiment of the invention, is shown in Fig. 1. The system comprises a computer
100, connected to a first database 10 (DB 10) and a second database 20 (DB 20). Computer
100 includes a disassembler (used to convert a program in its executable, ready-to-run,
form or object code into a representation in some form of assembler language so that
it is readable) 200, a string comparator 300 and a string converter 400.
[0027] Fig. 2 illustrates in a flow diagram of the process which is performed according
to an embodiment of the present invention. Accordingly, generating signatures starts
at a preprocessing step. In step 21, a DB 10 that holds samples of benign executables
is composed by disassembling each benign executable by disassembler 200, and storing
the op-code sequences of said benign executable in DB 10. According to one embodiment
of the present invention the IDA-Pro (DataRescue, Liege-Belgium) disassembler is used.
A large and diverse database is of the essence, as the size and the variety of the
database directly affect the false-positive rate (i.e., identifying an executable
as malware, even though it is perfectly safe). According to one embodiment of the
present invention, a database of 23,000 benign executables, ranging over most common
operating systems is established.
[0028] Step 22 illustrates that given a family of malwares (signature generation for stand-alone
malware will be discussed later on), each malware executable is disassembled by disassembler
200 into a sequence of op-codes. According to one embodiment of the present invention
the IDA-Pro disassembler is used. Step 23 illustrates that for each pair of malware
executables, string comparator 300 finds all common op-codes substrings, using any
linear time LCS (Largest Common Substring) algorithm. Step 23 further illustrates
that after string comparator 300 composes the set of common op-codes substrings between
any two malware executables, it checks which of said op-codes substrings appear in
at least one benign executable op-code sequence in DB 10, and these common op-code
sub-strings are ignored. The end result of this step is that for each pair of malware
executables, there exists a set of common op-code substrings, which do not appear
in any benign executable op-code. These sets of common op-code substrings are stored
by string comparator 300 in DB 20. Each of these op-code substrings, which are the
candidate signatures, can be used as a signature.
[0029] According to one embodiment of the present invention, all of the candidate signatures
stored in DB 20 are used.
[0030] According to another embodiment of the present invention, a small number of signatures
are desired (e.g., in real-time filtering), and a small as possible number of the
candidate signatures is used, as each op-code substring can potentially cover more
than just one pair of malware executables. The signatures found using this process
are likely to contain the shared code segments of the malware executables, which,
in turn, define the common "engine" of said malwares executables. Moreover, such common
engines are very likely to match future versions of these malware executables, as
future versions normally employ said common engine. Referring to Fig. 3, steps 31-33
are identical to the step 21-23 specified in Fig. 2. However, in order to find a small
number of signatures from the set of candidate signatures, as illustrated in step
34, string comparator 300 finds for each candidate signature the malwares it appears
in (as it may appear in more than two). String comparator 300 then finds the minimal
set of candidate signatures such that all the malware executables are identified by
said set. This is done by converting the problem of the minimal set of candidate signature
to the problem of coloring of the malware files set.
[0031] Each candidate signature is converted to a color, and as such, colors all the malware
executables it appears in. The combinatory problem to find a minimal set of colors
such that all malware executables are colored at least once, is then solved by string
comparator 300. As this problem is NP-complete (a problem is called NP (Nondeterministic
Polynomial) if its solution can be guessed and verified in polynomial time. If a problem
is NP and all other NP problems are polynomial-time reducible to it, the problem is
NP-complete), according to one embodiment of the present invention, a simple greedy
algorithm is used, which yields a good approximation of signatures to be used. For
example, in a family of 80 malwares examined, 15 signatures were enough to cover the
whole family. The found set of candidate signatures is then stored by string comparator
300 into DB 20.
[0032] The result of this stage is a set of signatures, which are composed of a sequence
of op-codes substrings, as described above. According to one embodiment of the present
invention, string converter 400, as will be detailed below, is then responsible to
convert said op-code sequences into regular expressions, which can be matched using
binary sequences.
Single File Signature Generation
[0033] In another embodiment of the present invention, a signature for a stand-alone file
is generated (e.g., said file had no common substrings with other malware).
[0034] Generating a signature for a single malware has been extensively studied in the past.
Any method which generates a signature given a set of input symbols (in our case,
vla-codes) and a set of "clean" specimen can be used. According to the invention,
given a malware executable, the system finds, for each offset in the op-code string
of said file, the shortest substring starting at this offset, which does not appear
in any clean file.
[0035] Fig 4 illustrates how to find the shortest substring starting at this offset, which
does not appear in any clean file. Device 100 receives as input a malware executable
and a benign set of files. In step 41, DB 10 is formed by disassembling each benign
executable by disassembler 200, and storing the op-codes sequences of said benign
executable into DB 10. According to one embodiment of the present invention, the IDA-Pro
disassembler is used. Moreover, disassembler 200 disassembles said malware executable
into an op-code sequence. In step 42, string comparator 300 generates all common op-code
substrings between the op-code sequence of the malware and each op-code sequence of
the benign files stored in DB 10. In step 43, for each common substring generated,
string comparator 300 records the exact offsets in the malwares' op-code sequence
from which the common substring started. In step 44, for each offset in the malwares'
op-code sequence, string comparator 300 denotes the shortest string starting from
this offset which is not contained in a common op-code substring, as a possible signature.
In step 45, string comparator 300 stores the set of possible signatures into DB 20
for future use.
[0036] The result of this stage is a set of possible signatures, which are composed of a
sequence of op-codes substrings, as described above. According to one embodiment of
the present invention, string converter 400, as detailed below, is then responsible
to convert said op-code sequences into regular expressions, which can be matched in
binary sequences.
Converting Signatures to Regular Expressions
[0037] According to one embodiment of the present invention, string converter 400 extracts
op-code substrings (signatures) from DB 20, and converts said op-code substrings into
regular expressions. This is done in order to get a compact, dense, easy to use signature.
As each op-code has a finite set of binary representations, the generation of a regular
expression is facilitated by a simple lookup table. However, the resulting regular
expressions are rather long as the set of possible binary representations can be quite
large. For example, the "add" op-code has 9 different binary representations. Moreover,
the length of the regular expressions is rather long, as the smallest element matchable
by most regular expressions implementations is a byte, some op-codes are shorter than
a byte and encode registers information in this same byte.
[0038] In an embodiment of the present invention, the length of the resulting regular expressions
is reduced by string converter 400, using the following augmentation to regular expression
operator. Namely, string converter 400 adds "binary masks" (a screen of numbers that
tells which numbers to look at underneath. In a binary mask, a "1" over a number means
"Look at the number underneath"; a "0" means "Don't look.") as matchable elements.
For example, the following binary values are matched, "0xa1, 0xa2, 0xa3,..., 0xaf",
using a single expression, "&0xaf", which implies that a byte X matches if and only
if the bitwise (i.e., data at the bit level) and of X and 0xaf differs from 0. Hence,
string converter 400 reduces the length of the generated regular expressions considerably.
After creating said regular expressions from each of the signatures, string converter
400 stores said regular expressions into DB 20.
Signature Detection on Executables
[0039] As disclosed above, each generated signature stored in DB 20 is converted into a
regular expression. Fig. 5 illustrates a detection process that is carried out on
a suspected executable. In step 51, an examined executable file is disassembled into
a sequence of op-codes by disassembler 200. According to one embodiment of the present
invention, the IDA-Pro disassembler is used. In step 52, string comparator 300 then
detects if one of the signature regular expressions stored in DB 20 exists in the
examined executable op-code sequence and issues a corresponding "passed" or "failed"
indication. This is achieved by employing a finite automaton of each of the regular
expressions signatures on the executable examined op-code sequence, by string comparator
300. If string comparator 300 finds at least one signature regular expression in the
examined executable op-code sequence, a "failed" indication is issued and the examined
executable is classified as malware, as illustrated in step 53. If however, no signature
regular expression is found in the examined executable op-code sequence, a "passed"
indication is issued and the examined executable is classified as safe, as illustrated
in step 54.
[0040] In an embodiment of the present invention, No Operation Performed (NOP- a command
that effectively does nothing) op-codes are ignored by string comparator 300 when
matching signature regular expressions in said examined executable op-code sequence,
to prevent the simple obfuscation of malware by inserting NOPs in the instruction
sequence.
[0041] In another embodiment of the present invention, the signature regular expressions
are checked by string comparator 300 for similarity, and not only for exact match
in the examined executable op-code sequence. Namely, a similarity relation between
strings is defined, and a signature regular expression is matched by string comparator
300 to similar strings in the examined executable file. When a high similarity value
is found, a "failed" indication is issued by string comparator 300 and the examined
executable is classified as malware. If however, a low similarity value is found in
the examined executable op-code sequence, a "passed" indication is issued and the
examined executable is classified as safe.
[0042] According to another embodiment of the present invention, inspection is made to executables
that are in-transit at the network layer. One may not always be able to capture the
entire length of an executable, as the executable may be divided in parts and each
part is routed differently (when using, for example, the TCP/IP protocol).
[0043] To overcome the aforementioned problem, string converter 400 creates several versions
from each extracted signature. Each version is a smaller signature, covering a possible
portion of the original signature. Using this technique the probability of identifying
a packet in transit as a possible part of malware executable is boosted.
[0044] String converter 400 generates from each of the signatures stored in DB 20 smaller
signatures using a sliding window technique. If the lower bound on the portion of
the executable the system can inspect is K (measured in bytes, for each consecutive
K op-codes of the executable under examination, string converter 400 generates a signature.
Each of the K consecutive op-codes is compared by string comparator 300 to the smaller
signatures extracted by string converter 400. If string comparator 300 finds at least
one signature regular expression in the examined executable op-code sequence, a "failed"
indication is issued and the examined executable is classified as malware. If however,
no signature regular expression is found in the examined executable op-code sequence,
a "passed" indication is issued and the examined executable is classified as safe.
[0045] According to another embodiment of the invention, the number of smaller signatures
is limited, and string converter 400 generates two small signature for the start and
end of the examined executable, as the start and end of an executable can be ensured
to be contained in a single packet, by limiting the size of the smallest packet (such
truncated signatures also need to be validated against the benign file DB 10, to ensure
there are no false positives). According to one embodiment of the invention, a reasonable
minimum packet size is determined, and each packet breaching this minimum is discarded
(this, for example, prevents an attacker from sending an executable byte by byte).
If string comparator 300 finds at least one of said two signature regular expressions
in the examined executable op-code sequence, a "failed" indication is issued and the
examined executable is classified as malware. If however, none of said two signature
regular expression is found in the examined executable op-code sequence, a "passed"
indication is issued and the examined executable is classified as safe.
Exemplary Results
[0046] A family of 99 worms was studied. A total of 15 signatures were enough to cover 79
worms of the family. The other 20 worms did not have a common substring with other
worms and needed a signature of their own.
[0047] The above examples and description have of course been provided only for the purpose
of illustration, and are not intended to limit the invention in any way. As will be
appreciated by the skilled person, the invention can be carried out in a great variety
of ways, employing more than one technique from those described above, all without
exceeding the scope of the invention.
1. Method for implementing malware signature builder and detection for executable codes,
comprising:
a) inspecting the op-codes of said executables, while disregarding other parameters
of said executables;
b) generating signatures from common engines of executable codes;
c) representing a large number of malwares of the same family by a small number of
signatures; and
d) identifying known and unknown malwares using said small number of signatures.
2. Method according to claim 1, comprising:
a) disassembling benign executables by a disassembler;
b) storing the op-code sequences of said benign executable in a first DB.
c) disassembling each malware executable by said disassembler to a sequence of op-codes;
d) for each pair of malware executables, finding all common op-codes substrings by
a string comparator;
e) composing a set of common op-codes substrings between any two malware executables,
by said string comparator;
f) checking by said string comparator, which of said op-code substrings appear in
at least one benign executable op-code sequence stored in said first DB;
g) ignoring said common op-code sub-strings;
h) for each pair of malware executables, identifying by said string comparator, a
set of common op-code substrings, which do not appear in any benign executable op-code;
and
i) storing by said string comparator, all sets of common op-code substrings in a second
DB, as candidate signatures.
3. Method according to claim 2, wherein all common op-codes substrings are found by the
string comparator using an LCS process.
4. Method according to claim 2, further comprising:
a) finding, for each candidate signature, by the string comparator, the malwares in
which said candidate signature appears;
b) finding, by the string comparator, the minimal set of candidate signatures identifying
all the malware executables; and
c) storing said minimal set in the second DB.
5. Method according to claim 4, further comprising converting the op-code sequences into
regular expressions, which can be matched using binary sequences.
6. Method according to claim 1, wherein a single file signature is generated by finding,
for each offset in the op-code string of said file, the shortest substring starting
at this offset, which does not appear in any clean file.
7. Method according to claim 6, wherein the shortest substring starting at this offset,
which does not appear in any clean file, is found by:
a) receiving as an input, a malware executable and a benign set of files;
b) disassembling each benign executable by a disassembler;
c) storing the op-code sequences of said benign executable into the first DB disassembling
said malware executable into an op-code sequence;
d) generating by the string comparator, all common op-code substrings between the
op-code sequence of the malware and each op-code sequence of the benign files stored
in said first DB;
e) for each common substring generated, recording, by said string comparator, the
exact offsets in the malwares' op-code sequence from which the common substring started;
f) for each offset in the malwares' op-code sequence, denoting, by said string comparator,
a possible signature being the shortest string starting from this offset which is
not contained in a common op-code substring;
g) storing the set of possible signatures in the second DB; and
h) converting said op-code sequences into regular expressions, to be matched as binary
sequences.
8. Method according to claim 7, wherein signatures are converted to regular expressions
by:
a) extracting by the string converter, op-code substrings (signatures) from the second
DB and converting said op-code substrings into regular expressions using a lookup
table;
b) reducing the length of the resulting regular expressions by string converter by
adding "binary masks" as matchable elements; and
c) storing said regular expressions in the second DB.
9. Method according to claim 1, wherein signatures are detected on executables by:
a) disassembling by the disassembler any examined executable file into a sequence
of op-codes;
b) detecting by the string comparator if one of the signature regular expressions
stored in the second DB exists in the examined executable op-code sequence and issuing
a corresponding "passed" or "failed" indication;
c) whenever the string comparator finds at least one signature regular expression
in the examined executable op-code sequence, issuing a "failed" indication and classifying
said examined executable as malware; otherwise,
d) issuing a "passed" indication and classifying said examined executable as safe.
10. Method according to claim 8, wherein signature regular expressions are checked by
the string comparator for similarity by:
a) defining a similarity relation between strings;
b) matching by the string comparator, a signature regular expression to similar strings
in the examined executable file;
c) whenever a high similarity value is found, issuing a "failed" indication and classifying
the examined executable as malware; and
d) whenever a low similarity value is found, issuing a "passed" indication and classifying
the examined executable as safe.
11. Method according to claim 10, wherein executables are inspected while being in-transit
at the network layer by:
a) creating several versions from each extracted signature; and
b) from each of the signatures stored in the second DB, generating smaller signatures
using a sliding window technique.
12. Method according to claim 10, wherein whenever the number of smaller signatures is
limited, executables are inspected by:
a) generating by the string converter, two small signature for the start and end of
the examined executable;
b) determining a reasonable minimum packet size;
c) discarding each packet breaching said minimum;
d) whenever at least one of said two signature regular expressions are found in the
examined executable op-code sequence, issuing a "failed" indication and classifying
the examined executable as malware; and
e) whenever none of said two signature regular expression are found in the examined
executable op-code sequence, issuing a "passed" indication and classifying the examined
executable as safe.