Chapter2 Malware
Chapter2 Malware
“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
§ File sharing
§ Worm creates a copy of itself on e.g. a USB drive, executes when drive is
connected to another system using the autorun mechanism
§ Scanning
§ If worm spreads via software vulnerability in remotely accessible network
service
§ It must identify target systems running the vulnerable service
§ Variant A, B, and E
§ Worm runs an HTTP server on source computer
§ Target shellcode connects back to HTTP server to download a copy of
the worm as Dynamically Linked Library
§ Loads the copy to processes such as svchost.exe (Variant A) or running
services.exe or Windows Explorer processes (Variant B and higher)
invoking LoadLibrary with the DLL as argument
§ DLL copies itself in the system root directory under a random file name
§ After initiating Winsock DLL the malware is executed
§ Variant C
§ Generates a pool of 50 000 domains daily across 110 top-level domains
§ Randomly selects 500 to connect to
§ Using Windows’ random number generator seeded with unpredictable host
dependent seed
§ Consequence
§ No reliable prediction of domains that are going to be contacted possible any more
§ Expected rate of successful updates: only 1% of infected hosts per day
§ The shorter domain names are expected to collide with 150-200 existing
domains per day -> potential for DDoS attacks
§ Conficker ist still active in 2019 although it is detected by all common A/V
products
§ Spread over more than 150 countries world wide infecting over 200 000
machines
§ Spreading stopped after kill switch domain detected and registered by malware analysts
§ Encrypts files on infected machines with RSA with 2048 bit keys
§ Generate an AES key for encrypting the files, encrypt the AES key with public RSA key
§ System Corruption
§ Data Destruction
§ Ransomware
§ Physical-World Damage
§ Logic Bomb
§ Information Theft
§ Keyloggers and spyware
§ Phishing and identity theft
§ Espionage and data exfiltration
§ Stealthing
§ Backdoors and rootkits
§ Bots -> next chapter
§ Rootkit
§ Main characteristic: stealthiness
§ hides infection from the host’s owner
§ Typical infection path:
§ Use stolen password or dictionary attack to log in
§ Use a buffer overflow in a vulnerable local program to gain root
privileges
§ Download rootkit, unpack, compile, install
§ Rootkits often modify parts of the operating system
§ Install themselves as drivers or kernel modules
§ May also install a “back door” such as replacing the login
mechanism
Name Description
Advanced Persistent Sophisticated malware directed at specific business or political targets
Threat (APT) applied persistently and effectively
Adware Advertising integrated in software, often results in pop-up ads or
redirection of a browser to a commercial site
Attack kit Set of tools for generating malware, including propagation and payload
mechanisms
Auto-rooter Malicious hacking tool used to remotely break into machines
Backdoor Any mechanism that bypasses a security check, allows unauthorized
access to functionality in a program or system
Downloader Code that installs other items on a machine, e.g. loads a larger malware
packed after initial infection
Drive-by-downloads Uses code in a compromised web site that exploits a vulnerability in the
browser or browser plugins
Exploit Code specific to exploiting a single vulnerability or set of vulnerabilities
Flooder (DoS engine) Generates large volume of data, e.g. to carry out denial of service attack
Basic Reading
§ Charles and Shari Pfleeger, Jonathan Marguites: Security in Computing, 2014
§ Chapter 3.2: Malicious code
§ Stallings and Brown: Computer Security, 2015
§ Chapter 6 on malicious software
§ Matt Bishop: Introduction to Computer Security, 2004
§ Chapter 19: Malicious Logic
Further Reading
§ Jon Erickson: Hacking – The art of Exploitation, 2007
§ Chapter 3: Exploitation
§ Exploit data bases
§ bugtraq
§ US-CERT
§ Ken Thompson: Reflections on Trusting Trust, 1984
§ Peter Capek et al: Marry Christmas – An Early Network Worm, 2003
§ Felix Leder, Tillmann Werner: Know Your Enemy: Containing Conficker – To Tame a Malware,
2009
§ P. Porras et al: An analysis of conficker’s logic and rendezvous protocol, 2009