37
CSC 382: Computer Security Slide #1 CSC 382: Computer Security Forensics

CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

Embed Size (px)

Citation preview

Page 1: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #1

CSC 382: Computer Security

Forensics

Page 2: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #2

Computer Forensics

1. Forensic Toolkit

2. Live Data Collection

3. Forensic Duplication

4. Network Data Collection

5. Evidence Handling

6. Disk Data Analysis

7. UNIX Forensics

8. Network Data Analysis

Page 3: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #3

Forensic Toolkit

Forensic investigation required trusted set of tools to collect and analyze data.

Hardware/Media:– CD-ROM containing tools.

– USB drive or floppy for saving collected data.

– Laptop for network data collection and/or saving larger quantities of data.

– Secure data analysis workstation

• Hard drive space for analyzing drive images.

• Drive bays and controllers for analyzing multiple types of hard disks.

Page 4: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #4

Forensic Toolkit Software

bash: known good copy of shell (cmd.exe for Win)dd: create bit level images of disksfind and ls: examine directory listingsifconfig: network configuration (ipconfig for Win)lsmod: list loaded kernel modules (modinfo for Sun)lsof: list open files (and network connections)md5sum: generate/validate file checksumsnetcat or cryptcat: save collected data via networknetstat: collect status of network connectionsps: collect process data (pslist for Win)script: records terminal sessionstrace: system call tracer (truss for Sun)strings: list text strings in binariesvim: edit and/or view binary/text files

Page 5: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #5

Forensic Toolkit Software

Live CD toolkits– FIRE: Forensic & Incident Response Environment– Helix Forensics CD: Contains Sleuthkit.

