Lecture 3-CSS
Lecture 3-CSS
Intrusion
Mohit Agarwal
ABES Engineering College
Courtesy: Dr. Sandeep K. Shukla, IITK
Acknowledgements
• Dan Boneh (Stanford University)
• John C. Mitchell (Stanford University)
• Nicolai Zeldovich (MIT)
• Jungmin Park (Virginia Tech)
• Patrick Schaumont (Virginia Tech)
• C. Edward Chow
• Arun Hodigere
• Web Resources
Lecture 3: Subverting Isolation, Rootkits, and
Intrusion
• Module 3.1: VM based Isolation
– Module 3.1.1 Subversion
• Module 3.2: Confinement Principle
• Module 3.3: Software Fault Isolation
• Module 3.4: Rootkits
– Module 3.4.1 – Rootkit Basics
– Module 3.4.2 – Rootkit Types
– Module 3.4.3 – Rootkit Detection
• Module 3.5: IDS – Intrusion Detection Systems
– Module 3.5.1 – Commercial IDS
Module 3.1
Isolation via Virtual Machines &
Subversion
Isolation
Isolation via
Virtual Machines
Virtual Machines
VM2 VM1
Apps Apps
Guest OS 2 Guest OS 1
Virtual Machine Monitor (VMM)
Host OS
Hardware
Example: NSA NetTop
single HW platform used for both classified and unclassified data
Why so popular now?
VMs in the 1960’s:
– Few computers, lots of users
– VMs allow many users to shares a single computer
Classified VM Public VM
malware
secret
covert
doc listener
channel
VMM
An example covert channel
Both VMs use the same underlying hardware
malware Guest OS
IDS VMM
Hardware
Sample checks
Stealth root-kit malware:
– Creates processes that are invisible to “ps”
– Opens sockets that are invisible to “netstat”
Subverting VM Isolation
Subvirt [King et al. 2006]
Virus idea:
– Once on victim machine, install a malicious VMM
– Virus hides in VMM
– Invisible to virus detector running inside VM
anti- s
anti-
viru
OS
s
viru
OS VMM and
HW virus
HW
The MATRIX
VM Based Malware (blue pill virus)
• VMBR: a virus that installs a malicious VMM (hypervisor)
Applications:
– Virus detector can detect VMBR
Software Fault
Isolation
Software Fault Isolation [Whabe et al., 1993]
app #1 app #2
jmp guard must ensure [addr] does not bypass load guard
Cross domain calls
caller callee
domain domain
call stub draw:
call draw
return
br addr br addr
br addr ret stub br addr
br addr br addr
Slide #41
Rootkit Goals
1. Remove evidence of original attack and activity that led to
rootkit installation.
2. Hide future attacker activity (files, network connections,
processes) and prevent it from being logged.
3. Enable future access to system by attacker.
4. Install tools to widen scope of penetration.
5. Secure system so other attackers can’t take control of
system from original attacker.
Slide #42
Concealment Techniques
• Remove log and audit file entries.
• Modify system programs to hide attacker files, network
connections, and processes.
• Modify logging system to not log attacker activities.
• Modify OS kernel system calls to hide attacker activities.
Slide #43
Installation Concealment
• Use a subdirectory of a busy system directory like /dev, /etc,
/lib, or /usr/lib
• Use dot files, which aren’t in ls output.
• Use spaces to make filenames look like expected dot files: “. “
and “.. “
• Use filenames that system might use
– /dev/hdd (if no 4th IDE disk exists)
– /usr/lib/libX.a (libX11 is real Sun X-Windows)
• Delete rootkit install directory once installation is complete.
Slide #44
Attack Tools
• Network sniffer
– Including password grabber utility
• Password cracker
• Vulnerability scanners
• Autorooter
– Automatically applies exploits to host ranges
• DDOS tools
Slide #45
History of Rootkits
1989: Phrack 25 Black Tie Affair: wtmp wiping.
1994: Advisory CA-1994-01 about SunOS rootkits.
1996: Linux Rootkits (lrk3 released.)
1997: Phrack 51 halflife article: LKM-based
rootkits
1998: Silvio Cesare’s kernel patching via kmem.
1999: Greg Hoglund’s NT kernel rootkit paper
Slide #46
History of Rootkits
2005: Sony ships CDs with rootkits that hide DRM and spyware
that auto-installs when CD played.
2006: SubVirt rootkit moves real OS to a VM.
Slide #47
Module 3.4.2
Types of Rootkits
Rootkit Types
User-mode Rootkits
– Binary Rootkits replace user programs.
• Trojans: ls, netstat, ps
• Trojan backdoors: login, sshd.
– Library Rootkits replace system libraries.
• Intercept lib calls to hide activities and add backdoors.
Kernel Rootkits
– Modify system calls/structures that all user-mode programs rely on
to list users, processes, and sockets.
– Add backdoors to kernel itself.
Slide #49
Binary Rootkits
• Install trojan-horse versions of common system commands, such as ls,
netstat, and ps to hide attacker activities..
• Install programs to edit attacker activity from log and accounting files.
• Install trojan-horse variants of common programs like login, passwd, and
sshd to allow attacker continued access to system.
• Install network sniffers.
Slide #50
Linux Root Kit (LRK) v4 Features
chsh Trojaned! User->r00t
cronta Trojaned! Hidden Crontab Entries
b du Trojaned! Hide files
fix File fixer!
ifconfig Trojaned! Hide
inetd sniffing
linsniffer Trojaned! Remote access
login Packet sniffer!
ls Trojaned!
netstat Remote access
passwd Trojaned! Hide files
ps Trojaned! Hide
rshd connections
sniffchk Trojaned! User->r00t
syslogd Trojaned! Hide processes
tcpd Trojaned! Remote access
top Program to check if sniffer is up and running
wted Trojaned! Hide logs
z2 Trojaned! Hide connections, avoid denies
Trojaned! Hide processes
wtmp/utmp editor!
Zap2 utmp/wtmp/lastlog eraser! Slide #51
Linux Root Kit (LRK) v4 Trojans
ifconfig – Doesn’t display PROMISC flag when sniffing.
login – Allows login to any account with the rootkit password. If root login is
refused on your terminal login as "rewt". Disables history logging when
backdoor is used.
ls – Hides files listed in /dev/ptyr. All files shown with 'ls -/' if SHOWFLAG
enabled.
passwd – Enter your rootkit password instead of old password to become
root.
ps – Hides processes listed in /dev/ptyp.
rshd – Execute remote commands as root: rsh -l rootkitpassword host command
syslogd – Removes log entries matching strings listed in /dev/ptys.
Slide #54
Kernel Rootkits
Kernel runs in supervisor processor mode
– Complete control over machine.
Rootkits modify kernel system calls
– execve modified to run Trojan horse binary for some programs,
while other system calls used by integrity checkers read original
binary file.
– setuid modified to give root to a certain user.
Advantage—Stealth
– Runtime integrity checkers cannot see rootkit changes.
– All programs impacted by kernel Trojan horse.
– Open backdoors/sniff network without running processes.
Slide #55
Types of Kernel Rootkits
Loadable Kernel Modules
– Device drivers are LKMs.
– Can be defeated by disabling LKMs.
– ex: Adore, Knark
Alter running kernel in memory.
– Modify /dev/kmem directly.
– ex: SucKit
Alter kernel on disk.
Slide #56
Kernel Rootkit Detection
List kernel modules
– lsmod
– cat /proc/modules
Examine kernel symbols (/proc/kallsyms)
– Module name listed in [] after symbol name.
Slide #57
Kernel Rootkit Detection
Check system call addresses
– Compare running kernel syscall addresses with those
listed in
System.map generated at kernel compile.
All of these signatures can be hidden/forged.
Slide #58
Knark
• Linux-based LKM rootkit
• Features
– Hide/unhide files or directories
– Hide TCP or UDP connections
– Execution redirection
– Unauthenticated privilege escalation
– Utility to change UID/GID of a running process.
– Unauthenticated, privileged remote execution daemon.
– Kill –31 to hide a running process.
• modhide: assistant LKM that hides Knark from module listing attempts.
Slide #59
Module 3.4.3
Rootkit Detection
Rootkit Detection
Offline system examination
– Mount and examine disk using another OS kernel+image.
– Knoppix: live CD linux distribution.
Computer Forensics
– Examine disk below filesystem level.
– Helix: live CD linux forensics tool.
Slide #61
Rootkit Detection Utilities
chkrootkit
– Detects >50 rootkits on multiple UNIX types.
– Checks commonly trojaned binaries.
– Examines log files for modifications.
– Checks for LKM rootkits.
– Use –p option to use known safe binaries from CDROM.
carbonite
– LKM that searches for rootkits in kernel.
– Generates and searches frozen image kernel process structures.
Slide #62
Detection Countermeasures
• Hide rootkit in unused sectors or in unused fragments of used sectors.
• Install rootkit into flash memory like PC BIOS, ensuring that rootkit persists
even after disk formatting and OS re-installation.
Slide #63
Rootkit Recovery
• Restore compromised programs from backup
– Lose evidence of intrusion.
– Did you find all the trojans?
• Backup system, then restore from tape
– Save image of hard disk for investigation.
– Restore known safe image to be sure that all trojans have been
eliminated.
– Patch system to repair exploited vulnerability.
Slide #64
Key Points
• Backdoors allow intruder into system without using exploit
again.
• Rootkits automatically deeply compromise a system once
root access is attained.
• Rootkits are easy to use, difficult to detect.
• Don’t trust anything on a compromised system—access disk
from a known safe system, like a Knoppix CD.
• Recovery requires a full re-installation of the OS and
restoration of files from a known good backup.
Slide #65
References
1. Oktay Altunergil, “Scanning for Rootkits,” http://www.linuxdevcenter.com/pub/a/linux/2002/02/07/rootkits.html, 2002.
2. Silvio Cesare, “Runtime kernel kmem patching,” http://vx.netlux.org/lib/vsc07.html, 1998.
3. William Cheswick, Steven Bellovin, and Avriel Rubin, Firewalls and Internet Security, 2nd edition, 2003.
4. Anton Chuvakin, “An Overview of UNIX Rootkits,” iDEFENSE whitepaper, 2003.
5. Dave Dittrich, “Rootkits FAQ,” http://staff.washington.edu/dittrich/misc/faqs/rootkits.faq, 2002.
6. Greg Hoglund and Gary McGraw, Exploiting Software: How to Break Code, Addison-Wesley, 2004.
7. Samuel T. King et. al., “SubVirt: Implementing malware with virtual machines”,
http://www.eecs.umich.edu/virtual/papers/king06.pdf, 2006.
8. McClure, Stuart, Scambray, Joel, Kurtz, George, Hacking Exposed, 3rd edition, McGraw-Hill, 2001.
9. Peikari, Cyrus and Chuvakin, Anton, Security Warrior, O’Reilly & Associates, 2003.
10. pragmatic, (nearly) Complete Loadable Linux Kernel Modules, http://www.thc.org/papers/LKM_HACKING.html, 1999.
11. Marc Russinovich, “Sony, Rootkits and Digital Rights Management Gone Too Far,”
http://blogs.technet.com/markrussinovich/archive/2005/10/31/sony-rootkits-and-digital-rights-management-gone-too-
far.aspx
12. Jennifer Rutkowska, “Red Pill: or how to detect VMM using (almost) one CPU instruction,”
http://www.invisiblethings.org/papers/redpill.html, 2004.
13. Ed Skoudis, Counter Hack Reloaded, Prentice Hall, 2006.
14. Ed Skoudis and Lenny Zeltser, Malware: Fighting Malicious Code, Prentice Hall, 2003.
15. Ranier Wichman, “Linux Kernel Rootkits,” http://la-samhna.de/library/rootkits/index.html, 2002.
Slide #66
Module 3.5
Intrusion and Intrusion Detection
Intrusion Detection Systems (IDS)
Another Digression
Intrusion and Intrusion Detection
• Intrusion : Attempting to break into or misuse your system.
• Intruders may be from outside the network or legitimate
users of the network.
• Intrusion can be a physical, system or remote intrusion.
Different ways to intrude
• Buffer overflows
• Unexpected combinations
• Unhandled input
• Race conditions
Intrusion Detection Systems (IDS)
Signature Based:
Intrusion Detection Systems look for attack signatures, which
are specific patterns that usually indicate malicious or
suspicious intent.
Packet Stream
Network
Bro - libpcap
• It’s the packet capture library used by tcpdump.
• Isolates Bro from details of the network link technology.
• Filters the incoming packet stream from the network to
extract the required packets.
• E.g port finger, port ftp, tcp port 113 (Ident), port telnet,
port login, port 111 (Portmapper).
• Can also capture packets with the SYN, FIN, or RST
Control bits set.
Bro – Event Engine
• The filtered packet stream from the libpcap is handed
over to the Event Engine.
• Performs several integrity checks to assure that the
packet headers are well formed.
• It looks up the connection state associated with the tuple
of the two IP addresses and the two TCP or UDP port
numbers.
• It then dispatches the packet to a handler for the
corresponding connection.
Bro – TCP Handler
• For each TCP packet, the connection handler verifies that the entire TCP
Header is present and validates the TCP checksum.
• If successful, it then tests whether the TCP header includes any of the
SYN/FIN/RST control flags and adjusts the connection’s state
accordingly.
• Different changes in the connection’s state generate different events.
Policy Script Interpreter
• The policy script interpreter receives the events generated by the Event
Engine.
• It then executes scripts written in the Bro language which generates
events like logging real-time notifications, recording data to disk or
modifying internal state.
• Adding new functionality to Bro consists of adding a new protocol analyzer
to the event engine and then writing new events handlers in the
interpreter.
Future of IDS
• To integrate the network and host based IDS for better
detection.
• Developing IDS schemes for detecting novel attacks rather
than individual instantiations.
Lecture 3: Summary
• Module 3.1: VM based Isolation
– Module 3.1.1 Subversion
• Module 3.2: Confinement Principle
• Module 3.3: Software Fault Isolation
• Module 3.4: Rootkits
– Module 3.4.1 – Rootkit Basics
– Module 3.4.2 – Rootkit Types
– Module 3.4.3 – Rootkit Detection
• Module 3.5: IDS – Intrusion Detection Systems
– Module 3.5.1 – Commercial IDS