Top Banner
1 Unix/Linux Forensics
57

Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

Mar 21, 2018

Download

Documents

lyliem
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

1

Unix/Linux Forensics

Page 2: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

2

Simple Linux Commands

• date – display the date• ls – list the files in the current directory• more – display files one screen at a time• cat – display the contents of a file• wc – displays lines, words, and characters• cp, mv, rm, pwd, mkdir, cd, rmdir, chmod, • head – show the first few lines of a file• file – determine a file type• tail – show the last few lines of a file• cal – display calendar• kill – terminate a running command• lpr – send a job to the printer• grep – searches a file for a specific pattern• chmod – change file permissions• fdisk• mount, cat /etc/fstab• last• ….

Page 3: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

3

Basic Concepts

• shell• shell scripts• background and foreground

– &– Ctrl-Z, bg, fg, jobs

• Environment variables– env

• passwd

Page 4: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

4

The Linux Filesystem Layout

• The basic layout of the filesystem starts with the root directory.–root directory : this is the base of the file system's tree structure. –/bin : binary files for the OS–/dev : the device files–/etc : system configuration files –/sbin: system administrative binaries–/home : conventional location for users’ home directories. –lost+found : storage for recovered files

Page 5: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

5

Commonly used command/concepts

• mount/umount• ls: different options• ln• df• tree• chmod, chown, chgrp• find• tar• gzip• dd• stat

Page 6: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

6

Commonly used command/concepts

• cksum– checksum and count the bytes in a file

• sum– checksum and count the blocks in a file

• diff– Provide a list of each line that differs

• strings

Page 7: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

7

Commonly used command/concepts

• Every file is managed by a data structure called an inode– File location and size– Owner, permission, – Time of creation, time of last access, time of last

modification– stat

• SUID root– Set user ID

Page 8: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

8

Ext2 Inode

http://www.tldp.org/LDP/tlk/fs/filesystem.html

Page 9: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

9

Network Information System

/etc/nsswitch.confyppasswd

Page 10: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

10

Shared System Files

Page 11: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

11

Four basic steps

• Collect• Preserve• Analyze• Present (report)

Page 12: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

12

Investigating A Unix Host

• Filesystem integrity-checking program– Tripwire: http://sourceforge.net/projects/tripwire/

• TCT– Examining hacked Unix systems– http://www.porcupine.org/forensics/tct.html

• netcat

Page 13: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

13

Order of Volatility

• The more volatile the data is, the more difficult it is to capture, and the less time you have to do it.

• The descending order:– CPU storage– System storage– Kernel Tables– Fixed media– Removable media– Paper printouts

• Table 11-4

Page 14: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

14

TCT (1)

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

• Mostly perl but some C as well• A STATIC tool!

– e.g. changes to filesystem during analysis will NOT be noticed by TCT

– You MUST isolate the system under investigation

Page 15: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

15

TCT (2)

• Four major parts:– grave-robber: captures forensics data– The C-tools (ils, icat, pcat, file, etc)

• pcat – low-level memory utilities: copy process memory– pcat PID

• file: determine file type• icat: copies files by inode number• ils: list inode info (usually removed files)

– lazarus• Lazarus: create structure from unstructured data

– mactime• Report on times of files

Page 16: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

16

The C-tools (ils, icat, pcat, file, etc)

• pcat – gathers process memory from live system

• ils – gathers inode information– ./ils /dev/sda6

• icat – copy files using inode information to standard out– ./icat /dev/sda6 1405802 (you can use stat to obtain

the inode number)• file – determine file system type

Page 17: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

17

lazarus

• Lazarus – classify raw information for analyzing (brings back info from the dead) – Unallocated datablocks with no referent inode

Page 18: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

18

mactime

• Three times on ext f/sys:– Modification time– Access time– Change time

• collects information on all three times for specific files– ./mactime -d /root/download/tct-1.16/bin -y

9/29/2006

Page 19: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

19

Be nice to your MAC times

• MAC times are sensitive (to changes within the system)

• Running a single command may change last Access time of a file

• Should grab MACtime info before running any further commands on system.

• You’ll use this info to create a timeline of activity.

Page 20: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

20

Sleuth kit

• Expands TCT data • Provides low- and high-level access to Xnix

and Windows f/systems.

Page 21: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

21

The Sleuth KitFile system tools

• File System Category• Content Category

– dls –f ext –e –l sda6.img» a: the data unit is allocated» f: the data unit is unallocated

– dcat –f ext sda6.img 23456» View the contents of any data unit

• Metadata category» Include data that describe a file: for example, temporal

information, the addresses of the data units, the size of the file.

» istat –f ext sda6.img 163199 - to get the specific metadata entry

» ils –f ext –e sda6.img - list the details of several metadata structures

» icat –f ext sda6.ima 31 - View the contents of the file based on metadata address instead of its file name

Page 22: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

22

The Sleuth Kit

• File Name Category» Includes the data that associates a name with a metadata entry» fls: list file names in a given directory» ffind: list which file name corresponds to a given metadata

address• Application Category

» A file system journal records updates to the file system so thatthe file system can be recovered more quickly after a crash

» jls – list the contents of the journal and show which file system blocks are saved in the journal blocks

• Multiple category» mactime: takes temporal data from fls and ils to produce a

timeline of file activity

Page 23: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

23

The Sleuth Kit

– Searching tools• sigfind – find binary signature in a file

– Disk tools• disk_stat

– Volume system tools

Page 24: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

24

Autopsy

• Developed to automate the investigation process when TSK is being used

