Chapter2 Malware Part1
Chapter2 Malware Part1
Chapter2 Malware Part1
“A program that is inserted into a system, usually covertly, with the intent
of compromising the confidentiality, integrity or availability of the
victim’s data, applications, or operating system or otherwise annoying or
disrupting the victim”
§ Note that
§ Definition excludes coincidences, although their consequences may
be similar
§ Owner of the system and the victim do not have to coincide
§ Corporate espionage
§ Stealing patented information, prizing strategies,
information on new models,…
§ Indirect financial gain
cp /bin/sh /tmp/.xyz
chmod u+s,o+x /tmp/.xyz
rm ./ls
ls $*
§ Attacker saves this script in a file called “ls” and tricks a victim user into
executing it
§ To the victim user, the result will look as if the real ls command would
have been executed
§ This leads to a copy of the shell in a hidden file executable by anyone with
the userid set to who-ever-executed-the-script
§ Program with an
§ overt purpose (known to user) and a
§ covert purpose (unknown to user)
§ Often called a Trojan
§ Back doors
§ Methods of bypassing normal authentication
§ Gain remote access to a computer
§ While attempting to remain undetected
§ DDoS engines
§…
§ But:
§ Do you really check the source code?
§ And what about the compiler?
§ Describes how to
§ Write a self-reproducing code fragment
§ In a first step, modify the compiler such that
§ when it compiles the login program, it inserts a back door
§ login with back door accepts the user's correct password or a fixed master
password (the same one for all users)
§ Now make the original login code open source such that anyone can check it
for backdoors
user password
logged in
user password or
magic password
logged in
§ Delete the source containing the modification and put the original
compiler source back in place
login source
login source
§ Thompson during his speech when receiving the Turing award in 1983
§ “The moral is obvious. You can't trust code that you did not totally create
yourself. (Especially code from companies that employ people like me.) No
amount of source-level verification or scrutiny will protect you from using
untrusted code.“
Software fragment that attaches itself to some existing executable. Virus can
replicate itself and pass on malicious code to other non-malicious executables
by modifying them
§ Analogy to a biological virus
§ Infects healthy subjects by attaching itself to the program
§ Either destroys or coexists with with the program after infection
§ Someone has to run the infected program to initially execute the virus
§ Modification includes
§ Injecting a routine to make copies of the virus code
§ Other say No
§ Overt purpose = virus’ actions (infect, execute)
§ Covert purpose = none
§ Macro virus
§ Infects files with macro or scripting code that is interpreted by an application
§ Multipartite virus
§ Infects files in multiples ways. Typically, the multipartite virus is capable of
infecting multiple types of files, so that virus eradication must deal with all of
the possible sites of infection
§ A macro..
§ is an executable program written in a scripting language embedded in a file
generated with an application
§ E.g. embedded in a word processing document or spreadsheet
§ A macro virus…
§ is composed of a sequence of instructions that are interpreted by an
application (e.g. Word, Excel) rather than executed directly
§ are platform independent
§ spread easily as documents are more often exchanged than programs
§ When an infected document is opened, the virus copies itself into the
global macro file and makes itself auto-executing
§ Invoked whenever any document is opened or created
§ Encrypted virus
§ Stealth virus -> uses rootkit techniques
§ Polymorphic virus
§ Metamorphic virus
Decryption key
§ A virus that changes its form each time it inserts itself into another
program
§ While functionality stays the same
§ Idea is to prevent signature detection by changing the “signature” or
instructions used for decryption routine
§ Simplest form: encrypt the same virus body with a different key on each
infection
§ More advanced
§ At instruction level: substitute instructions
§ At algorithm level: different algorithms to achieve the same purpose
§ Possible also on the decryption routine
Mutation A
Virus body
Mutation B
Mutation C
§ From Szor and Ferrie, “Hunting for Metamorphic”, Symantec White Paper,
2001
§ To integrate itself into host’s instruction flow, virus must disassemble and
rebuild host binary
Randomly insert
indirect call OR jump
to decryptor’s entry
point OR rely on
instruction flow to
reach it
Disassemble, insert space for new Insert mutated virus body Encrypt virus body by Insert random garbage
code blocks, generate new binary • Split into jump-linked “islands” XOR (ADD, SUB) with a instructions using
• Mutate opcodes (XOR ↔ SUB, OR ↔ TEST) randomly generated key, Executable Trash Generator
• Swap register moves and PUSH/POP, etc.
insert mutated decryptor