Forensic Guide To Linux
Forensic Guide To Linux
Forensic Examiner
Introduction to Linux
A Beginner's Guide
Barry J. Grundy
Special Agent
NASA Office of Inspector General
Computer Crimes Division
Code 190 Greenbelt Rd.
Greenbelt, MD 20771
(301) 286-3358
[email protected]
VER 2.0.5
January 2004
1
LEGALITIES ................................................................................................................................................ 3
FOREWORD ................................................................................................................................................. 4
A WORD ABOUT THE “GNU” IN GNU/LINUX ............................................................................................. 5
WHY LEARN LINUX? .................................................................................................................................. 5
I. INSTALLATION..................................................................................................................................... 6
DISTRIBUTIONS .......................................................................................................................................... 7
INSTALLATION METHODS:.......................................................................................................................... 9
INSTALLATION OVERVIEW ....................................................................................................................... 10
THE NEW 2.6 LINUX KERNEL ................................................................................................................... 12
II. LINUX DISKS, PARTITIONS AND THE FILESYSTEM.............................................................. 13
DISKS ....................................................................................................................................................... 13
PARTITIONS .............................................................................................................................................. 13
USING MODULES ....................................................................................................................................... 15
MODULES ON NEWER SYSTEMS ................................................................................................................ 16
THE FILESYSTEM ...................................................................................................................................... 17
III. THE LINUX BOOT SEQUENCE (SIMPLIFIED)........................................................................... 19
BOOTING THE KERNEL .............................................................................................................................. 19
INITIALIZATION ........................................................................................................................................ 20
RUNLEVEL ................................................................................................................................................ 21
GLOBAL STARTUP SCRIPTS ...................................................................................................................... 22
BASH ........................................................................................................................................................ 22
IV. DOS / LINUX EQUIVALENT COMMANDS ................................................................................. 24
"DOS COMMAND" = LINUX EQUIVALENT ................................................................................................. 24
ADDITIONAL USEFUL COMMANDS ............................................................................................................ 27
FILE PERMISSIONS .................................................................................................................................... 29
METACHARACTERS .................................................................................................................................. 31
COMMAND HINTS ..................................................................................................................................... 32
PIPES AND REDIRECTION .......................................................................................................................... 32
THE SUPERUSER....................................................................................................................................... 33
V. EDITING WITH VI ............................................................................................................................. 35
USING VI .................................................................................................................................................. 35
VI COMMAND SUMMARY .......................................................................................................................... 36
VI. MOUNTING FILE SYSTEMS ON DISKS ...................................................................................... 37
THE MOUNT COMMAND ........................................................................................................................... 37
THE FILE SYSTEM TABLE (/ETC/FSTAB) ..................................................................................................... 39
VII. LINUX AND FORENSICS................................................................................................................ 41
INCLUDED FORENSIC TOOLS .................................................................................................................... 41
ANALYSIS ORGANIZATION ........................................................................................................................ 42
DETERMINING THE STRUCTURE OF THE DISK ............................................................................................ 43
CREATING A FORENSIC IMAGE OF THE SUSPECT DISK ................................................................................ 44
MOUNTING A RESTORED IMAGE................................................................................................................ 45
FILE HASH ................................................................................................................................................ 46
THE ANALYSIS .......................................................................................................................................... 47
MAKING A LIST OF ALL FILES .................................................................................................................... 48
MAKING A LIST OF FILE TYPES .................................................................................................................. 49
VIEWING FILES ......................................................................................................................................... 49
SEARCHING UNALLOCATED AND SLACK SPACE FOR TEXT ......................................................................... 51
2
VIII. COMMON FORENSIC ISSUES..................................................................................................... 54
HANDLING LARGE DISKS .......................................................................................................................... 54
PREPARING A DISK FOR THE SUSPECT IMAGE ............................................................................................ 56
IX. ADVANCED (BEGINNER) FORENSICS ........................................................................................ 58
THE COMMAND LINE ON STEROIDS .......................................................................................................... 58
FUN WITH DD........................................................................................................................................... 64
SPLITTING FILES AND IMAGES ................................................................................................................... 64
DATA CARVING WITH DD ......................................................................................................................... 66
CARVING PARTITIONS WITH DD ................................................................................................................ 69
THE NASA ENHANCED LOOPBACK DRIVER ............................................................................................ 74
DETERMINING THE SUBJECT DISK FILESYSTEM STRUCTURE .................................................................... 76
X. ADVANCED FORENSIC TOOLS ..................................................................................................... 80
SLEUTHKIT ............................................................................................................................................... 81
AUTOPSY .................................................................................................................................................. 88
SMART FOR LINUX ............................................................................................................................... 100
OTHER ADVANCED LINUX FORENSIC TOOLS ......................................................................................... 104
XI. BOOTABLE LINUX DISTRIBUTIONS......................................................................................... 105
TOMSRTBT - BOOT FROM A FLOPPY......................................................................................................... 105
KNOPPIX - FULL LINUX WITHOUT THE INSTALL ...................................................................................... 105
PENGUIN SLEUTH - KNOPPIX WITH A FORENSIC FLAVOR ........................................................................ 105
WHITE GLOVE LINUX - DR. FRED COHEN .............................................................................................. 106
SMART FOR LINUX - IT’S BOOTABLE! ................................................................................................... 106
CONCLUSION .......................................................................................................................................... 107
XI. LINUX SUPPORT ............................................................................................................................ 108
WEB SITES TO CHECK FOR SUPPORT:....................................................................................................... 108
Legalities
3
Foreword
Over the past couple of years I have repeatedly heard from colleagues
that have tried Linux by installing it, and then proceeded to sit back and
wonder “what next?” You have a copy of this introduction. Now download
the exercises and drive on.
ftp://ftp.hq.nasa.gov/pub/ig/ccd/linuxintro/
http://www.ohiohtcia.org/resource.html
4
A word about the “GNU” in GNU/Linux
When we talk about the Linux operating system, we are actually talking
about the GNU/Linux operating system (OS). Linux itself is not an OS. It
is just a kernel. The OS is actually a combination of the Linux kernel and
the GNU utilities that provide the tools allowing us to interact with the
kernel. Which is why the proper name for the OS is “GNU/Linux”. We
(incorrectly) call it “Linux” for convenience.
One of the questions I hear most often is: “why should I use Linux when I
already have [insert Windows GUI forensic tool here]?”
There are many reasons why Linux is quickly gaining ground as a forensic
platform. I’m hoping this document will illustrate some of those attributes.
• Control – not just over your forensic software, but the whole OS and
attached hardware.
• Flexibility – boot from a CD (to a complete OS), file system support,
platform support, etc.
• Power – A Linux distribution is a forensic tool.
As Linux becomes more and more popular, both in the commercial world
and with desktop users, the chance that an examiner will encounter a Linux
system in a case becomes more likely (especially in network investigations).
Even if you elect to utilize a Windows forensic tool to conduct your
analysis, you must at least be familiar with the OS you are examining. If
you do not know what is normal, then how do you know what does not
belong? This is true on so many levels, from the actual contents of various
directories to strange entries in configuration files, all the way down to how
files are stored. While this document is more about Linux as a forensic tool
rather than analysis of Linux, you can still learn a lot about how the OS
works by actually using it.
5
I. Installation
• Hard drive – knowing the size and geometry is helpful when planning
your partitioning.
• SCSI adapters and devices (note the adapter chipset). SCSI is very well
supported under Linux.
• Sound card (note the chipset).
• Video Card (important to know your chipset and memory, etc.).
• Monitor timings
• Horizontal and vertical refresh rates.
• Network card settings (chipset).
• Network Parameters:
• IP (if not DHCP)
• Netmask
• Broadcast address
• DNS servers
• Default gateway
• Modem
• NO WINMODEMS. (Support is being worked on – check
http://www.linmodems.org. Note that if you have an HSF modem,
Conexant has released Linux drivers! Find them at
http://www.conexant.com/customer/. I use them, and they work.)
• USB support is in kernel 2.4. USB is standard in current distributions.
• IEEE1394 (firewire) support is included in current distributions.
6
Most distributions have a plethora of documentation, including online
help and documents in downloadable form. For example, Red Hat users can
check for hardware compatibility and installation issues at:
http://www.redhat.com/support/hardware/
If you cannot find your monitor documentation and need it for XFree86
(the Linux GUI) setup, then go to:
http://www.monitorworld.com/monitors_home.html
Distributions
Red Hat
One of the most popular Linux distributions (right now). Red
Hat works with companies like Dell, IBM and Intel to assist business in the
adoption of Linux for enterprise use. Use of RPM and Kickstart began the
first “real” user upgrade paths for Linux. Red Hat is an excellent choice for
beginners because of the huge install base and the proliferation of online
support. The install routine is well polished and hardware support is well
documented. While Red Hat has elected to move into a more enterprise
oriented business model, it is still a viable option for the desktop through the
“Fedora Project” (http://fedora.redhat.com/).
7
Debian
Not really for beginners. The installation routine is not as
polished as some other distributions. Debian has always been a hacker
favorite. It is also one of the most “non-commercial” Linux distributions,
and true to the spirit of GNU/GPL.
SuSE
Another distribution with its own proprietary install program,
YaST2. SuSE is German in origin. It is by far the largest software inclusive
distribution, and comes with six (6!) CD’s (or a DVD).
Slackware
The original commercial distribution. Slackware has been
around for years. Installation is not as easy as others. Good standard Linux.
Not over-encumbered by GUI config tools.
Mandrake Linux
Red Hat based and rapidly gaining on Red Hat’s desktop
market share, Mandrake is a favorite of many beginners and desktop users.
It is heavy on GUI configuration tools, allowing for easy migration to a
Linux desktop environment. Mandrake is also a good choice to use with this
document’s exercises.
Gentoo Linux
Source-centric distribution that is optimized during install – my
personal favorite. Once through the complex installation routine, upgrading
the system and adding software is made extremely easy through Gentoo’s
“Portage” system. Not for beginners, though. You are left to configure the
system entirely on your own.
8
One thing to keep in mind: If you are going to use Linux in a forensic
capacity, then try not to rely on GUI tools too much. Almost all settings and
configurations in Linux are maintained in text files (usually in either your
home directory, or in /etc). By learning to edit the files yourself, you avoid
problems when either the X window system is not available, or when the
specific GUI tool you rely on is not on a system you might come across. In
addition, knowledge of the text configuration files will give you insight into
what is “normal”, and what might have been changed when you examine a
subject system.
Installation Methods:
• Buy a book! (Most come with a distribution).
• Download the needed files, create a boot and root disk and read
online! (See the “Linux Support” section at the end of this document).
• Get hold of a distribution CD and boot from it (change your bios to
boot from the CD if needed).
• Use a bootable Linux distribution (covered later).
9
Installation Overview
If you are comfortable with the idea of multiple partitions for your
Linux install, then it is recommended that you use at least a separate
/boot partition along with the root (/) and swap.
10
5) Package installation (system)
-When asked which packages to select for installation, it is usually
safe for a beginner to select “everything” (as in Red Hat or
Mandrake). This allows you to try all the packages, along with both
KDE and Gnome (X Window GUIs). This can take as much as 2GB
on some of the newer distributions, however it includes all the
software you are likely to need for a long time (including “office”
type applications). This is not really optimal or recommended, but for
a learning box it will give you the most exposure to available software
for experimentation.
6) Installation Configuration
-Sound
-Usually automatic. If not, search the Web. The answer is out
there. If the sound is not configured automatically, try running
sndconfig if it is available (i.e. most Redhat systems).
-Xfree86 (X Window system)
-Know your hardware.
-If you choose to configure X during the installation routine, do
not click “yes” when asked if you want X to start automatically
every time you system boots. This can make problem solving
difficult and results in less control over the system. You can
always start the GUI with “startx” from the command line.
11
what he or she is doing and allows “root” to do anything he or she
wants, including destroy the system. Create a new user. Don’t log in
as “root” unless you must. Having said this, much of the work done
for forensic analysis must be done as “root” to allow access to raw
devices and system commands.
In December of 2003, the Linux 2.6 kernel was released. While this is
another milestone in the Linux saga, it would be wise to stay with the 2.4
kernel until tests are done on changes that affect our work.
Many of the changes in 2.6 are geared toward enterprise use and
scalability. The new kernel release also has a number of infrastructure
changes that could have a huge impact on Linux as a forensic platform. For
example, there is enhanced support for USB and a myriad of other external
devices. The kernel module and entire device sub-systems have been
changed and improved, making them more robust. And we will soon have
access to “user mode” Linux that could provide a whole new environment
for us to work in.
As with all forensic tools, we need to have a clear view of how the
new kernel will interact with our forensic platforms and subject hardware.
This will take some time.
12
II. Linux Disks, Partitions and the Filesystem
Disks
Linux treats its devices as files. The special directory where these
"files" are maintained is "/dev".
Partitions
1
Some distributions support devfs which uses a different naming scheme. Don’t let this confuse you. The
pattern described above is still supported through “links” for compatibility. See
http://www.atnf.csiro.au/people/rgooch/linux/docs/devfs.html for more information.
13
This is an example of the output of fdisk -l /dev/hda on a dual boot
system:
Keep in mind, that even what not mounted, devices can still be written to.
Simply not mounting a file system does not protect it from being
inadvertently changed through your actions.
Note that if you use a parallel ZIP drive or USB disk (thumb drive,
memory stick, etc.), it will be accessed as /dev/sda (assuming no other SCSI
devices) or /dev/sdb. Support must be compiled either into the kernel, or as
a loadable module. Most new distros have USB support already included.
Also, a Linux formatted ZIP disk is /dev/sda1 and a DOS (FAT) formatted
ZIP disk is /dev/sda4 (no, I don't know why). It’s not unusual for Linux to
recognize storage peripherals as SCSI devices. The same is true for
14
IEEE1394 “firewire” devices. In order mount file systems on these types of
“external” devices, we may need to delve a little deeper into modules.
Using modules
It’s difficult to decide when to introduce modules to a new user. The
concept can be a little confusing, but “out of the box” Linux distributions
rely heavily on modules for device and file system support. For this reason,
we will make an effort to get familiar with the concept early on.
Modules are really just “drivers” that can be loaded and unloaded
from the kernel dynamically. They are object files (*.o) that contain the
required driver code for the supported device or option (file system support
under Linux is often loaded as a module). The various modules available on
your system are located in /lib/modules/<KERNEL-VERSION>/. Note that
the current kernel version running on your system can be found using the
command uname -r.
Modules are installed and removed from the system “on the fly” using
the following commands (as root):
Note that while the module is named with a “.o” extension, we do not
include that in the insertion command.
15
You can check to see if the module has been correctly loaded with:
lsmod
Note that the output of lsmod will include any other drivers loaded by
the system as well (including those loaded at boot time).
Often, once you have loaded the required drivers, you will see activity
lights on the drives kick in as the equipment becomes accessible. Again,
USB and Firewire drives are usually picked up as SCSI devices once the
modules are loaded, so check /dev/sda or /dev/sdb using fdisk to see if the
device is recognized and which partitions are available.
The above commands will get USB working on many systems, for
Firewire, try installing the modules ieee1394.o, ohci1394.o, and for Firewire
hard drive support, sbp2.o. If these commands don’t work for your system’s
USB or Firewire controller, then try searching Google for answers specific
to your hardware.
Modules on Newer systems
On newer Linux systems (like the one you are probably using now)
there is often an automatic kernel module daemon that handles the loading
and unloading of modules automatically. When you issue a command that
requires a module that is not yet loaded, the kernel will often detect your
request and load the applicable module. The module “autoloader” is useful
and ends the need to install modules by hand using insmod in some cases
(like when mounting supported file systems). It is likely that your system
follows this convention. I would not suggest relying on this feature,
however. If you have the kernel sources on your system, check out
/usr/src/linux/Documentation/modules.txt for more detailed information.
16
The Filesystem
Like the Windows file system, the Linux file system is hierarchical.
the "top" directory is referred to as "the root" directory and is represented by
"/". Note that the following is not a complete list, but provides an
introduction to some important directories.
17
On most Linux distributions, the directory structure is organized in the
same manner. Certain configuration files and programs are
distribution dependant, but the basic layout is similar to this.
18
III. The Linux Boot Sequence (Simplified)
Booting the kernel
The first step in the (simplified) boot up sequence for Linux is loading
the kernel. The kernel image is usually contained in the /boot directory. It
can go by several different names…
• bzImage
• vmlinuz
Sometimes the kernel image will specify the kernel version contained
in the image, i.e. bzImage-2.4.18. Very often there is a soft link (like a
shortcut) to the most current kernel image in the /boot directory. It is
normally this soft link that is referenced by the boot loader, LILO (or
GRUB). The boot loader specifies the “root device” (boot drive), along with
the kernel version to be booted. For LILO, this is all controlled by the file
/etc/lilo.conf. Each “image=” section represents a choice in the boot screen.
GRUB is a more recent boot loader used by many Linux distributions. The
concept is the same. You can look at the man or info pages for either boot
loader for more information.
more /etc/lilo.conf
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.4.17 Å Defines the Linux kernel to boot
label=linux_old Å Menu choice in LILO
root=/dev/hda3 Å Where the root file system is found
read-only
other=/dev/hda1 Å Defines alternate boot option
label=Win2k Å Menu choice in LILO
table=/dev/hda
19
counting from 0, so where you see “hd0,0” it is referring to the first IDE
disk, followed by the first partition. See the info or man page for GRUB.
more /etc/grub.conf
boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Linux (2.4.20)
root (hd0,0)
kernel /boot/bzImage-2.4.20 ro root=/dev/hda1
title Linux-enh (2.4.20-xfs-enh)
root (hd0,0)
kernel /boot/bzImage-2.4.20-xfs-enh ro root=/dev/hda1
title Linux (2.4.19)
root (hd0,0)
kernel /boot/bzImage-2.4.19 ro root=/dev/hda1
Once the system has finished booting, you can see the kernel
messages that “fly” past the screen during the booting process with the
command dmesg. Often, this command can be used to find hardware
problems, or to see how your suspect drive was detected (geometry, etc).
The output can be piped through a paging viewer to make it easier to see:
dmesg | less
Initialization
The next step starts with the program /sbin/init. This program really
has two functions:
20
In short, the init program is controlled by the file /etc/inittab. It is this
file that controls your runlevel and the global startup scripts for the system.
Runlevel
id:3:initdefault:
It is here that the default runlevel for the system is set. If you want a
text login (which I would strongly suggest), set the above value to “3”. You
can always use “startx” to get to the X Window GUI system. If you want a
graphical login, you would edit the above line to contain a “5”.
21
Global Startup Scripts
After the default runlevel has been set, init (via /etc/inittab) then runs
the following scripts:
• /etc/rc.d/rc.sysinit - handles system initialization, file system
mount and check, PNP devices, etc.
• /etc/rc.d/rc X - where X is the runlevel passed as an argument
by init. This script then calls the specified script for the runlevel that
is being started.
• /etc/rc.d/rc.local - called from within the specific runlevel
scripts, rc.local is a general purpose script that can be edited to
include commands that you want started at bootup (sort of like
autoexec.bat).
There are actually quite a few files that can be used to customize a
user’s Linux experience. Here are two that will get you started. I am
assuming here that you are using the bash shell.
2
In bash we define the contents of a variable with a dollar sign. $USER is a variable that represents the
name of the current user. To see the contents of shell individual variables, use “echo $VARNAME”.
22
The bash startup sequence is actually more complicated than this, but
this should give you a starting point. In addition to the above files, check
out /home/$USER/.bash_profile and /etc/profile. The man page for bash is
an interesting (and long) read, and will describe some of the customization
options. In addition, reading the man page will give a good introduction to
the programming power provided by bash scripting.
23
IV. DOS / Linux Equivalent Commands
Output of ls -l
total 11
drwx------ 5 barry 501 1024 Feb 7 15:07 Desktop
drwxr-xr-x 2 barry users 1024 Feb 9 08:19 Files
drwx------ 2 barry users 1024 Dec 18 15:58 Mail
-rw-r--r-- 1 barry users 0 Feb 9 09:21 Mydata.file.today
drwxr-xr-x 26 barry users 1024 Jan 23 00:49 Office51
drwxr-xr-x 2 barry users 1024 Nov 8 16:21 Prog
drwxr-xr-x 2 barry users 1024 Dec 16 15:42 Programming
drwxr-xr-x 2 barry users 1024 Feb 9 09:27 Sample
drwxr-xr-x 2 barry users 1024 Feb 9 08:41 autosave
drwxr-xr-x 2 barry users 1024 Feb 8 15:50 bin
drwx------ 2 barry 501 1024 Oct 9 14:00 nsmail
drwxrwxr-x 3 barry 501 1024 Jan 23 00:42 software
-rw-r--r-- 1 barry users 0 Feb 9 09:20 textfile
24
"copy" = cp
cp sourcefile destinationfile copy a file.
“cls” = clear
clears the terminal screen of all text and returns a prompt.
"del" = rm
rm filename deletes a file.
rm -r recursively deletes all files in
directories and subdirectories.
FIND(1L) FIND(1L)
find - search for files in a directory hierarchy
SYNOPSIS
find [path...] [expression]
DESCRIPTION
This manual page documents the GNU version of find. find
searches the directory tree rooted at each given file name
by evaluating the given expression from left to right,
according to the rules of precedence (see section OPERA-
TORS), until the outcome is known (the left hand side is
false for and operations, true for or ), at which point
find moves on to the next file name.
<CONTINUES WITH MORE INFO>
25
"md" = mkdir
mkdir directoryname creates a directory. Again, remember the
difference between a relative and explicit
path here.
cat filename The simplest form of file display, cat streams the
contents of a file to the standard output (usually
the terminal). cat actually stands for
“concatenate”. This command can also be used to
add files together (useful later on…). For
example:
Note that you can string together several options. For example:
ls -aF
will give you a list of all files (-a), including hidden files, and
file/directory classification (-F, which shows "/" for directories, "*" for
executables, and "@" for links).
26
Output of ls –aF :
./ .emacs .kderc .zshrc Sample/
../ .gnome/ .kpackage/ Desktop/ autosave/
.Xauthority .gnome_private/ .mailcap Files/ bin/
.Xdefaults .gqviewrc .maxwellrc Mail/ mylink@
.bash_history .gxedit .netscape/ Mydata.file.today nsmail/
.bash_logout .gxedit.apps .sversionrc Office51/ samp_script.sh*
.bash_profile .kaudioserver .user.rdb Prog/ snapshot01.gif
.bashrc .kde/ .vimrc Programming/ software/
textfile
Grep will look for occurrences of pattern within the file filename.
grep is an extremely powerful tool. It has hundreds of uses given the
large number of options it supports. Check the man page for more
details.
find -allows you to search for a file (wild cards – actually “expressions”
permitted). To look for your XF86Config file, you might try:
pwd
/home/barry
27
file -categorizes files based on what they contain, regardless of the name
(or extension, if one exists). Compares the file header to the "magic"
file in an attempt to ID the file type. For example:
file snapshot01.gif
snapshot01.gif: GIF image data, version 87a, 800 x 600
ps -list of current processes. Gives the process ID number (PID), and the
terminal on which the process is running.
strings -prints out the readable characters from a file. Will print out
strings that are at least four characters long (by default)from a
file. Useful for looking at data files without the originating
program, and searching executables for useful strings, etc.
28
chmod -changes the permissions on a file. (See the section in this
document on permissions).
chown -changes the owner of a file in much the same way as chmod
changes the permissions.
ls –l filename
If you look close at the first 10 characters, you have a dash (-)
followed by 9 more characters. The first character describes the type of file.
3
This has become much less of an issue with the newer journaled file systems used by Linux.
29
A dash (-) indicates a regular file. A "d" would indicate a directory, and "b"
a special block device, etc.
The next 9 characters indicate the file permissions. These are given in
groups of three:
This gives the file owner read, write and execute permissions (rwx),
but restricts other members of the owner’s group and users outside that
group to only read and execute the file (r-x).
Now back to the chmod command. There are a number of ways to
use this command, including explicitly assigning r, w, or x to the file. We
will cover the octal method here because the syntax is easiest to remember
(and I find it most flexible). In this method, the syntax is as follows
octal is a three digit numerical value in which the first digit represents
the owner, the second digit represents the group, and the third digit
represents others outside the owner's group. Each digit is calculated by
assigning a value to each permission:
30
read (r) =4
write (w) = 2
execute (x) = 1
For example, the file filename in our original example has an octal
permission value of 755 (rwx =7, r-x =5, r-x=5). If you wanted to change
the file so that the owner and the group had read, write and execute
permissions, but others would only be allowed to read the file, you would
issue the command:
4(r)+2(w)+1(x)=7
4(r)+2(w)+1(x)=7
4(r)+0(-)+0(-) =4
Metacharacters
Linux also supports wildcards (metacharacters)
• * for multiple characters (including ".").
• ? for single characters.
• [ ] for groups of characters or a range of characters or numbers.
This is a complicated and very powerful subject, and will require further
reading… Refer to “regular expressions” in your favorite Linux text, along
with “globbing” or “shell expansion”. There are important differences that
can confuse a beginner, so don’t get discouraged by confusion over what “*”
means in different situations.
31
Command Hints
1. Linux supports command line editing.
2. Linux has a history list of previously used commands (stored in
.bash_history in your home directory).
-use the keyboard arrows to scroll through commands
you've already typed.
3. Linux commands and filenames are CASE SENSITIVE.
4. Learn output redirection for stdout and stderr “>” and “2>”.
5. Linux uses “/” for directories, DOS uses “\”.
6. Linux uses “-“ for command options, DOS uses “/”
7. To execute commands in the current directory (if the current directory
is not in your PATH), use the syntax "./command". This tells Linux to
look in the present directory for the command.
Pipes and Redirection
Like DOS, Linux allows you to redirect the output of a command
from the standard output (usually the display or "console") to another device
or file. This is useful for tasks like creating an output file that contains a list
of files on a mounted volume, or in a directory. For example:
The above command would output a long list of all the files in the current
directory. Instead of outputting the list to the console, a new file called
"filelist.txt" will be created that will contain the list. If the file "filelist.txt"
already existed, then it will be overwritten. Use the following command to
append the output of the command to the existing file, instead of over-
writing it:
32
ps -ax
What if all you wanted to see were those processes ID's that indicated
a bash shell? You could "pipe" the output of ps to the input of grep,
specifying "bash" as the pattern for grep to search. The result would give
you only those lines of the output from ps that contained the pattern "bash".
A little later on we will cover using pipes on the command line to help
with analysis. Stringing multiple powerful commands together is one of
using Linux for forensic analysis.
The SuperUser
If Linux gives you an error message "Permission denied", then in all
likelihood you need to be "root" to execute the command or edit the file, etc.
You don't have to log out and then log back in as "root" to do this. Just use
the su command to give yourself root powers (assuming you know root’s
password).
su -
33
Then enter the password when prompted. You now have root
privileges (the system prompt will reflect this). Note that the "-" after su
allows Linux to apply root's environment (including root’s path) to your su
login. So you don't have to enter the full path of a command. Actually, su is
a “switch user” command, and can allow you to become any user (if you
know the password), not just root.
When you are finished using your su login, return to your own self by
typing exit.
34
V. Editing with Vi
There are a number of terminal mode (non-GUI) editors available in
Linux, including emacs and vi. You could always use one of the available
GUI text editors in Xwindow, but what if you are unable to start X? The
benefit of learning vi or emacs is your ability to use them from an xterm, a
character terminal, or a telnet (use ssh instead!) session, etc. We will
discuss vi here. (I don't do emacs :-)). vi in particular is useful, because you
will find it on all versions of Unix. Learn vi and you should be able to edit a
file on any Unix system.
Using Vi
You can start vi either by simply typing vi at the command prompt, or
you can specify the file you want to edit with vi filename. If the file does
not already exist, it will be created for you.
You can use the arrow keys to move around the file in command
mode. In addition, there are a number of other navigation keys described
below.
If you lose track of which mode you are in, hit the escape key twice.
You should hear your computer beep and you will know that you are in
command mode.
35
Vi command summary
Command Mode:
0 (zero) = Move cursor to beginning of current line.
$ = Move cursor to the end of current line.
x = delete the character under the cursor
X = delete the character before the cursor
dd = delete the entire line the cursor is on
:w = save and continue editing
:wq = save and quit (can use ZZ as well)
:q! = quit and discard changes
:w filename = save a copy to filename (save as)
The best way to save yourself from a messed up edit is to hit <ESC>
followed by :q! That command will quit without saving changes.
Another useful feature that can be used in command mode is the string
search. To search for a particular string in a file, make sure you are in
command mode and type
/string
Where string is your search target. After issuing the command, you
can move on to the next hit by typing "n".
36
VI. Mounting File Systems on Disks
There is a long list of file system types that can be accessed through
Linux. You do this by using the mount command. Linux has a special
directory used to mount file systems to the existing Linux directory tree.
This directory is called /mnt. It is here that you can dynamically attach new
file systems from external (or internal) storage devices that were not
mounted at boot time. Actually you can mount file systems anywhere (not
just on /mnt), but it's better for organization. Here is a brief overview.
Any time you specify a mount point you must first make sure that that
directory exists. For example to mount a floppy under /mnt/floppy you must
be sure that /mnt/floppy exists. After all, suppose we want to have a
CDROM and a floppy mounted at the same time? They can't both be
mounted under /mnt (you would be trying to access 2 file systems through
one directory!). So we create directories for each device’s file system under
the parent directory /mnt. You decide what you want to call the directories,
but make them easy to remember. Keep in mind that until you learn to
manipulate the file /etc/fstab (covered later), only root can mount and
unmount file systems.
mkdir /mnt/floppy
mkdir /mnt/cdrom
Newer distributions usually create these mount points for you, but you
might want to add others for yourself (mount points for subject disks or
images, etc. like /mnt/data or /mnt/analysis)
The Mount Command
37
• Now change to the newly mounted file system:
cd /mnt/floppy
umount /mnt/floppy
cd /mnt/cdrom
umount /mnt/cdrom
If you want to see a list of file systems that are currently mounted, just
use the mount command without any arguments or parameters. It will list
the mount point and file system type of each device on system, along with
the mount options used (if any). This is actually read from a file called
38
/proc/mounts, part of a virtual file system that keeps an up to date
“snapshot” of the current system configuration. Try the following two
commands:
mount
cat /proc/mounts
mount /mnt/floppy
mount /mnt/cdrom
39
The above mount commands look incomplete. When not enough
information is given, the mount command will look to /etc/fstab to fill in the
blanks. If it finds the required info, it will go ahead with the mount.
Note the "user" entry in the options column for some devices. This
allows non-root users to mount the devices. Very useful. To find out more
about available options for /etc/fstab, enter info fstab at the command
prompt.
Also keep in mind that default Linux installations will often create
/mnt/floppy and /mnt/cdrom for you already. After installing a new Linux
system, have a look at /etc/fstab to see what is available for you. If what you
need isn’t there, add it.
40
VII. Linux and Forensics
41
Analysis organization
Having already said that this is just an introduction, most of the work
you will do here can be applied to actual casework. The tools are standard
Linux tools, and although the example shown here is very simple, it can be
extended with some practice and a little (ok, a lot) of reading. The practice
floppy (in raw image format from a simple dd) for the following exercise is
available at:
ftp://ftp.hq.nasa.gov/pub/ig/ccd/linuxintro/practical.floppy.dd
Once you download the floppy image, put a floppy disk in your drive
and create the practice floppy with the following command (covered in
detail later):
dd if=practical.floppy.dd of=/dev/fd0
mkdir ~/evidence
The tilde (~) in front of the directory name is shorthand for “home
directory”, so when I type ~/evidence, Linux interprets it
$HOME/evidence. If I am logged in as root, the directory will be created as
/root/evidence. Note that if you are already in your home directory, then
you don't need to type ~/. Simply using mkdir evidence will work just fine.
We are being explicit for instructional purposes. Directing all of our
analysis output to this directory will keep our output files separated from
everything else and maintain case organization.
42
For the purposes of this exercise, we will be logged in as “root”. I
have mentioned already that this is generally a bad idea, and that you can
make a mess of your system if you are not careful. Many of the commands
we are utilizing here require root access (permissions on devices that you
might want to access should not be changed to allow otherwise, and doing
so would be far more complex than you think). So the output files that we
create and the images we make will be found under /root/evidence/
mkdir /mnt/analysis
Determining the structure of the disk
There are two simple tools available for determining the structure of a
disk attached to your system. The first, fdisk, we discussed eariler using the
-l option. Replace the “x” with the letter of the drive that corresponds to the
subject drive.
fdisk –l /dev/hdx
Disk /dev/hda: 255 heads, 63 sectors, 1582 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 255 2048256 b Win95 FAT32
/dev/hda2 * 256 638 3076447+ 83 Linux
/dev/hda3 639 649 88357+ 82 Linux swap
/dev/hda4 650 1582 7494322+ f Win95 Ext'd (LBA)
/dev/hda5 650 1453 6458098+ b Win95 FAT32
/dev/hda6 1454 1582 1036161 b Win95 FAT
We can redirect the output of this command to a file for later use by
issuing the command as:
fdisk –l /dev/hdx > fdisk.disk1
A couple of things to note here: The name of the output file
(fdisk.disk1) is completely arbitrary. There are no rules for extensions.
Name the file anything you want. I would suggest you stick to a convention
43
and make it descriptive. Also note that since we did not define an explicit
path for the file name, fdisk.disk1 will be created in our current directory (for
instance, /root/evidence/).
Also note that you can expect to see strange output if you use fdisk on
a floppy disk. Be aware of that if you attempt fdisk on the practice floppy.
Try it on your harddrive instead to see sample output. Don’t use fdisk on
the practice floppy. The output won’t make sense.
Creating a forensic image of the suspect disk
Make an image of the practice disk. This is your standard forensic
image of a suspect disk. Execute the command from within the
/root/evidence/ directory:
This takes your floppy device (/dev/fd0) as the input file (if) and writes the
output file (of) called image.disk1 in the current directory (/root/evidence/).
The bs option specifies the block size. This is really not needed for most
block devices (hard drives, etc.) as the Linux kernel handles the actual block
size. It’s added here for illustration
For the sake of safety and practice, change the read-write permissions
of your image to read-only.
The 444 gives all users read-only access. If you are real picky, you
could use 400. Note that the owner of the file is the user that created it.
Now that you have created an image file, you can restore the image to
another disk for analysis and viewing. Put another (blank) floppy in and
type:
This is the same as the first dd command, only in reverse. Now you
are taking your image (the input file “if”) and writing it to another disk (the
output file “of”) to be used as a backup or as a working copy for the actual
analysis.
44
Note that using dd creates an exact duplicate of the physical device.
This includes all the file slack and unallocated space. We are not simply
copying the logical file structure. Unlike many other forensic imaging tools,
dd does not fill the image with any proprietary data or information. It is a
simple bit stream copy from start to end. This (in my ever-so-humble
opinion) has a number of advantages, as we will see later.
Mounting a restored image
Mount the restored (cloned) working copy and view the contents.
Remember, we are assuming this is a DOS formatted disk from a Win 98/95
machine.
This will mount your working copy (the new floppy you created from
the forensic image) on “/mnt/analysis”. The “–o ro,noexec” specifies the
options ro (read-only) and noexec (prevents the execution of binaries from
the mount point) in order to protect the disk from you, and your system (and
mountpoint) from the contents of the disk. There are other useful mount
options as well, such as noatime. See the man page for more details.
umount /mnt/analysis
We use the same mount command and the same options, but this time
we include the option “loop” to indicate that we want to use the loop device
to mount the file system within the image file, and we specify a disk
(partition) image rather than a disk device. Change to the directory where
you created the image and type:
45
mount -t vfat -o ro,noexec,loop image.disk1 /mnt/analysis
umount /mnt/analysis
File Hash
One important step in any analysis is verifying the integrity of your
data both before after the analysis is complete. You can get a hash (CRC,
MD5, or SHA) of each file in a number of different ways. We will use the
SHA hash. SHA is a hash signature generator that supplies a 160-bit
“fingerprint” of a file or disk. It is not feasible for someone to
computationally recreate a file based on the SHA hash. This means that
matching SHA signatures mean identical files.
We can get an SHA sum of a disk by changing to our evidence
directory (i.e. /root/evidence) and doing (note that the following commands
can be replaced with md5sum if you prefer to use MD5 sums):
sha1sum /dev/fd0
or
sha1sum /dev/fd0 > SHA.disk1
We can get a hash of each file on the disk using the find command
and an option that allows us to execute a command on each file found. We
can get a very useful list of SHA hashes for every file on a disk (once it is
mounted, as in the loop mount command on the previous page) by changing
to the /mnt/analysis directory:
46
mount -t vfat -o ro,noexec,loop image.disk1 /mnt/analysis
cd /mnt/analysis
You can also use Linux to do your verification for you. To verify that
nothing has been changed on the original floppy, you can use the -c option
with sha1sum. If the disk was not altered, the command will return “ok”.
Make sure the floppy is in the drive and type:
sha1sum -c /root/evidence/SHA.disk1
If the SHA hashes match from the floppy and the original SHA output
file, then the command will return “OK” for /dev/fd0. The same can be done
with the list of file SHAs. Mount the floppy on /mnt/analysis, change to that
directory and issue the command:
sha1sum -c /root/evidence/SHA.filelist
Again, the SHA hashes in the file will be compared with SHA sums
taken from the floppy (at the mount point). If anything has changed, the
program will give a “failed” message. Unchanged files will be marked
“OK”.
The analysis
You can now view the contents of the read-only mounted or restored
disk or loop-mounted image. If you are running the X window system, then
you can use your favorite file browser to look through the disk. In most (if
not all) cases, you will find the command line more useful and powerful in
order to allow file redirection and permanent record of your analysis. We
will use the command line here.
47
We are also assuming that you are issuing the following commands
from the proper mount point (/mnt/analysis/). If you want to save a copy of
each command’s output, be sure to direct the output file to your evidence
directory (/root/evidence/)
Navigate through the directories and see what you can find. Use the ls
command to view the contents of the disk. The command in the following
form might be useful:
ls –al
This will show all the hidden files (-a), give the list in long format to
identify permission, date, etc. (-l). You can also use the –R option to list
recursively through directories. You might want to pipe that through less.
ls –alR | less
Making a list of all files
Get creative. Take the above command and redirect the output to
your evidence directory. With that you will have a list of all the files and
their owners and permissions on the suspect disk. This is a very important
command. Check the man page for various uses and options. For example,
you could use the –i option to include the inode in the list, the –u option can
be used so that the output will include and sort by access time (when used
with the –t option).
You could also get a list of the files, one per line, using the find
command and redirecting the output to another list file:
Now use the grep command on either of the file lists for whatever
strings or extensions you want to look for.
48
grep -i jpg filelist.list
This command looks for the pattern “jpg” in the list of files, using the
filename extension to alert us to a JPEG file.
Making a list of file types
What if you are looking for JPEG’s but the name of the file has been
changed, or the extension is wrong? You can also run the command file on
each file and see what it might contain.
file filename
The file command compares each file’s header (the first few bytes of a
raw file) with the contents of the “magic” file (usually found in
/usr/share/magic). It then outputs a description of the file.
View the list with the more command, and if you are looking for
images in particular, then use grep to specify that:
This command would stream the contents of our filetype.list file using
the cat command and pipe the output through grep, looking for instances of
the string “image”.
Viewing files
For text files and data files, you might want to use cat, more or less to
view the contents.
cat filename
more filename
49
less filename
Be aware that if the output is not standard text, then you might corrupt
the terminal output (type “reset” at the prompt and it should clear up). It is
best to run these commands in a terminal window in X so that you can
simply close out a corrupted terminal and start another. Using the file
command will give you a good idea of which files will be viewable.
If you are currently running the X window system, you can use any of
the graphics tools that come standard with whichever Linux distribution you
are using. gqview is one graphics tool for the Gnome desktop that will
display thumbnails of all the recognized graphic files in a directory.
Experiment a little. konqueror from the KDE desktop has a feature that
will create a very nice html image gallery for you from all images in a
directory. There are g-scripts that will do the same for the Nautilus file
manager under Gnome.
Once you are finished exploring, be sure to unmount the floppy (or
loop mounted disk image). Again, make sure you are not anywhere in the
mount point when you try to unmount, or you will get the “busy” error.
umount /mnt/analysis
50
Searching unallocated and slack space for text
Now let’s go back to the original image. The restored disk (or loop
mounted disk image) allowed you to check all the files and directories
(logical view). What about unallocated and slack space (physical view)?
We will now analyze the image itself, since it was a byte for byte copy and
includes data in the unallocated areas of the disk, as well as file slack space.
Let’s assume that we have seized this disk from a former employee of
a large corporation. The would-be cracker sent a letter to the corporation
threatening to unleash a virus in their network. The suspect denies sending
the letter. This is a simple matter of finding the text from a deleted file
(unallocated space).
First, change back to the directory in which you created the image,
whether it was the root’s home directory, or a special one you created.
cd /root/evidence
Now we will use the grep command to search the image for any
instance of an expression or pattern. We will use a number of options to
make the output of grep more useful. The syntax of grep is normally:
$50,000
ransom
unleash a virus
51
grep –aibf searchlist.txt image.disk1 > hits.txt
Looking at the grep command we see that we are asking grep to use
the list we created in “searchlist.txt” for the patterns we are looking for. This
is specified with the “-f listfile” option. We are telling grep to search
image.disk1 for these patterns, and we are redirecting the output to a file
called hits.txt, so we can record the output and view them at our leisure. The
–a option tells grep to process the file as if it were text, even if it’s binary.
The option -i tells grep to ignore upper and lower case. And the -b option
tells grep to give us the byte offset of each hit so we can find the line in xxd
or one of the graphical hex editors, like GHex.
Once you run the command above, you should have a new file in your
current directory called hits.txt. View this file with less or more or any text
viewer. Keep in mind that strings might be best for the job. Again, if you
use more or less, you run the risk of corrupting your terminal if there are
non-ASCII characters. We will simply use cat to stream the entire contents
of the file to the standard output. The file hits.txt should give you a list of
lines that contain the words in your searchlist.txt file. In front of each line is
a number that represents the byte offset for that “hit” in the image file.
cat hits.txt
52
If you want to cheat a little, and use a GUI, try GHex. Find it on the
KDE or Gnome menus, or simply type ghex & in a terminal window. It is a
standard hex editor. Open the image file, and click on <Edit> and then
<Goto Byte>. Type in the byte offset given in your hits.txt file and it should
take you to that byte in the hex screen. The ASCII equivalent is displayed
on the right.
53
VIII. Common Forensic Issues
Handling large disks
The example used in this text utilizes a file system on a floppy disk.
What happens when you are dealing with larger hard disks? When you
create an image of a disk drive with the dd command there are a number of
components to the image. These components can include a boot sector,
partition table, and the various partitions (if defined).
When you attempt to mount a larger image with the loop device, you
find that the mount command is unable to find the file system on the disk.
This is because mount does not know how to “recognize” the partition table.
The easy way around this (although it is not very efficient for large disks)
would be to create separate images for each disk partition that you want to
analyze. For a simple hard drive with a single large partition, you would
create two images.
The first command gets you a full image of the entire disk for backup
purposes, including the boot record and partition table. The second
command gets you the partition. The resulting image from the second
command can be mounted via the loop device.
Note that although both of the above disks will contain the same file
system with the same data, the sha1sums will obviously not match.
One method for handling larger disks (mounting the image with the
loop device) is to send the mount command a message to skip trying to
mount the first 63 sectors of the image. These sectors are used to contain
information (like the MBR) that is not part of a normal data partition. We
know that each sector is 512 bytes, and that there are 63 of them. This gives
us an offset of 32256 bytes from the start of our image to the first partition
we want to mount. This is then passed to the mount command as an option:
54
This effectively “jumps over” the first 63 sectors of the image and
goes straight to the “boot sector” of the first partition, allowing the mount
command to work properly.
You could also use NASA’s enhanced loopback driver, which we will
discuss a little later.
When you are dealing with larger disks (over 2GB), you must also
concern yourself with the size of your image files. If your Linux distribution
relies on the 2.2.x kernel then you will encounter a file size limit of 2GB (on
x86 systems). The Linux 2.4.x kernel solves this problem. You can either
compile the 2.4.x kernel on your current system, or use a distribution that
includes the 2.4.x kernel in its default installation. Just about any
distribution from anytime this century (!) will have the 2.4 kernel.
Now that we know about the issues surrounding creating large images
from whole disks, what do we do if we run into an error? Suppose you are
creating a disk image with dd and the command exits halfway through the
process with a read error? We can instruct dd to attempt to read past the
errors using the conv=noerror option. In basic terms, this is telling the dd
command to ignore the errors that it finds, and attempt to read past them.
When we specify the noerror option it is a good idea to include the sync
option along with it. This will “pad” the dd output wherever errors are
found and ensure that the output will be “synchronized” with the original
disk. This may allow file system access and file recovery where errors are
not fatal. The command will look something like:
In addition to the structure of the images and the issues of image sizes,
we also have to be concerned with memory usage and our tools. You might
find that grep, when used as illustrated in our floppy analysis example,
might not work as expected with larger images and could exit with an error
similar to:
The most apparent cause for this is that grep does its searches line by
line. When you are “grepping” a large disk image, you might find that you
55
have a huge number of bytes to read through before grep comes across a
newline character. What if grep had to read 200MB of data before coming
across a newline? It would “exhaust” itself (the input buffer fills up).
Let’s say we want to take all of the control characters streaming into
grep from the disk image and change them to newlines. We can use the
translate command, tr, to accomplish this. Check out man tr for more
information about this powerful command:
56
We can use a special device as a source of zeros. This can be used to
create empty files and wipe portions of disks. You can write zeros to an
entire disk using the following command:
This starts at the beginning of the drive and writes zeros in every
sector in 4096 byte chunks. Specifying larger block sizes can speed the
writing process. Experiment with different block sizes and see what effect it
has on the writing speed (i.e. 32k, 64k, etc.). I’ve wiped 60GB disks in
under an hour on a fast IDE controller with the proper drive parameters.
Specific drive parameters can be set using the hdparm command. Check
hdparm’s man page for available options. For instance, setting dma on a
drive can dramatically speed things up.
So how do we verify that the write (of zero’s) was a success? You
could check random sectors with a hex editor, but that’s not realistic for a
large drive. One of the best methods would be to use the xxd command
(command line hexdump) with the “autoskip” option (works if a drive is
wiped with 0x00). The output of this command on a zero’d drive would give
just three lines. The first line, starting at offset zero with a row of zeros in
the data area, followed by an asterisk (*) to indicate identical lines, and
finally the last line, with the final offset followed by the remaining zeros in
the data area. Here’s and example of the command on a zero’d drive
(floppy) and its output.
xxd -a /dev/fd0
0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
0167ff0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
57
IX. Advanced (Beginner) Forensics
The following sections are more advanced and detailed. New tools
are introduced to help round out some of your knowledge and provide a
more solid footing on the capabilities of the Linux command line. The
topics are still at the beginner level, but you should be at least somewhat
comfortable with the command line before tackling the exercises. Although
I’ve included the commands and much of the output for those who are
reading this without the benefit of a Linux box nearby, it is important that
you follow along on your own system as we go through the practical
exercises. Typing at the keyboard and experimentation is the only way to
learn.
Let’s dig a little deeper into the command line. Often there are
arguments made about the usefulness of the command line interface (CLI)
versus a GUI tool for analysis. I would argue that in the case of large sets of
regimented data, the CLI can sometimes be faster and more flexible than
many GUI tools available today.
Create a directory called “logs” and download the file logs.tar.gz into
that directory:
ftp://ftp.hq.nasa.gov/pub/ig/ccd/linuxintro/logs.tar.gz
58
tar tzvf logs.tar.gz
-rw------- root/root 8296 2003-10-29 16:14:49 messages
-rw------- root/root 8302 2003-10-29 16:17:38 messages.1
-rw------- root/root 8293 2003-10-29 16:19:32 messages.2
-rw------- root/root 4694 2003-10-29 16:23:18 messages.3
-rw------- root/root 1215 2003-10-29 16:23:33 messages.4
The archive contains 5 log files from a Unix system. The messages
logs contain entries from a variety of sources, including the kernel and other
applications. The numbered files result from log rotation. As the logs are
filled, they are rotated and eventually deleted. On most Unix systems, the
logs are found in /var/log/ or /var/adm.
Each line in the log files begin with a date and time stamp. Next
comes the hostname followed by the name of the application that generated
the log message. Finally, the actual message is printed.
Let’s assume these logs are from a victim system, and we want to
analyze them and parse out the useful information. We are not going to
worry about what we are actually seeing here, our object is to understand
how to boil the information down to something useful.
First of all, rather than parsing each file individually, let’s try and
analyze all the logs at one time. They are all in the same format, and
essentially they comprise one large log. We can use the cat command to add
all the files together and send them to standard output. If we work on that
data stream, then we are essentially making one large log out of all five logs.
Can you see a potential problem with this?
59
If you look at the output, you will see that the dates ascend and then
jump to an earlier date and then start to ascend again. This is because the
later log entries are added to the bottom of each file, so as the files are added
together, the dates appear to be out of order. What we really want to do is
stream each file backwards so that they get added together with the most
recent date in each file at the top instead of at the bottom. In this way, when
the files are added together they are in order. In order to accomplish this, we
use tac (yes, that’s cat backwards).
Beautiful. The dates are now in order. We can now work on the
stream of log entries as if they were one large (in order) file.
Feb 8
Feb 8
Feb 8
…
This command will stream all the log files (each one from bottom to
top) and send the output to awk which will print the first field (month - $1),
followed by a space (“ “), followed by the second field (day - $2). This
shows the month and day for every entry. Suppose I just want to see one of
each date when an entry was made. I don’t need to see repeating dates. I
ask to see one of each unique line of output with uniq:
60
tac messages* | awk ‘{print $1 “ “ $2}’ | uniq | less
Feb 8
Nov 22
Nov 21
Nov 20
…
This removes repeated dates, and shows me just those dates with log
activity. If a particular date is of interest, I can grep the logs for that
particular date (note there are 2 spaces between “Nov” and “4”, one space
will not work):
Of course, we have to keep in mind that this would give us any lines
where the string “Nov 4” resided, not just in the date field. To be more
explicit, we could say that we only want lines that start with “Nov 4”, using
the “^”:
Also, if we don’t know that there are two spaces between “Nov” and
“4”, we can tell grep to look for any number of spaces between the two:
The above grep expression translates to “Lines starting (^) with the
string “Nov” followed by zero or more (*) of the preceding characters
([/space/]) followed by a 4”. Obviously, this is a complex issue. Knowing
how to use regular expression will give you huge flexibility in sorting
through and organizing large sets of data.
61
As we look through the log files, we may come across entries that
appear suspect. Perhaps we need to gather all the entries that we see
containing the string “Did not receive identification string from <IP>” for
further analysis.
Now we just want the date (fields 1 and 2), the time (field 3) and the
remote IP address that generated the log entry. The IP address is the last
field. Rather than count each word in the entry to get to the field number of
the IP, we can simply use the variable “$NF”, which means “number of
fields”. Since the IP is the last field, its field number is equal to the number
of fields:
62
This can all be redirected to an analysis log or text file for easy
addition to a report (note that “> report.txt” creates the report file, “>>
report.txt” appends to it):
We can also get a sorted (sort) list of the unique (-u) IP addresses
involved in the same way:
less report.txt
The resulting list of IP addresses can also be fed to a script that does
nslookup or whois database queries.
As with all the exercises in this document, we have just sampled the
abilities of the Linux command line. It all seems somewhat convoluted to
the beginner. After some practice and experience with different sets of data,
you will find that you can glance at a file and say “I want that information”,
and be able to write a quick piped command to get what you want in a
readable format in a matter of seconds. As with all language skills, the
Linux command line “language” is perishable. Keep a good reference handy
and remember that you might have to look up syntax a few times before it
becomes second nature.
63
Fun with DD
We’ve already done some simple imaging and wiping using dd, let’s
explore some other uses for this flexible tool. dd is sort of like a little
forensic Swiss army knife (talk about over-used clichés!). It has lots of
applications, limited only by your imagination.
Splitting files and images
One function we might find useful would be the ability to split images
up into usable chunks, either for archiving or for use in another program.
We will first discuss using split on its own, then in conjunction with dd for
“on the fly” splitting.
For example, you might have a 10GB image that you want to split into
640MB parts so they can be written to CD-R media. Or, if you use a
program such as Ilook Investigator and need files no larger than 2GB (for a
fat32 partition), you might want to split the image into 2GB pieces. For this
we use the split command.
split normally works on lines of input (i.e. from a text file). But if we
use the –b option, we force split to treat the file as binary input and lines are
ignored. We can specify the size of the files we want along with the prefix
we want for the output files. The command looks like:
This would result in 3 files (2GB in size) each named with the prefix
“image.split.” as specified in the command, followed by “aa”, “ab”, “ac”,
and so on:
64
image.split.aa
image.split.ab
image.split.ac
In this case, instead of giving the name of the file to be split in the
split command, we give a simple “-“. The single dash is a descriptor that
means “standard input”. In other words, the command is taking its input
from the data pipe provided by the standard output of dd.
Once we have the image, the same technique using cat will allow us to
reassemble it for hashing or analysis.
For practice, let’s take the practical exercise floppy disk we used earlier and
try this method on that disk, splitting it into 360k pieces:
sha1sum /dev/fd0
f5ee9cf56f23e5f5773e2a4854360404a62015cf /dev/fd0
65
ls –lh
-rw-r--r-- 1 root root 360k Aug 14 08:13 floppy.split.aa
-rw-r--r-- 1 root root 360k Aug 14 08:13 floppy.split.ab
-rw-r--r-- 1 root root 360k Aug 14 08:13 floppy.split.ac
-rw-r--r-- 1 root root 360k Aug 14 08:13 floppy.split.ad
sha1sum new.floppy.image
f5ee9cf56f23e5f5773e2a4854360404a62015cf new.floppy.image
Looking at the output of the above commands, we see that all the sha1sum’s
match. We find the same hash for the disk, for the split images “cat-ed”
together, and for the newly reassembled image.
Data Carving with dd
In this next example, we will use dd to carve a JPEG image from a
chunk of raw data. By itself, this is not a real useful exercise. There are lots
of tools out there that will “carve” files from forensic images, including a
simple cut and paste from a hex editor. However, the purpose of this
exercise is to help you become more familiar with dd. In addition, you will
get a chance to use a number of other tools in preparation for the “carving”.
This will help familiarize you further with the Linux toolbox. First you will
need to download the raw data chunk from:
ftp://ftp.hq.nasa.gov/pub/ig/ccd/linuxintro/image_carve.raw
66
Have a brief look at the file image_carve.raw with your wonderful
command line hexdump tool, xxd:
This exercise starts with the assumption that we are familiar with
standard file headers. Since we will be searching for a standard JPEG image
within the data chunk, we will start with the stipulation that the JPEG header
begins with hex ffd8 with a six-byte offset to the string “JFIF”. The end of
the standard JPEG is marked by hex ffd9.
Let’s go ahead with step 1: Using xxd, we pipe the output of our
image_carve.raw file to grep and look for the start of the JPEG4:
4
The perceptive among you will notice that this is a “perfect world” situation. There are a number of
variables that can make this operation more difficult. The grep command can be adjusted for many
situations using a complex regular expression (outside the scope of this document).
67
As the output shows, we’ve found the pattern “ffd8” near the string
“JFIF”. The start of a standard JPEG file header has been found. The offset
(in hex) for the beginning of this line of xxd output is 00052a0. Now we
can calculate the byte offset in decimal. For this we will use the bc
command. bc is a command line “calculator”, useful for conversions and
calculations. It can be used either interactively or take piped input. In this
case we will echo the hex offset to bc, first telling it that the value is in base
16. bc will return the decimal value.
It’s important that you use uppercase letters in the hex value. Note
that this is NOT the start of the JPEG, just the start of the line in xxd’s
output. The “ffd8” string is actually located another 4 bytes farther into that
line of output. So we add 4 to the start of the line. Our offset is now 21156.
We have found and calculated the start of the JPEG image in our data chunk.
Since we already know where the JPEG starts, we will start our search
for the end of the file from that point. Again using xxd and grep we search
for the string:
Because that is the offset for the start of the line, we need to add 2 to
the value to include the ffd9 (giving us 27766). Now that we know the start
and the end of the file, we can calculate the size:
68
echo "27766 - 21156" | bc
6610
We now know the file is 6610 bytes in size, and it starts at byte offset
21156. The carving is the easy part! We will use dd with three options:
You should now have a file in your current directory called carv.jpg.
If you are in X, simply use the xview command to view the file (or any other
image viewer) and see what you’ve got.
xview carv.jpg
Now we can try a more useful exercise in carving with dd. Often, you
will obtain or be given a dd image of a full disk. At times you might find it
desirable to have each separate partition within the disk available to search
or mount. Remember, you cannot simply mount an entire disk image, only
the partitions.
69
The method we will use in this exercise entails identifying the
partitions within a dd image using the standard loopback device along with
fdisk or sfdisk. We will then use dd to carve the partitions out of the image.
First, let’s grab the practice disk image that we will be working on.
This is a dd image of a 330MB disk from a Linux system that was
compromised (“hacked”).
ftp://ftp.hq.nasa.gov/pub/ig/ccd/linuxintro/able2.tar.gz
The tar archive contains the disk image, the MD5 digest values, and
the imaging log file with information collected during the imaging process.
Once you have downloaded the file, check the md5sum (it should
match the output below):
md5sum able2.tar.gz
a0cef6c441ae84ef931c541d73ee619f able2.tar.gz
The file name is derived from the original hostname of the machine
that was compromised (“hacked”). Very often we name our cases and
evidence with the original hostname of the machine we are investigating.
70
This executes the tar command with the options –x to extract the
files, -z to decompress the files, -v for verbose output, and –f to specify the
file.
ls -lh
total 464M
-rwxrwxr-x 1 root root 330M Aug 10 21:16 able2.dd
-rwxrwxr-x 1 root root 3.6k Aug 11 07:56 able2.log
-rwxrwxr-x 1 root root 134M Aug 11 14:42 able2.tar.gz
-rwxrwxr-x 1 root root 43 Aug 10 21:16 md5.dd
-rwxrwxr-x 1 root root 43 Aug 10 21:04 md5.hdd
The output of ls –lh (the –lh is for “long list with human readable
sizes”) shows the 330MB dd image, the logfile and two files that record the
original MD5 hashes, one for the image (md5.dd) and one for the original
disk (md5.hdd). At this point you can check the hash of the able2.dd and
compare it to the value stored in md5.dd to be sure the image is intact.
cat md5.dd
02b2d6fc742895fa4af9fa566240b880 able2.dd
md5sum able2.dd
02b2d6fc742895fa4af9fa566240b880 able2.dd
The file able2.log was created from the output of various commands
used during the evidence collection process. The log includes information
about the investigator that gathered the evidence, information about the
system, and the output of commands including hdparm, fdisk, sfdisk and
hashing functions. We create the log file by appending (“>>”) the output of
the commands, in sequence, to the log:
71
command >> logfile.txt
Look at the log file, able2.log, using less and scroll down to the
section that shows the structure of the disk (the output of fdisk –l /dev/hdd
and sfdisk –l –uS /dev/hdd):
#####################################################
sfdisk output for SUBJECT disk:
The output shown above is directly from the victim hard drive (the
machine able2), recorded prior to obtaining the dd image. It shows that
there are 4 partitions on the drive. The data partitions are hdd1, hdd2 and
hdd4. The hdd3 partition is actually a swap partition (for virtual memory).
Remember that the designation hdd indicates that the victim hard drive was
attached to our forensic workstation as the slave drive on the secondary IDE
controller during the imaging process, NOT how it was attached in the
original machine.
72
The command sfdisk –l –uS /dev/hdd gave us the second listing
above and shows the partition sizes in units of “sectors” (-uS). The output
also gives us the start of the partition. For our partition carving exercise (as
with the raw data carving), all we need is the starting offset, and the size.
Let’s go ahead and dd out each partition. If you have the output of sfdisk –l
–uS /dev/hdx, the job is easy.
This will leave you with four able2.part*.dd files in your current
directory that can now be loop mounted.
What if you have a dd image of the full disk, but no log file or access
to the original disk, and therefore no info from sfdisk or fdisk?
73
sfdisk –l –uS /dev/loop0
Disk /dev/loop0: cannot get geometry
Aside from the error messages at the beginning of the output, notice
that the actual disk geometry (in sectors) matches that taken from the
original disk! The partitions are now noted as /dev/loop0p*, indicating,
“loop device zero, partitions 1 through 4”. In a pinch, we could use this to
gather information from the standard loop device to determine the disk
partitioning5.
When you are finished with the loop0 association, be sure to remove it:
losetup –d /dev/loop0
5
The purpose of this section is to explore the concept of the loop devices in more detail. In actuality, the
original dd image is a file just like /dev/loop0 or /dev/hdx. Try the fdisk or sfdisk commands on the dd
image itself to see what I mean.
74
image if the original drive is not available. We also learned that we couldn’t
use the standard loopback driver to actually mount the partitions.
ftp://ftp.hq.nasa.gov/pub/ig/ccd/enhanced_loopback/
http://www.crazytrain.com/monkeyboy/FSK.pdf
http://www.crazytrain.com
75
Determining the Subject Disk Filesystem Structure
Going back to our able2 case dd images, we now have the original
image along with the partition images that we carved out.
So when you have a disk with multiple partitions, how do you find out
the structure of the file system? Earlier in this paper we discussed the
/etc/fstab file. This file maintains the mounting information for each file
system, including the physical partition; mount point, file system type, and
options. Once we find this file, reconstructing the system is easy. With
experience, you will start to get a feel for how partitions are setup, and
where to look for the fstab. To make things simple here, just mount each
partition (loopback, read only) and have a look around.
One thing we might like to know is what sort of file system is on each
partition before we try and mount them. We can use the file command to do
76
this6. Remember from our earlier exercise that the file command determines
the type of file by looking for “header” information.
file able2.part*
able2.part1.dd: Linux rev 1.0 ext2 filesystem data…
able2.part2.dd: Linux rev 1.0 ext2 filesystem data…
able2.part3.dd: Linux/i386 swap file (new style)…
able2.part4.dd: Linux rev 1.0 ext2 filesystem data…
So now we see that the logical file system was constructed from three
separate partitions (note that /dev/hda here refers to the disk when it is
mounted in the original system):
6
Keep in mind that the file command relies on the contents of the magic file to determine a file type. If
this command does not work for you in the following example, then it is most likely because the magic file
on your system does not inlcude headers for filesytem types.
7
You can also use the auto filesystem type under the mount command, but I prefer to be explicit. Check
man mount for more information.
77
|_home/ (data on hda2)
|_lib/ (data on hda2)
|_opt/ (data on hda2)
|_proc/ (data on hda2)
|_usr/ Å mounted from/dev/hda4 (data on hda4)
|_root/ (data on hda2)
|_sbin/ (data on hda2)
|_tmp/ (data on hda2)
|_var/ (data on hda2)
Now we can create the original file system at our analysis mount point by
creating separate directories for each partition. The mount point
/mnt/analysis already exists. We create the other two with:
mkdir /mnt/analysis/boot
mkdir /mnt/analysis/usr
78
At this point we can run all of our searches and commands just as we
did for the previous floppy disk exercise on a complete file system “rooted”
at /mnt/analysis.
As always, you should know what you are doing when you mount a
complete file system on your forensic workstation. Be aware of options to
the mount command that you might want to use (check man mount for
options like “nodev” and “nosuid”, “noatime” etc.). Take note of where
links point to from the subject file system. Note that we have mounted the
partitions “read only” (ro). Remember to unmount each partition when you
are finished exploring.
79
X. Advanced Forensic Tools
So now you have some experience with using the Linux command
line and the powerful tools that are provided with a Linux installation.
However, as forensic examiners, we soon come to find out that time is a
valuable commodity. While learning to use the command line tools native to
a Linux install is useful for a myriad of tasks in the “real world”, it can also
be tedious. After all, there are Windows based tools out there that allow you
to do much of what we have discussed here in a simple point and click GUI.
Well, the same can be said for Linux.
80
Sleuthkit
The first of the tools we will cover here is actually not a GUI tool at
all, but rather a collection of command line tools. We cover them here
because we will soon introduce a tool (Autopsy) that provides a nice GUI
wrapper.
Installation is easy. You can simply un-tar the file then change in to
the resulting directory:
81
The Sleuthkit’s tools are organized by what the author calls a “layer”
approach.
Let’s have a look at a couple of the file system and file name layer
tools, fsstat and fls. We will run them against our able2 partition images8.
For the sake of this analysis, the information we are looking for is located on
the root partition.
Remember from our previous analysis of the able2 dd images that the
root (“/”) file system is located on the second partition (able2.part2.dd).
./fsstat /root/able2/able2.part2.dd
8
The Sleuthkit works on partition images, not on whole disk images. This is one reason why it might be
useful to learn how to carve partitions (or take partition dd images).
82
You should see the following output (partial):
META-DATA INFORMATION
--------------------------------------------
Inode Range: 1 - 12880
Root Directory: 2
CONTENT-DATA INFORMATION
--------------------------------------------
Fragment Range: 0 - 51299
Block Size: 1024
Fragment Size: 1024
<CONTINUES>
We can get more information using the fls command. fls lists the file
names and directories contained in a file system, with a number of options.
If you type “./fls” on its own, you will see the available options (view the
man page for a more complete explanation).
83
./fls –f linux-ext2 –Frd /root/able2/able2.part2.dd
In this case, we are running the fls command against an Ext2 file
system (-f linux-ext2), showing only file entries (-F), descending into
directories (-r), and displaying deleted entries (-d). The output gives us the
file name and the inode to which that file is associated.
Now let’s use a couple of Metadata (inode) layer tools included with
the Sleuthkit. An inode has unique number and is assigned to a file. The
number corresponds to the inode table, allocated when a partition is
formatted. The inode contains all the metadata available for a file, including
the modified/accessed/changed times and all the data blocks allocated to that
file.
84
First we are going to use istat from the Sleuthkit. Remember that
fsstat took a file system as an argument and reported statistics about that file
system. Well, istat does the same thing; only it works on a specified inode.
If you look at the output of our fls command, you will see a file called
lrkn.tgz located in the /root directory (the last file in the output of our fls
command). The inode displayed by fls for this file is 2139. Note that this
same inode also points to a file in /dev (same file, different location). We
are going to use istat to gather some information about inode 2139.
Remember, we are in the sleuthkit/bin directory, so we use “./” to indicate
that the command (not in our path) is run from the current directory:
inode: 2139
Not Allocated
Group: 1
uid / gid: 0 / 0
mode: -rw-r--r--
size: 3639016
num of links: 0
Inode Times:
Accessed: Sun Aug 10 00:18:38 2003
File Modified: Sun Aug 10 00:08:32 2003
Inode Modified: Sun Aug 10 00:29:58 2003
Deleted: Sun Aug 10 00:29:58 2003
Direct Blocks:
22811 22812 22813 22814 22815 22816 22817 22818
22819 22820 22821 22822 22824 22825 22826 22827
...<snipped>
32225 32226 32227 32228 32229 32230 32231 32232
32233 32234
Indirect Blocks:
22823 23080 23081 23338 23595 23852 24109 24366
30478 30735 30992 31249 31506 31763 32020
85
This reads the inode statistics (./istat), on an ext2 (-f linux-ext2)
partition (/root/able2/able2.part2.dd) from inode 2139. There is a large
amount of output here, showing all the inode information and the direct and
indirect blocks9 that contain all of the file’s data. We can either pipe the
output to a file for logging or evidence results, or we can send it to less for
viewing.
We now have the name of the deleted file (from fls) and the inode
information, including where the data is stored (from istat). Now we are
going to use the icat command from the Sleuthkit to grab the actual data
contained in the data blocks referenced from the inode. icat also takes the
“inode” as an argument and reads the content of the data blocks that are
assigned to that inode, sending it to standard output.
We are going to send the contents of the data blocks assigned to that
inode to a file for closer examination. Again, we issue the following
command from the sleuthkit/bin directory:
This runs the icat command on our ext2 (-f linux-ext2) partition
(able2.part2.dd) and streams the contents of the data blocks associated with
inode 2139 to the file /root/lrkn.tgz.2139. The filename is arbitrary; I
simply took the name of the file from fls and appended the inode number to
indicate that it was recovered. Normally this output should be directed to
some results directory.
file lrkn.tgz.2139
lrkn.tgz.2139: gzip compressed data, was "lrkn.tar", from Unix
Have a look at the contents of the recovered archive (pipe the output
through less…it’s long). Remember that the “t” option lists the contents of
the archive.
9
For a detailed description of “direct” and “indirect” blocks, see
http://e2fsprogs.sourceforge.net/ext2intro.html.
86
Don’t just haphazardly extract an archive without knowing what it
will write, or especially where10:
The difference with this tar command is that we specify that we want
the output sent to stdout (“O”) so we can redirect it. We also specify the
name of the file that we want extracted from the archive (lrk3/README).
This is all redirected to a new file called /root/README.2139.
If you read that file, you will find that we have uncovered a “rootkit”,
full of trojanized programs used to hide a hacker’s activity.
10
Let’s face it, it would be BAD to have an archive that contains a bunch of trojans and other nasties (evil
kernel source or libraries, etc.) overwrite those on your system. Be extremely careful with archives.
87
We are now going to look at an easier way to “point and click”
your way through a Sleuthkit exam, organizing your investigation as you go
using Autopsy.
Autopsy
mkdir /root/autopsy_evid/
3. You can also use a hash database for data reduction purposes (known
good files and/or known bad files). While we are not going to use
such a database here, be aware of the capability. Proper use of hash
databases can often be a huge time saver.
88
Change into the resulting autopsy-1.75 directory and type make. The
program will search for several files, and then prompt you for the location of
your Sleuthkit install. Enter the path. When you are asked about the
location of your NSRL database, just hit enter (unless you installed it).
Finally, enter the path of our Evidence Locker (/root/autopsy_evid).
./autopsy
Once the Autopsy process starts, you will want to open your browser
and copy the resulting URL into your browser window.
=========================================
=========================================
Open an HTML browser on the remote host and paste this URL in it:
http://localhost:9999/30982529072506971042/autopsy
89
Copying the URL shown above (yours might differ) and pasting it into
your browser results in the Autopsy HTML interface being displayed. Take
note of the “Help” button in the lower right. The HTML help pages are
detailed and extremely useful if you get stuck or curious:
90
Click on “New Case” again, and then read the information that
Autopsy provides on the steps it has taken (creating new directories, etc.).
You are then taken to the “Case Gallery”. When you have more than
one case started, they will all be displayed here. As you start Autopsy, you
will select the case with the corresponding radio button and then click “ok”
to go to that case.
After entering the case that we just created, we are presented with a
screen that tells us that we need to add a “host” in the “Host Gallery”. The
case name is displayed in the top left hand corner:
91
by name or IP address, connected to the network (local or wide area). A
host computer can be either a victim or a “hostile”. Both require forensic
examination in most cases. Details on network intrusion investigations are
outside the scope of this document.
Enter the “Add Host” section and fill in the required information:
92
Figure 6. A single host entered in the "Host Gallery"
Now that we have the case defined, and a host within that case
defined, we need to tell the host about the different forensic images that
make up our evidence gathered from able2. Click “ok” (above) to enter the
able2 “Host Manger” area. Again, if there were multiple hosts defined for
this case, we would select the host we want to manage with the appropriate
radio button.
We are now in the Host Manager (above). Notice that “No images
have been added” is telling us that there is not yet any evidence associated
with this host. We need to add the appropriate images, so click on “Add
Image”.
93
Figure 8. Adding the partition images to the "Host Manager" for our host
94
In most of our Sleuthkit commands from the previous exercise, we
had to specify the file system type with a command option (-f linux-ext2).
In the above dialog box, we specify it in a dropdown box. Any operation
taken on that image will apply that file system type.
11
See the section Determining the Subject Disk Filesystem Structure on page 76.
95
The image above shows the completed Host Manager entries for our
case. We are now ready to explore Autopsy, and the powerful forensic
capabilities it gives us.
Let’s have a look at some of the commands and steps we took using
the Sleuthkit’s command line tools on this same evidence, this time using
Autopsy.
First, in the Host Manager make sure the radio button for
able2.part2.dd (the “/” partition) is selected, and click “okay”. In the
resulting page, there is a frame at the top with a row of buttons for various
functions. Click on the button “Image Details” and look at the output. Does
it look familiar?
96
Figure 10. "Image Details" provides similar output to "fsstat"
This is the same output we saw from our fsstat command from the
Sleuthkit! Let’s go a little deeper and see if we can reproduce more of our
Sleuthkit output.
In the top frame row of buttons, click “File Analysis” (we are still in
the able2.part2.dd image, the “/” file system of able2). We are now given a
“tree” view of the contents of the selected image.
97
Figure 11. "File Analysis" display
In the left hand pane, there is a button labeled “All Deleted Files”.
Click on this button…
This generates a list of all the deleted files found on this partition.
Again, do you recognize the output? It provides similar output to our fls
command from the Sleuthkit. Scroll to the bottom of the list, and you will
see our /root/lrkn.tgz, recovered by the Sleuthkit from inode 2139. Once
you scroll to the bottom of the list and see /root/lrkn.tgz, you can scroll all
98
the way to the right and see that the file is indeed associated with inode
2139.
If you click ON THE INODE NUMBER (2139), you will see the
following:
Figure 13. Click ON THE INODE number (all the way to the right, see the arrow)
Again, you see the output is similar to out output from the Sleuthkit
command istat (under “Details:”). Clicking on “Export Contents” produces
a dialog box that allows us to save the file to our local file system. If you
retrace the same process we followed with the previous exported contents of
inode 2139 using Sleuthkit12, you will find the same results.
12
See Page 86.
99
SMART for Linux
http://www.asrdata.com/SMART/
Opening SMART provides the user with a view of the physical layout
of all the devices recognized on the system, including internal and external
drives. This gives the examiner an overall picture of what file systems
reside on each drive, the sizes of each partition, and the amount of
unallocated space on the drive.
100
Figure 15. Smart’s opening window with drive identification
101
Figure 16. Forensic image acquisition dialog box. Red text indicates incomplete items…
102
Case management under SMART is straightforward. Once a forensic
image (or multiple images) is added as evidence to a case, SMART will
parse the image and provide details on the contents. Here we’ve added our
able2.dd image to a case:
103
Figure 19. Right click on a deleted file
The right click menu displayed for a file in a file listing allows you to
perform a number of tasks. In the above screenshot, we see that we have the
ability to export the contents of the deleted file at inode 2139, leading us to
the same steps as we took with Sleuthkit/Autopsy on the same data.
There are too many tools to include in this document. For a sample of
some other tools that might be of interest to a forensic examiner using
Linux, check http://www.opensourceforensics.org/tools/unix.html .
104
XI. Bootable Linux Distributions
For so many people, this is the meat and potatoes of what makes
Linux such a flexible operating system. Access to a bootable CD drive and
the ability to reboot the machine can now give us the power to run a full-
fledged Linux box without the need to install. For those who have not seen
this in action, the power you can get from a CDROM, or even a floppy disk
is amazing. This is not a complete list, but the following bootable
distributions can give you some idea of what’s available to you. There are
many MANY more bootable distributions out there. Just do a Google search
on “Linux bootable CD” for a sample.
Tomsrtbt - boot from a floppy
This small distribution is the definition of minimalist, and it fits on
one floppy. You get a decent set of drivers for NICs and file systems
(including FAT and NTFS). There’s a basic set of common Linux tools,
including dd and rsh or nc for imaging over net connections and more. The
installation (to a floppy) can be done in Windows with an included batch
file. The floppy holds a surprising number of programs, and actually
formats your 1.44 Mb floppy to 1.722 Mb. Find it at
http://www.toms.net/rb/
Knoppix - Full Linux without the install
This is a CDROM distribution for people who want to try a full-
featured Linux distribution, but don’t feel like installing Linux. It includes a
full Linux environment and a huge compliment of software. The CD
actually holds 2GB of software, including a full office suite, common
network tools and just about anything else you’re likely to need all
compressed to a CD sized image. http://www.knoppix.net
Penguin Sleuth - Knoppix with a forensic flavor
Re-mastered by Ernie Bacca, this Knoppix based distribution
maintains its user-friendliness and adds a good deal of forensic software as
well. The complete list of software (including Sleuthkit/Autopsy) can be
found at http://www.linux-forensics.com/forensics/pensleuth.html
105
White Glove Linux - Dr. Fred Cohen
White Glove Linux is a small, pocket-sized distribution developed by
Dr. Fred Cohen (http://www.all.net). The CD runs a minimalist but usable
Blackbox X interface and has a number of useful network audit tools that
allow you to check the integrity of, and audit systems. Everything from file
system checks, executable file validation and log checking, to finding
graphical images on the target system are addressed by White Glove.
106
Conclusion
The examples and practical exercises presented to you here are very
simple. There are quicker and more powerful ways of accomplishing what
we have done in the scope of this document. The steps taken in these pages
allow you to use common Linux tools and utilities that are helpful to the
beginner.
Once you become comfortable with Linux, you can extend the
commands to encompass many more options. Practice will allow you to get
more and more comfortable with piping commands together to accomplish
tasks you never thought possible with a default OS load (and on the
command line to boot!);
• Compress an image as you create it.
• Image using dd over a network connection.
• Start learning how to automate these tasks with shell scripts
(shell scripts are your friend!).
I hope that your time spent working with this guide was well spent. At
the very least, I’m hoping it gave you something to do, rather than stare at
Linux for the first time and wonder “what now?”
107
XI. Linux Support
Web sites to check for support:
Linux Forensics:
http://linux-forensics.com
Software:
http://sourceforge.net/
108