• http://www.sleuthkit.org/autopsy/

Page 25: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

25

Capture Filesystem• Imaging utilities

– Wipe out analysis drive• dd if=/dev/zero of=/dev/fd0

– One more example• nc –l –p 10001 > syspect.hdb5.image.1of3&• nc –l –p 10002 > syspect.hdb5.image.2of3&• nc –l –p 10003 > syspect.hdb5.image.3of3&

• dd if =/dev/hdb5 count 2000000 bs=1024 | nc 192.168.0.4 10001 –w 3

• dd if =/dev/hdb5 skip 2000000 count 2000000 bs=1024 | nc192.168.0.4 10002 –w 3

• dd if =/dev/hdb5 skip 4000000 count 2000000 bs=1024 | nc192.168.0.4 10003 –w 3

• cat suspect.image1.10f3 >> suspect.hdb5.image• cat suspect.image2.2of3 >> suspect.hdb5.image• cat suspect.image3.3of3 >> suspect.hdb5.image

Page 26: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

26

md5

• Create the hash value of collected data and record it– md5 from tct: md5 /dev/sda6– Verify the image file on the collection host

Page 27: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

27

Accessing Captured Filesystems for Examination

• Copy the image into a partition that is the same size as the image (partition cleaned using dd)

• Another approach– mkdir /mnt/suspecthost– mount –t ext2 –o ro, loop=/dev/loop0

suspect.hdb5.image /mnt/suspecthost– Treat it like any other filesystem

Page 28: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

28

logs

• /etc/syslog.conf

Page 29: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

29

logs

Page 30: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

30

logs

• /var/log/secure– authpriv.*

• HTTP– /var/log/httpd/*: grep passwd /var/log/httpd/*

Page 31: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

31

Examine Account Information

Page 32: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

32

Trust Relationship Configuration Files

Page 33: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

33

Invisible Files and Directories

• Find invisible files and directories– find . –type d –name “.*” –print0 | cat –a

• Search SUID root executables– find / -user root –perm -4000 –print0 | xargs -0 ls

-l• Search SGID programs

– find / -perm -2000 –print0 | xargs -0 ls -l

Page 34: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

34

Signs of Intrusion in /tmp

Page 35: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

35

Verifying crontab and at jobs

Page 36: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

36

Signs that an Executable File Deserves a Closer Look

Page 37: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

37

Shell and Application History

• sh– .sh_history

• csh– .history

• ksh– .sh_history

• bash– .bash_history

• tcsh– .history

Page 38: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

38

Signs of Hostile Processes

Page 39: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

39

Levels of System Compromise

Page 40: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

40

RootKit

• http://www.securityfocus.com/infocus/1811• Increase privileges• Hide activities

– To manipulate the environment and hide evidence

• Gather information– To extend attacks

• One example– Loadable kernel modules (LKM)– http://www.s0ftpj.org/docs/lkm.htm

Page 41: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

41

RootKit Content

Page 42: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

42

RootKit Content

Page 43: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

43

RootKit Content

Page 44: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

44

RootKit Content

Page 45: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

45

RootKit Content

Page 46: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

46

RootKit Content

Page 47: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

47

RootKit Content

Page 48: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

48

KSTAT Utility

•Kstat –s: display the system call table

Page 49: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

49

Detecting Trojan LKMs on Live System

• Detecting trojan LKMs on a live system– Complicated– These tools intercept system calls.

• Port 2222 is open – default Adore LKM port

Page 50: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

50

Miscellaneous

• To determine listing applications associated with open ports– netstat –anp

• To determine whether a sniffer is running on a system (promiscuous mode)– ifconfig eth0

• /proc– fd subdirectory: all the files a process has opened– cmdfile: the command-line argument

Page 51: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

51

Miscellaneous

• lsof (list open files)– Lists processes with all their open files, network

ports, current directories, and other file system-related information

– An open file can be a regular file, a directory, a library, a stream, or a network socket.

– Example:• For root user: lsof –p PID_of_SSHD• lsof –i: show all processes with active network ports

Page 52: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

52

Miscellaneous• ltrace

– Library call monitoring programs– ltrace date > /dev/null

• Show fragment of a library-call trace of the date command

• strace– System call monitoring– strace date > /dev/null

• sysctl– Read/Write access to kernel configuration parameters and

other data– sysctl -a

Page 53: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

53

Prepare Analysis Machines

• Boot into Knoppix-STD (or your favorite Linux OS with all the right tools)

• http://en.wikipedia.org/wiki/Knoppix_STD

Page 54: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

54

A Summary of the Steps in a Unix Investigation

• Review all pertinent logs• Perform keyword searches• Review relevant files• Identify unauthorized user accounts or groups• Identify rogue processes• Check for unauthorized access points• Analyze trust relationships• Check for kernel module rootkits

Page 55: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

55

Compromising a Unix Host

Page 56: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

56

Typical Attack Host Exploits

Page 57: Unix/Linux Forensics - Lamar Universitygalaxy.cs.lamar.edu/~bsun/forensics/slides/unix_linux_forensics.pdf · Unix/Linux Forensics. 2 Simple Linux Commands • date ... The Linux

57

Attack Steps• Target Identification• Intelligence Gathering

– Password sniffing and guessing– Compromise network service

• Initial Compromise• Privilege Escalation

– Gain root access• Reconnaissance

– Attackers perform their own forensic examination– Look for security programs– Analyze system and user activities

• Covering the Tracks– System that is owned

• Gain administrative access, clean the tracks, and prepare a returned path