Specialized Forensics Tools– Sleuthkit (http://www.sleuthkit.org/)

• Includes Autoposy Forensic Browser.

– The Coroner’s Toolkit• http://www.porcupine.org/forensics/tct.html

– Encase• Commercial MS Windows toolkit.

Page 6: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #6

Live Data Collection

• In-memory system state is volatile and must be collected before system is shutdown.

• These types of data will be lost on shutdown:– Running processes.

– Open network connections.

– Deleted binaries whose programs are still executing.

– Deleted files in use by a running program.

• Caveat: Even using tools from CD-ROM will modify system state, both memory (perhaps including swap) and disk files.

Page 7: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #7

Saving Live Data

• Floppy drive– small but ubiquitous.

• USB drive– larger but not on older systems.

• Network storage– Use netcat listener on remote host.

• nc –l –p 2222 >output

– Pipe to netcat on machine you’re investigating:• /mnt/cdrom/bin/date | /mnt/cdrom/bin/nc –w 3 destIP 2222

– Use cryptcat or pipe through DES for security.

Page 8: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #8

Live Data Procedure

1. Mount forensic toolkit media• mount –n /mnt/cdrom

2. Start trusted shell• /mnt/cdrom/bin/bash• export PATH=/mnt/cdrom/bin

3. Record current date• date

4. ARP and route cache tables• arp –an• route -Cn

Page 9: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #9

Live Data Procedure

5. Logged-in users• w

6. File-modification times• atime: ls –alRu / • ctime: ls –clRu /• mtime: ls –alR

7. Open network connections/sniffers• ifconfig -a• netstat –anp

8. Physical memory image• dd if=/proc/kcore | nc remoteIP port

Page 10: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #10

Live Data Procedure

9. Kernel modules and symbols• cat /proc/modules• cat /proc/ksyms• For detecting hidden kernel modules,

• insmod –f /mnt/cdrom/hunter.o• cat /proc/showmodules

10. Process list• ps aux• Memory image of suspicious processes:

• pcat PID or

• kill –STOP PID && gcore –o PID.img PID

Page 11: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #11

Live Data Procedure

11. Record system logs1. utmp: current user access/accounting data

2. wtmp: historical user access/accounting data

3. lastlog: last access/login data

4. syslog files:• /etc/syslog.conf• /var/adm/messages or /var/log/messages

5. Application logs• Shell history files

• Apache access_log• FTP xferlog

Page 12: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #12

Live Data Procedure

12. Save configuration filesAuthentication: /etc/passwd, /etc/shadowScope of access: /etc/groupLocal machines: /etc/hostsTrust relationships: /etc/hosts.equiv,~/.rhostsTCP wrapper rules: /etc/hosts.allow,

/etc/hosts.denySyslog configuration: /etc/syslog.confinetd/xinetd: /etc/inetd.conf,

/etc/xinetd.conf, /etc/xinetd.dStartup files: /etc/inittab, /etc/rc*Scheduled events: /var/spool/cron/*

Page 13: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #13

Live Data Procedure

13. Find deleted fileslsof: list open files

Look for files named only by disk partition.Investigate /proc entries for processes

# ls –al /proc/1403dr-xr-xr-x 3 root root 0 Apr 22 04:09 .dr-xr-xr-x 78 root root 0 Apr 17 13:33 ..dr-xr-xr-x 2 root root 0 Apr 26 19:25 attr-r-------- 1 root root 0 Apr 26 19:25 auxv-r--r--r-- 1 root root 0 Apr 26 19:24 cmdlinelrwxrwxrwx 1 root root 0 Apr 26 19:25 cwd -> /-r-------- 1 root root 0 Apr 26 19:25 environlrwxrwxrwx 1 root root 0 Apr 26 19:25 exe -> /sbin/syslogddr-x------ 2 root root 0 Apr 26 19:25 fd-r-------- 1 root root 0 Apr 26 19:25 maps-rw------- 1 root root 0 Apr 26 19:25 mem-r--r--r-- 1 root root 0 Apr 26 19:25 mountslrwxrwxrwx 1 root root 0 Apr 26 19:25 root -> /-r--r--r-- 1 root root 0 Apr 26 19:24 stat-r--r--r-- 1 root root 0 Apr 26 19:25 statm-r--r--r-- 1 root root 0 Apr 26 19:24 statusdr-xr-xr-x 3 root root 0 Apr 26 19:25 task-r--r--r-- 1 root root 0 Apr 26 19:25 wchan

Page 14: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #14

Live Data Procedure

13. Find deleted files (continued)exe link points to binary image file for process

Can access binary via link even if file deletedcmdline file contains command line args

cat cmdlinefd directory lists all open files by file descriptor

> ls -al fdtotal 7dr-x------ 2 root root 0 Apr 26 19:25 .dr-xr-xr-x 3 root root 0 Apr 22 04:09 ..lrwx------ 1 root root 64 Apr 26 19:25 0 -> socket:[2715]l-wx------ 1 root root 64 Apr 26 19:25 2 -> /var/log/messagesl-wx------ 1 root root 64 Apr 26 19:25 3 -> /var/log/securel-wx------ 1 root root 64 Apr 26 19:25 4 -> /var/log/maillogl-wx------ 1 root root 64 Apr 26 19:25 5 -> /var/log/cronl-wx------ 1 root root 64 Apr 26 19:25 6 -> /var/log/spoolerl-wx------ 1 root root 64 Apr 26 19:25 7 -> /var/log/boot.log

Page 15: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #15

Live Data Procedure

14. Record completion date.

15. Record your actions.history will list all of your commands

script command will record all keystrokes and output of commandsscript /mnt/floppy/log.txt

16. Record secure checksums on filesmd5sum * >md5sums.txt

Page 16: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #16

Forensic Duplication

Forensic Duplicate: File that contains every bit of information from source.

Qualified Forensic Duplicate: A file or set of files that contains every bit of information in source, but which may be stored in altered format.– checksums

– compression

Restored Image: The result of restoring a qualified forensic duplicate to another medium.– Problems: Different drive geometries, partition tables.

Page 17: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #17

Forensic Duplication

• Compare and record data checksum– md5sum /dev/hda == md5sum hda.img

• Duplicating a drive to local media– dd if=/dev/hda of=/mnt/disk/hda.img conv=noerror,notrunc bs=16384

• Duplicating a drive across the network– dd if=/dev/had conv=noerror,sync | des –e –c –k password | nc –w 3 targetIP 2222

– nc –l –p 2222 | des –d –c –k password | dd of=hda.img

Page 18: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #18

Forensic Duplication

Duplicating a drive to multiple files#!/bin/bashblocksz=20480klet count=1while(dd if=/dev/hda of=/mnt/disk/hda.$count.img bs=$blocksz skip=($($count-1)) conv=noerror,notrunc)

do echo “Block $count output.”

count=$((count+1))done

Page 19: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #19

Network Data Collection

• Goals– Monitor specific host/network.– Monitor specific protocol.– Monitor specific person’s actions.– Check for known attack signatures.

• Where to monitor?– Need physical access to appropriate network.– Many switches offer SPAN (switched port

analysis), providing a network monitor port.

Page 20: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #20

Network Data Collection Hardware

Fast networks require much CPU/RAM to monitor all packets.– Pentium4/512MB/striped disk for heavily used

100Mbps network.– Special purpose network monitors for faster networks.

Silent Sniffers – Configure interface without IP address to monitor while

not being scannable.• Turn off ARP responses (ifconfig –arp eth0 up)• Unbind NetBIOS and IPX protocols on MSWindows.

– Construct a read-only ethernet tap cable by cutting transmit wires on cable for maximum stealth.

Page 21: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #21

Network Data Collection Software

• Robust, configurable OS• Data file formats

– libpcap: tcpdump, Ethereal, Snort– Sun snoop

• Monitoring with tcpdump– May filter by src/dest IP address and/or port.– Traffic patterns

•tcpdump –n –w log.pcap

– Full-content:•tcpdump –n –s 1514 –w log.pcap

Page 22: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #22

Evidence Handling

Original Evidence: original copy of evidence provided for client/victim.

Best Evidence: duplication of evidence most closely linked to original evidence.

Authentication of Evidence: testimony of evidence collector in court that evidence is what the proponent claims.

Page 23: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #23

Evidence Handling

Chain of Custody– Evidence must be stored in tamperproof

manner, where it cannot be accessed by unauthorized people.

– Requirements:• Know location of evidence at all times.• Maintain custody of keys/passwords for access.• Document all receipts and transfers of evidence.• Provide testimony to defend evidence handling.• Secure checksums of all files to validate that best

evidence matches original evidence.

Page 24: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #24

Evidence Handling Procedures1. Record information about original system.

– Include photographs of system and media.2. Create evidence tag for evidence stored.3. Label all media with evidence label.

– Case number and evidence tag number.– Timestamp and description of contents.

4. Store best evidence copy in evidence safe.5. Evidence custodian records entry in log.6. All examinations performed on forensic copy of

best evidence.7. Evidence custodian responsible for backups and

audits of contents of evidence safe.

Page 25: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #25

Evidence Tags

• Description of place and/or persons from whom evidence was received.

• Description of item and data contained.• Timestamp of when evidence received.• Full name and signature of individual receiving

evidence.• Case and tag number related to evidence.• Record of all people who have possessed the

evidence, including names, timestamps, and reasons why evidence was transferred.

Page 26: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #26

Disk Data Analysis

Use Linux analysis system– Support for wide range of filesystems: FAT12,

FAT16, FAT32, NTFS, HFS+, FFS, UFS

Mount read-only partition image via loopback device:– mount –r –t ntfs –o loop /mnt/evi hda1.img

Examine mounted image with standard UNIX tools.

Page 27: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #27

Disk Data Analysis

Mount read-only full disk image via loopback:– Install NASA enhanced loopback patches.– losetup /dev/loopa hda.img– fdisk –l /dev/loopaDisk /dev/loopa: 255 heads, 63 sectors, 592 cylinders

Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/loopa1 *63 7438094 3719016 7 HPFS/NTFS /dev/loopa2 7438095 9510479 1036192+ 5 Extended

/dev/loopa5 7438158 7695134 128488+ 82 Lin swap – mount –r –t vfat /dev/loopa1 /mnt/evi

Page 28: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #28

Recovering Deleted Files

Linux Tools– fatback

• FAT/VFAT filesystem undelete by name.

– foremost• Recovers files based on header/footer tags.

– Sleuthkit TASK• FAT/BSD/Linux/UFS filesystems.

• Autopsy GUI forensic browser.

Page 29: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #29

Recovering Unused Space

Types of Unused Space– Unallocated space

• Disk blocks not currently allocated to any files.

– Slack space• Portions of disk blocks currently used by file.

– Free space• Portion of disk unused by any current partition.

Page 30: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #30

File Lists

Create list of all files – Full path– All timestamps (atime, ctime, mtime on UNIX)– Logical file size– Cryptographic checksum of file

Tool: CATALOG –p /mnt/loopa1

Compare checksums against known good checksums of OS distribution to find altered files.

Page 31: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #31

Identify suspicious files

New SUID files– find /mnt/evi \(–perm –0400 –o – perm –0200 \) –print

Files with no owner– find /mnt/evi –nouser –o –nogroup

Core files may reveal attacker programs– find /mnt/evi –name core –print

Page 32: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #32

String Searches

Preparations– Recover deleted files.– Recursively uncompress/decrypt files as needed.

Using GNU grep– grep –a –i -# –f search /dev/hda >results

– -a: search binary files– -i: case insensitive– -#: lines of context before/after match– -f: search file contains list of regular expressions

Page 33: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #33

UNIX Forensics

1. Review log files2. Keyword searches of disk image3. Review configuration files4. Identify unauthorized users/groups5. Identify suspicious files6. Identify suspicious processes7. Check for backdoors8. Analyze trust relationships9. Check for kernel rootkits

Page 34: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #34

Network Data Analysis

tcptrace– Reconstructs UDP/TCP sessions from packet

capture files.

tcpflow– Reassembles TCP sessions correctly (deals with

out of sequence packets and retransmissions.)

snort– Identifies known attack signatures in pcap files.

Page 35: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #35

Network Data Analysis

Ethereal– Reads many different packet capture formats.– View filters for colorizing packet display.– “Follow TCP Stream”

• Select one packet from a TCP session.

• Display and/or save single TCP session.

• Reconstruct files transferred via TCP file transfer protocols.

Page 36: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #36

Key Points

• Don’t trust the system being investigated.

• Document all of your actions.

• Collect as much data as possible without modifying system state.

• Cryptographically sign all digital data so copies can be verified to match originals.

• Forensic duplication and restoration process.

• Network capture and analysis tools.

Page 37: CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Forensics

CSC 382: Computer Security Slide #37

References1. Matt Bishop, Introduction to Computer Security, Addison-Wesley, 2005.2. N. Brownlee and E. Guttman, , “RFC 2350 - Expectations for Computer Security Incident

Response,” http://www.faqs.org/rfcs/rfc2350.html, 1998.3. Mariusz Burdach, “Forensic Analysis of a Live Linux System, Part One,”

http://www.securityfocus.com/infocus/1769, March 2004.4. Mariusz Burdach, “Forensic Analysis of a Live Linux System, Part Two,”

http://www.securityfocus.com/infocus/1773, April 2004.5. Brian Carrier, Sleuthkit Informer #11,

http://sleuthkit.sourceforge.net/informer/sleuthkit-informer-11.html, December 2003.6. CERT, “Computer Security Incident Response Team (CSIRT) FAQ,”

http://www.cert.org/csirts/csirt_faq.html7. William Cheswick, Steven Bellovin, Steven, and Avriel Rubin, Firewalls and Internet

Security, 2nd edition, Addison-Wesley, 2003.8. Dan Farmer and Wietse Venema, Forensic Discovery, Addison-Wesley, 2004.9. Fraser (ed.), “RFC 2196 - Site Security Handbook,”

http://www.faqs.org/rfcs/rfc2196.html, 1997.10. Garfinkel, Simson, Spafford, Gene, and Schartz, Alan, Practical UNIX and Internet

Security, 3rd edition, O’Reilly & Associates, 2003.11. Kevin Mandia, Chris Prosise, and Matt Pepe, Incident Response & Computer Forensics,

2nd edition, McGraw-Hill, 2003.