07 Malware
07 Malware
Fall 2023
Malware
Tyler Bletsch
Duke University
Introduction
MALWARE:
Software that violates confidentiality, integrity,
or availability of a system.
2
The universe of malware
Methods of infection
Goals of attacker 3
Vectors of infection
More
technical • Can classify by how
amount of technical
Virus Macro virus Exploit Worm engineering vs. social
Methods of infection
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
4
social
Vectors of infection
More
technical • Can classify by how
amount of technical
Virus Macro virus Exploit Worm engineering vs. social
Methods of infection
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
5
social
Viruses
• Software that “infects” (modifies) existing programs
▪ Modifies executables to include code to spread further
▪ Has same permissions as that program, runs in secret
▪ Is OS- and platform-specific
• Classical targets of viruses
▪ Boot sector virus – modifies launch firmware [OBSOLETE]
▪ File infector – modifies executable files [DETECTABLE]
▪ Macro virus – the “program” is automation code inside of documents [DYING]
• They may employ concealment strategies such as:
▪ Encrypted virus – Code gets decrypted at launch, keeps hashes unique
▪ Polymorphic virus – Mutates or changes with every infection
6
Viruses in the modern era
• Observation: Viruses modify binary executables
• Solutions?
▪ Don’t let unprivileged users modify binaries
▪ Track hashes of binaries, notice when they change
▪ Require cryptographic signing of binaries
• Bottom line: virus infection strategy is peculiar, can be detected
It’s not
a virus. 7
Vectors of infection
More
technical • Can classify by how
amount of technical
Virus Macro virus Exploit Worm engineering vs. social
Methods of infection
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
8
social
Macro viruses
• Many document formats have some form of scripting to allow
custom automation, e.g. Microsoft Office
• Attackers make document macros that infect other documents
when opened.
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
10
social
Worms
• Worm: A program that seeks out more machines to infect
▪ Each infected machine is a launching pad for attacks on other machines
• Methods of spread:
▪ Exploit software vulnerabilities in client or server programs
▪ Can use network connections to spread from system to system
• Example: Web app bug allows uploading of new code
• Example: SSH dictionary attack to infect bad credential’d hosts
▪ Spreads through shared media (USB drives, CD, DVD data disks)
• Example: Automatically write autostart executable to attached USB stick
▪ Can include social techniques (email, instant messaging, etc.)
• Example: Email to everyone in address book with “me-nude.jpg.exe”
11
How a network worm tries to spread
Many possible strategies. Examples:
• Random: Each compromised host probes random addresses in the
IP address space using a different seed. High traffic, may be
inadvertently disruptive.
• Hit-list: The attacker first compiles a long list of potential vulnerable
machines, includes in worm itself, infections scan part of the list.
▪ Example of targeted attack – common if attacker wants to achieve something
specific with stealth (e.g. the Stuxnet worm)
• Topological: Use info in or about the victim machine, such as
“automagic” file sharing services
• Local subnet: Target hosts nearby on network; especially good if the
worm lands behind a NAT or firewall
12
Malware history: the Morris worm (1988)
• First major worm on the internet
• Attributes:
▪ Dictionary-attacked weak passwords
▪ Exploited bugs in “fingerd” (user info
tool) and “sendmail” (email server)
13
Morris Worm, continued
• Not supposed to cause damage
▪ Had an intentional 1 in 7 chance of re-
infecting an infected system in case the
already-infected detector had been fooled
▪ This was dumb due to math
▪ Damage due to re-infection choking
system with thousands of worm processes
• Internet was literally segmented
during cleanup
• First conviction under the 1986
Computer Fraud and Abuse Act
▪ Probation, community service, and $10k
fine
14
Worms today
• Worms are alive and well today, but the term “worm” is less
common
15
Vectors of infection
More
technical
rootkits?
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
16
social
What is a rootkit?
• How do you tell if a system is running process X?
▪ Ask the OS (e.g. the ps command)
“Runs at boot” doesn’t
▪ What if the OS lies??????? imply rootkit – needs to
mess with OS behavior!
17
Rootkit properties
• Persistent vs. in-memory:
▪ Persistent: Activates on system boot; requires persistent storage. Can be
easier to detect (can look at storage offline).
▪ In-memory: No persistent code (can't survive a reboot). Can be harder to
detect (have to look at RAM; usually need OS to do so).
• Location:
▪ User mode: Replace system tools (ls, cat, etc.) or their shared libraries.
• Example: LD_PRELOAD on Linux -- put a custom library in front of any
executed program; can catch all libc calls.
▪ Kernel mode: Modify kernel memory; can control all syscalls.
▪ Virtual machine based: Install a lightweight hypervisor and run the operating
system in a virtual machine.
▪ External: Control something outside the plain CPU, such as the BIOS or
system management mode, so it can directly access hardware.
18
Adapted from textbook slide materials
knark_fork( )
sys_read( ) sys_read( )
system call system call
table table
sys_execve( ) sys_execve( )
sys_chdir( ) sys_chdir( )
19
Example of a kernel rootkit
20
Vectors of infection
More
technical • Can classify by how
amount of technical
Virus Macro virus Exploit Worm engineering vs. social
Methods of infection
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
21
social
Drive-By Downloads
• Exploit browser vulnerabilities to download and installs malware on
the system when the user views a Web page controlled by the
attacker
▪ Usually happens automatically and invisibly
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
23
social
Clickjacking
• What do you use to authorize something on your computer?
• This is why the browser waits before it lets you say yes to certain
things
25
Vectors of infection
More
technical • Can classify by how
amount of technical
Virus Macro virus Exploit Worm engineering vs. social
Methods of infection
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
26
social
Phishing
• Phishing: A social engineering attack where the
attacker pretends to be a trusted source, induces
victim to take an action
▪ Possible “sources”: Your IT department, a voicemail
system, a cloud storage provider, a friend or colleague,
an authority at your company, etc.
▪ Possible actions: Click a link, open an attachment,
img src
reply with info, change a setting, transfer money,
run a program (like a trojan horse – next topic!), etc. It’s not just about
stealing credentials!
• Spear phishing:
▪ Normal phishing is usually broadcast to large number of potential victims
▪ Spear phishing is specific and targeted
• Create a deeper narrative for specific victim(s)
• Leverage facts already found from other investigation/attacks
28
Vectors of infection
More
technical • Can classify by how
amount of technical
Virus Macro virus Exploit Worm engineering vs. social
Methods of infection
engineering
Drive-by download
Clickjacking
Phishing
Trojan
horse
Spear phishing
More
29
social
Trojan horse
30
Trojan horse
• Trojan horse: Malware that the attacker tries to get the victim to
run themselves.
• Example approaches:
▪ Pretend to be installer for a program the user wants
▪ Better: actually *be* the installer, but with something extra…
▪ Pretend to be a non-program,
e.g. the classic “adorablecat.jpg.exe”
▪ Make a web ad that looks like
what the user wants
▪ Pretend to be a necessary step to
something else, e.g.
“you must install MalMeeting plugin
to attend this webinar”
31
Summary of commonly confused malware terms
• Viruses: Infect executables to spread
32
The universe of malware
Methods of infection
Goals of attacker 33
Goals of attacker (1)
• Remote access
▪ Back door: Maintain access
▪ Network access: Penetrate private network (e.g. a tunnel or VPN)
▪ Spyware: Gather info on user/system activities
• Keylogger: Specifically monitor keyboard (passwords, bank info, etc.)
• Data theft: Steal data, either generally or in a targeted way
▪ Scams: Use malware as part of a larger scam to get user money/info,
e.g. the currently common “Microsoft support” scam
• Business Email Compromise (BEC)
▪ Usually an extended, personalized attack:
1. Gain access to a victim via spearphishing, malware, or other technique(s)
2. Learn about the business: who makes decisions, how they’re communicated
3. Impersonate a decision maker (and possibly others) via email to arrange a
money transfer or other profitable action
34
Goals of attacker (2)
• Zombie/Botnet: Enlist victim as a node in a network of victims
▪ Distributed Denial of Service (DDOS): Have all bots flood a target
▪ Spam sender
▪ Mine stupid cryptocurrencies
• Endpoint attacks
▪ Ransomware: Encrypt files and sell the user back the key to decrypt
• This one is HUGE right now!!
• Usually demand payment in Bitcoin or other cryptocurrency
▪ Adware: Inject ads into normal browsing or just have them pop up
▪ Damage/defacement: Just mess things up, sign the attacker’s work, etc.
▪ Charge for services: Use SMS, phone, pay services, etc. to rack up bills
• Attack kit: Download tools to further an active intrusion
35
The universe of malware
36
Classes of attackers
• Explorer: An individual just testing things
▪ Increasingly rare…
• Criminal: Out for money (either directly or indirectly)
▪ Increasingly common…
• Hacktivist: Political motivation
• Advanced Persistent Threat (APT)
▪ Nation-states and large collective organizations
▪ Advanced: Has access to unpublished vulnerabilities and custom tools; will
deploy multiple malware systems in a concerted attack
▪ Persistent: Has specific targets of interest and will work on them over time
▪ Threats: Did you read the above two?
37
Who APTs are and what they do
• Gets paid in bitcoin? You’re a criminal.
• Work in an office; get paid by the government? You’re in an APT.
39
The universe of malware
40
Optimal defense: prevention
• Prevention is best, but prevention is also hardest.
• Keys to malware prevention:
▪ Policy: Adopt preventative maintenance policies and clear procedures for
how systems are used
• #1 example: Keep systems up to date with security updates!
▪ Awareness: Most infection methods involve some amount of social
engineering
• Training reduces effectiveness of the social dimension
▪ Vulnerability mitigation: Deploy defenses against classes of vulnerability
• Example: Software can be written to do no runtime memory allocation,
thus eliminating the possibility of memory allocation bugs
(e.g., Wireguard VPN)
▪ Threat mitigation: Deal with specific malware threats and behavior patterns
• This includes Host-Based Intrusion Detection Systems (HIDS),
Network-Based Intrustion Detection Systems (NIDS), and other things
we’ll cover later in the course
41
What about anti-virus?
• Slide from the text book:
True?
42
Rootkits ruin everything (1)
• If any malware has ever touched a system, the following is possible:
▪ The malware may have exploited an unpublished kernel vulnerability to get
root access
▪ Using this access, it may have installed a rootkit, rendering all OS calls suspect
▪ RESULT: Even if it looks like known malware, that may be a ruse, and your
kernel has a persistent infection that you cannot detect
• CONCLUSION: “Flatten and reinstall”
▪ Destroy all data and restore from install files and/or known-good backup
43
Rootkits ruin everything (2)
• Higher levels of paranoia can also exist:
▪ If a bare metal computer, malware may have exploited a hardware
vulnerability to install outside the OS, e.g. the system firmware, hard disk
firmware, video card firmware, out-of-band management system, etc.
▪ If a VM, malware may have exploited a hypervisor vulnerability to take over
the hypervisor and may be in command of all VMs (and may do the hardware
stuff listed above).
• In that case…
etc., etc.
47
An alternative take on anti-virus software (1)
• Modern anti-virus is weak against novel threats,
and in some cases can be harmful!
• Antivirus software must:
High value target
1. Hook in at kernel level
2. Parse and process every piece of code and data you see using a wide variety
techniques (lots of code)
Large attack surface
QUALITY MATTERS!
48
Example: a tale of two antiviruses
• Symantec/Norton Microsoft Defender
• Runs malware analysis
entire in a sandbox
(code unable to use
most system calls)
Reference
Reference
Also, a here’s
a separate Symantec privilege escalation bug
49
An alternative take on anti-virus software (2)
• For consumers, vendors push software into pre-installed market
with limited “subscription” to updates, fleece buyers into paying for
subscription
▪ Basically, extortion
• Both Windows and Mac have built-in protections now that obviate
this…don’t pay the consumer antivirus mafia.
50
Perimeter scanning
Various approaches to look for malware at network borders:
• Network Intrusion Detection Systems (NIDS): Scanning network
traffic content for malware signatures (covered later in the course)
• Protocol-specific checks. For example, for email:
scanning for malicious attachments, intercepting/blocking email
links, etc.
• Honeypots: Fake targets to attract attackers – can trigger
automated reactions, such as blocking origin traffic
51
Summary
• Methods of infection • Attacker payloads
• Virus • Back door
• Worm • Spyware
• Trojan horse • Zombie/Bot
• Drive-by download • DDOS
• Phishing/Spear phishing • Ransomware
• Clickjacking • Adware
• Exploit • Countering
• Rootkits • Policy
• Attacker types • Awareness
• Includes APTs • Vulnerability mitigation
• Threat mitigation
52