CSN08101 Digital Forensics Lecture 4: System Level Disk Control Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak.

Slides:



Advertisements
Similar presentations
Chapter 9 Part III Linux File System Administration
Advertisements

1 Week 11 FAT32 Boot Sector, Locating Files and Dirs Classes COP4610 / CGS5765 Florida State University.
Linux can be generally divided into four major components: 1. KERNEL – OS, ultimate boss The kernel is the core program that runs programs and manages.
MODULE 4 File and Folder Management. Creating file and folder A computer file is a resource for storing information, which is available to a computer.
File System Analysis.
File Management and Storage Devices. Floppy Disk Drive ► A floppy drive (normally designated as the "A" drive). ► A floppy drive (normally designated.
1 An Introduction to IBM SPSS PSY450 Experimental Psychology Dr. Dwight Hennessy.
Introduction to Unix (CA263) File System
Exploring the UNIX File System and File Security
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
GNU/Linux Filesystem 1 st AUT GNU/Linux Festival Computer Engineering & IT Department Bahador Bakhshi.
Operating Systems File systems
Guide To UNIX Using Linux Third Edition
Format Scandisk Defragmentation Antivirus Compression Software
Introduction to Unix – CS 21 Lecture 5. Lecture Overview Lab Review Useful commands that will illustrate today’s lecture Streams of input and output File.
Week 10 Project 3: An Introduction to File Systems
Chapter 10 File System Interface
Guide To UNIX Using Linux Fourth Edition
Linux Installation and Administration – Lesson 5 Tutor: George Papamarkos Topic: Devices in Linux.
LIS508 lecture 5: storage devices Thomas Krichel
1 Day 3 Directories Files Moving & Copying. 2 Case Sensitive First thing to learn about UNIX is that everything is case sensitive. Thus the files: –enda.
F8-Noncommercial-Based Forensic Duplications Dr. John P. Abraham Professor UTPA.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Guide to Linux Installation and Administration, 2e1 Chapter 3 Installing Linux.
CSN08101 Digital Forensics Lecture 1B: Essential Linux and Caine Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak.
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
1 Project 3: An Introduction to File Systems CS3430 Operating Systems University of Northern Iowa.
Component 4: Introduction to Information and Computer Science Unit 4: Application and System Software Lecture 3 This material was developed by Oregon Health.
PC Maintenance: Preparing for A+ Certification Chapter 10: Introduction to Disk Storage.
Chapter 6: Linux Filesystem Administration
Chapter Two Exploring the UNIX File System and File Security.
1 Interface Two most common types of interfaces –SCSI: Small Computer Systems Interface (servers and high-performance desktops) –IDE/ATA: Integrated Drive.
File I/O Static void Main( ) {... } data. Topics I/O Streams Reading and Writing Text Files Formatting Text Files Handling Stream Errors File Pointers.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
CSN08101 Digital Forensics Lecture 5: Data management and Autopsy Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak.
File System Interface. File Concept Access Methods Directory Structure File-System Mounting File Sharing (skip)‏ File Protection.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
Lesson 12: Using the Recycle Bin deleting files or folders what the Recycle Bin is restoring files from the Recycle Bin emptying the Recycle Bin identifying.
Hands On UNIX II Dorcas Muthoni. Processes A running instance of a program is called a "process" Identified by a numeric process id (pid)‏  unique while.
Manage Directories and Files in Linux. 2 Objectives Understand the Filesystem Hierarchy Standard (FHS) Identify File Types in the Linux System Change.
Chapter Two Exploring the UNIX File System and File Security.
CIS Lesson 5 Lesson 5 New Skills Boot time GRUB edits (review) Changing BIOS boot order on a VM (review) Mounting CD ISO and floppy Image files on.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
What is a port The Ports Collection is essentially a set of Makefiles, patches, and description files placed in /usr/ports. The port includes instructions.
E X C E E D I N G E X P E C T A T I O N S Basic LINUX Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Directory structure:
Chapter 5 Files and Exceptions I. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. What is a file? A.
Linux+ Guide to Linux Certification Chapter Six Linux Filesystem Administration.
System Administration – Part 2. Devices in UNIX are files: A device can be accessed with different file names All device files are stored in /dev or its.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop V Files and the File System Part B – File System.
File and Folder CLI Commands 12/24/ Agenda Overview of OS functions and the SHELL Internal v External Commands Command History Making & Modifying.
File system In computing, a file system is a method of storing and organizing computer files and the data they contain to make it easy to find and access.
Digital Forensics Dr. Bhavani Thuraisingham The University of Texas at Dallas Lecture #8 File Systems September 22, 2008.
CSN08101 Digital Forensics Lecture 2: Essential Linux for Forensics Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
MS-DOS is an acronym for MicroSoft Disk Operating System It is a CUI based operating system. It provides user with a command prompt (generally called.
Linux Filesystem Administration
Installing Windows 7 Lesson 2.
Guide to Linux Installation and Administration, 2e
Chapter 6 File Systems CSNB113 SYSTEM ADMINISTRATION
Project 3: An Introduction to File Systems
Introduction to Computers
Exploring the UNIX File System and File Security
Linux File Systems Partitioning Mounting File Systems
Using files Taken from notes by Dr. Neil Moore
OPS235: Week 5 Lab4: Investigations 1 – 3
Topics Introduction to File Input and Output
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

CSN08101 Digital Forensics Lecture 4: System Level Disk Control Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak

Essential Linux for Forensics You will learn in this lecture: Command Summary: –sudo –mount/umount –fdisk family (cfdisk) –dd –strings –dmsetup –losetup –blockdev This week is all about: –Doing things as the administrator –Reading and Writing disk blocks –Accessing partition information –Mounting and unmounting and loop devices –Snapshots

Directory Tree /home/caine This week we are accessing new directories in the directory tree /mnt – Empty directory useful for mounting images and disks /dev – Holds special files needed for mounting data /root – The administrator’s HOME /images – A collection of disk images we are using for forensic tutorials. /home/etc / /root /dev /images /mnt

sudo You run commands in Caine with the rights and privileges of the current user account. This is usually the user “caine”. Sometimes you need to run commands with more privileges.. In Caine, this is done by prepending the command with the string “sudo”.

Example: sudo $ ls -l /etc/shadow -rw-r root shadow :46 /etc/shadow $ tail -1 /etc/shadow tail: cannot open `/etc/shadow' for reading: Permission denied $ sudo tail -1 /etc/shadow telnetd:*:15349:0:99999:7:::

Reading binary files cat/more/less lets you look at text files. Sometimes you want to look at binary files, perhaps looking for normal english words which will help you understand the file. If you try this with cat you get rubbish: $ cat /bin/cat

The strings command The “strings” command looks at binary files and tried to extract things which might be words. Really it just looks for normal characters which end in a NULL (\0) and which are over a certain length. Could be useful in understanding an unknown file: $ strings /bin/cat

Disk Blocks Disk storage devices deal with data block transfers, not bytes. When a whole disk is copied to a file, it is called a disk image. When performing forensics, reading and writing blocks in disks or images may be necessary. In Linux, the system command to perform block reads and writes is called “dd”.

dd parameters dd takes many parameters. The ones we are interested in are: –if=filename – the filename or disk being read –of=filename – the filename or disk being written to –seek=blockno – Skip over blockno number of blocks from the beginning of the output file before starting to write –skip=blockno – Skip over blockno number of blocks from the beginning of the input file before starting to read –bs=512 – assume a block size of 512 bytes. –count=N – transfer N number of blocks –conv=notrunc – do not truncate the output file when finished.

dd example 1 $ dd if=file1.dd of=file2.dd bs=512 The input file and the output file can be simple files, in which case the input file is copied to the output file. This is just like $ cp file1.dd file2.dd “if” or “of” could be actual disks. In Linux, disks can be accessed using special files in /dev. A hard drive could be “/dev/sdd” (which is sata disk 4). “if” or “of” can be other types of devices, some of which do special things. In Linux block size is usually 512 bytes. Always state “bs=512” unless you have reason not to.

Subset of blocks - skip bs=512 count=3 skip=3 Nothing remains of original destination. Block 0 Input file Block 1 Block 2 Block 3 Block 4 Block 5 Block 3 Block 4 Block 5 Output file Old Block 0 Old Block 1 Old Block 2 Old Block 3 Old Block 4 Old Block 5 Original Output file

Subset of blocks - seek Block 0 Input file Block 1 Block 2 Block 3 Block 4 Block 5 Block 0 Block 1 Block 2 Output file bs=512 count=3 seek=3 Things in the destination BEFORE the seek point are kept Old Block 0 Old Block 1 Old Block 2 Old Block 3 Old Block 4 Old Block 5 Original Output file Old Block 0 Old Block 1 Old Block 2

Seek and truncate Block 0 Input file Block 1 Block 2 Block 3 Block 4 Block 5 Block 0 Block 1 Output file bs=512 count=2 seek=1 Things in the destination AFTER the transfer are TRUNCATED Old Block 0 Old Block 1 Old Block 2 Old Block 3 Old Block 4 Old Block 5 Original Output file Old Block 0

Seek and stop truncate Block 0 Input file Block 1 Block 2 Block 3 Block 4 Block 5 Block 0 Block 1 Output file bs=512 count=2 seek=1 conv=notrunc Things in the destination not in the transfer are kept with notrunc. Old Block 0 Old Block 1 Old Block 2 Old Block 3 Old Block 4 Old Block 5 Original Output file Old Block 0 Old Block 3 Old Block 4 Old Block 5

Seek and Skip Block 0 Input file Block 1 Block 2 Block 3 Block 4 Block 5 Block 2 Block 3 Output file bs=512 count=2 skip=2 seek=1 conv=notrunc Things in the destination not in the transfer are kept with notrunc. Old Block 0 Old Block 1 Old Block 2 Old Block 3 Old Block 4 Old Block 5 Original Output file Old Block 0 Old Block 3 Old Block 4 Old Block 5

Examples file1.dd contains byte blocks. Write these to block 7 onwards of hard drive partition /dev/sda1. (Note real hard drives cannot be truncated) $ dd if=file1.dd of=/dev/sda1 bs=512 count=3 seek=7 (conv=notrunc) Read block 9 from disk image file2.dd and write that block to file3.dd. $ dd if=file2.dd of=file3.dd bs=512 count=1 skip=9

Questions: Copy block 11 and block 12 from file5.dd and save this as copy1.dd. $ dd if=file5.dd of=copy1.dd bs=??? skip=??? count=??? Copy block 55 from drive /dev/sdd and save this block as block 10 into a pre-existing disk image called image1.dd $ dd if=/dev/sdd of=image1.dd bs=512 ????????????? count=1

Mount and umount If you have a hard drive on linux it has a device name. For instance in Caine the harddrive is called /dev/sda (SATA drive 1). Disks are partitioned up into disk partitions. In caine /dev/sda is partitioned into 1 partition. It is called /dev/sda1. If it had more partitions they would be /dev/sda1, /dev/sda3, etc. To access the contents of a partition the partition must be mounted at a mountpoint. –In Linux a mountpoint is simply an empty directory. –There is a commonly used empty directory called /mnt used for temporary mounts $ mount /dev/sda1 /mnt

Understanding partition data To read a disk and find out its partition structure you might use any number of tools. An easy tool at the CLI is sfdisk. Remember to use sudo! $ sfdisk –l –uS /dev/sda Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sda1 * Linux /dev/sda Empty /dev/sda Empty /dev/sda Empty

$ sfdisk –l –uS /dev/sda Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sda1 * Linux... “-l” shows you the partitions. This command can also set partitions. We will only be using “-l” for now. “-uS” says to report the sizes and other data in Sectors, which in this case is interchangable for 512 byte blocks. /dev/sda1 starts 2048*512 bytes into the disk, and is *512 bytes in size. It is a Linux partition (type 0x83).

Errors from sfdisk The Cylinders/Heads/Sectors of a disk (C/H/S) is given by the BIOS. This is needed to access the drive in C/H/S mode. C/H/S data may also be written to the hard drive, and may even be right... Some operating systems need this to be right. Linux does not care, and will access the disk in block mode. This happens a lot with disk images, as an image does not have a BIOS to tell you the geometry. Usually it is fine and you can ignore the issue...

Disk /dev/sda: 446 cylinders, 255 heads, 63 sectors/track Warning: The partition table looks like it was made for C/H/S=*/48/49 (instead of 446/255/63). For this listing I'll assume that geometry. Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sda1 * Linux start: (c,h,s) expected (0,41,40) found (0,32,33) end: (c,h,s) expected (1023,47,49) found (446,47,49) /dev/sda Empty /dev/sda Empty /dev/sda Empty

Mount parameters The first parameter of mount is the device name of the hard drive being mounted. The second parameter is the mountpoint. $ mount /dev/sda1 /mnt Each partition must have been formatted already. In linux formats include ext3 and brfs. In Windows common format are fat/FAT16 and NTFS. This is usually detected automatically by Linux during the mount.

Removing a mount Once you are finished with the mount you can unmount it. $ umount /dev/sda1 $ umount /mnt You can either unmount using the mountpoint name or the device name. Either one is fine. Note if you “cd /mnt” you cannot unmount /mnt. You will get an error that the drive is in use. Just “cd /” in that case before you umount. You can only mount devices, not files.

Mounting Files If you take a disk image (perhaps using dd) of a device you may want to mount that image. To do this you need to create a loop device. They are numbered /dev/loop0 to loop9. –This takes a disk image and gives it a device name –Remember to use sudo $ losetup /dev/loop0 /images/imagename.dd $ losetup -a /dev/loop0: [0821]:13 (/images/imagename.dd) $ mount /dev/loop0 /mnt $ ls –l /mnt/... $ umount /dev/loop0 $ losetup –d /dev/loop0

Mounting Partitions in Files When you loop a disk image you have /dev access to the file as a disk, but no immediate access to the partitions individually. If /images/file1.dd is a whole disk, and you want to mount partition 1, you need to do some work! Firstly, you need to know the byte offset into the disk where the partition starts... So in the example of sfdisk above: Device Boot Start End #sectors Id System /dev/sda1 * Linux As the start is 2048 blocks, the offset is 2048*512. Add this into the losetup using –a, e.g. $ losetup /dev/loop3 /images/img1.dd –a

Snapshots Sometimes it would be nice to be able to take a disk image, and make changes to the image without the changes being permanent. For instance, if you have a 1TB disk image with a damaged partition table, you could copy the whole image and write to the copy. –But this would use up another 1TB of data. One alternative is to use snapshots, which allow you to change read- only data by pretending to write to the original data, but instead putting the writes into a separate file. –This new file holds all the changes, and so long as the number of changes are small this file should also be small.

Snapshot change Block 3 Block 5 Changed Blocks Block 0 Block 1 Block 2 Block 3 Block 4 Block 5 Readonly image Block 0 Block 1 Block 2 Block 3 Block 4 Block 5 Looks like

Build a snapshot device of /images/img1.dd File to hold the changes... Must be big enough! $ dd if=/dev/zero of=/root/changes bs=512 seek=4095 count=1 Build loop devices for the original and the changes $ losetup /dev/loop5 /images/img1.dd (plus offset info for partitioning). $ losetup /dev/loop6 /root/changes We need the blocksize of the original $ blockdev –getsize /dev/loop5 Create the snapshot $ dmsetup create sandbox --table "0 THESIZE snapshot /dev/loop5 /dev/loop6 N 1“ Mount the new device $ mount /dev/mapper/sandbox /mnt

Remove shapshot $ mount /mnt $ dmsetup remove sandbox $ losetup –d /dev/loop5 $ losetup –d /dev/loop6

Next Week My last lecture on Linux-focused commands –Although we will cover many more Caine commands for forensic-specific activities. Next week I will be looking at sorting, text-based diff, and understanding binary information in files. I will also be doing some preparation work for the first class test.

Assessment: Short-Answer Examples The short answer class test has no past papers yet (as this is a new module for this year). This section contains example questions which are of the same style as you might expect in the actual past paper. Obviously it is likely that the actual questions shown here are not the ACTUAL questions which will appear in the exam! Remember this short answer exam is CLOSED BOOK. You are not permitted to use the internet or access your notes during the exam.

Q1 You have two disk images, “image1.dd” and “image2.dd”. Show the “dd” command to copy blocks 8,9, and 10 from image1.dd so that they appear as blocks 20,21,and 22 in image2.dd. All other blocks in image2.dd should be left unchanged. Insert answer here:

Q2 Consider the output of “sfdisk –l –uS /img/a.dd”. Device Boot Start End #sectors Id System /img/a.dd1 * Linux Show the appropriate commands needed to mount the partition shown in /mnt. Insert answer here:

Q3 Briefly discuss two advantages in using snapshots during a forensic investigation. Insert answer here: