Tuesday, October 28, 2008

Linux Forensics

We started playing around with Fedora in the last class on Monday. Fedora is running as a virtual machine using VMware Player.

We learned about the booting process of a computer and covered a few terms such as bootstrap, kernel, multiprogramming, time sharing and virtual memory to name a few. We also started to learn a few things about the Linux operating system and how it works, particularly about processes and how they are created and managed. We still have a LOT to learn about this beast, however.

We started exploring the /proc folder which is a virtual file system that resides entirely in memory. The previous link has a lot of good information about the contents of this folder.

Thursday, October 16, 2008

Volatility procdump

Ok, so you guys were given a lab to work on yesterday and I see that some of you have been working hard ;-)

One of you asked about how to use the procdump feature of Volatility to extract a process from the memory image. So first of all: how do you know which process you would like to dump? You can get a list of all running processes in the image by using the pslist command:


$ ./volatility pslist -f ../memimages/xp-laptop-2005-07-04-1430.img

Name Pid PPid Thds Hnds Time
[lots of output left out]
VPTray.exe 2496 2392 2 111 Mon Jul 04 18:18:06 2005
atiptaxx.exe 2524 2392 1 51 Mon Jul 04 18:18:06 2005
jusched.exe 2548 2392 1 22 Mon Jul 04 18:18:07 2005
EM_EXEC.EXE 2588 2540 2 80 Mon Jul 04 18:18:09 2005
WZQKPICK.EXE 2692 2392 1 17 Mon Jul 04 18:18:15 2005
wuauclt.exe 3128 800 3 157 Mon Jul 04 18:19:11 2005
taskmgr.exe 3192 2392 3 65 Mon Jul 04 18:19:33 2005
cmd.exe 3256 2392 1 29 Mon Jul 04 18:20:58 2005
firefox.exe 3276 2392 7 189 Mon Jul 04 18:21:11 2005
PluckSvr.exe 3352 680 6 206 Mon Jul 04 18:21:42 2005
PluckTray.exe 3612 3352 3 102 Mon Jul 04 18:24:00 2005
PluckUpdater.ex 368 3352 0 -1 Mon Jul 04 18:24:30 2005
dd.exe 3300 3256 1 22 Mon Jul 04 18:30:32 2005



So let's say that we want to dump the firefox process, we can do that. First of all you should note the Process ID (pid) of the firefox process to make your life much simpler. Firefox's pid is 3276 which we can see above.

Next, how do you know which command you enter to accomplish this? Well, we know that if we just run volatility with no options, we will get a list of the commands that we can use:


./volatility

Volatile Systems Volatility Framework v1.3
Copyright (C) 2007,2008 Volatile Systems
Copyright (C) 2007 Komoku, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

usage: volatility cmd [cmd_opts]

Run command cmd with options cmd_opts
For help on a specific command, run 'volatility cmd --help'

Supported Internel Commands:
connections Print list of open connections
connscan Scan for connection objects
connscan2 Scan for connection objects (New)
datetime Get date/time information for image
dlllist Print list of loaded dlls for each process
dmp2raw Convert a crash dump to a raw dump
dmpchk Dump crash dump information
files Print list of open files for each process
hibinfo Convert hibernation file to linear raw image
ident Identify image properties
memdmp Dump the addressable memory for a process
memmap Print the memory map
modscan Scan for modules
modscan2 Scan for module objects (New)
modules Print list of loaded modules
procdump Dump a process to an executable sample
pslist Print list of running processes
psscan Scan for EPROCESS objects
psscan2 Scan for process objects (New)
raw2dmp Convert a raw dump to a crash dump
regobjkeys Print list of open regkeys for each process
sockets Print list of open sockets
sockscan Scan for socket objects
sockscan2 Scan for socket objects (New)
strings Match physical offsets to virtual addresses (may take a while, VERY verbose)
thrdscan Scan for ETHREAD objects
thrdscan2 Scan for thread objects (New)
vaddump Dump the Vad sections to files
vadinfo Dump the VAD info
vadwalk Walk the vad tree

Supported Plugin Commands:
getsids Print the SIDs owning each process
memmap_ex_2 Print the memory map
pslist_ex_1 Print list running processes
pslist_ex_3 Print list running processes
ssdt Display SSDT entries
thread_queues Print message queues for each thread
usrdmp_ex_2 Dump the address space for a process
volshell Shell in the memory image

Example: volatility pslist -f /path/to/my/file



Now if you run the procdump command without any other options it will dump all processes in the memory dump, which is not what we want. Therefore we should figure out how to get a usage statement for this command. If we issue Volatility with the command and the option -h then we get the following:

./volatility procdump -h
Usage: procdump [options] (see --help)

Options:
-h, --help show this help message and exit
-f FILENAME, --file=FILENAME
(required) XP SP2 Image file
-b BASE, --base=BASE (optional, otherwise best guess is made) Physical
offset (in hex) of directory table base
-t TYPE, --type=TYPE (optional, default="auto") Identify the image type
(pae, nopae, auto)
-o OFFSET, --offset=OFFSET
EPROCESS Offset (in hex) in physcial address space
-p PID, --pid=PID Dump the process with this Pid
-m MODE, --mode=MODE strategy to use when saving executable. Use "disk" to
save using disk-based section sizes, "mem" for memory-
based sections. (default: "mem")
-u, --unsafe do not perform sanity checks on sections when dumping



Now to dump the firefox process we can type the following:

./volatility procdump -p 3276 -f ../memimages/xp-laptop-2005-07-04-1430.img



You should end up with a file called executable.3276.exe

Sunday, October 5, 2008

Memory images

As we have already learned: we can copy all of physical memory from our computer using win32dd. This was part of your homework.

There are several practice images available online of different types of Windows OSes.

The image information for your lab is here:

[xp-laptop.tgz | xp-laptop.md5]

Some other things:

Volatility [direct download]
SID [direct download]
System call table [direct download | supporting library]
Windows messages [direct download]

The supporting library goes in the ``forensics/win32/'' folder under Volatility
All other plugins go in the ``memory_plugins/'' folder under Volatility

Friday, September 19, 2008

Linux vs Windows DOS commands

Here is a comparison between Windows DOS and Linux commands:
Windows DOSLinux/Cygwin
dirls
cdpwd
cd [path](same)
clsclear
copy [old] [new]cp [new] [old]
del [file]rm [file]
move [old] [new]mv [old] [new]
treetree (Linux only)
ls -R
mkdir [dir](same)
rmdir [dir](same)
help [cmd]man [cmd]
type [file]cat [file]
date /t(same)
time /tdate
netstat -an(same Linux only)
netstat -rn(same Linux only)
ipconfig /allifconfig -a
(Linux only)

Windows DOS commands

In the last two classes we have been playing around with command line on windows. We learned a few useful commands:

dirlist out files
cdshow current working directory
cd [path]change to [path] directory
clsclear screen
copy [old] [new]
copies the old file to new
del [file]deletes the file
move [old] [new]
moves the old file to new
treeshows the tree of the current directory
mdcreates new directory
mkdircreates new directory
rmdir [dir]deletes directory dir
helplists help information
type [file]outputs file contents to screen
date /toutputs date to screen
time /toutputs time to screen
netstatgives us network connection information
netstat -an
-a: all connections -n: IP addresses
netstat -rn
-r: routing information
ipconfig /all
gives us network information

Thursday, September 18, 2008

Talk on 9/24: Visual Forensic Analysis

There's an interesting talk coming up at John Jay College that might interest some of you:

The Center for Cybercrime Studies
The John Jay College of Criminal Justice
Presents

Visual Forensic Analysis

Speaker: Greg Conti



Computer Science Department
United States Military Academy

For decades hex was the common tongue of reverse engineers and forensic analysts, but we can do better. Hex editors are the Swiss Army knives of low level analysis and have evolved significantly, but are now at a local maximum. With the tiny textual window hex provides, it is difficult, if not impossible to understand the big picture context and inner workings of binary objects - files, file systems, process memory, and network traffic. While there are helpful tools to analyze the special case of executable files, little work exists to help address the general case of all types of binary objects. This talk presents visual approaches to improve the art and science of forensic analysis, diffing, and reverse engineering, both in the context independent case where little is known about the raw structure of the binary data and at the semantic level where external knowledge can be used to inform analysis. If you are faced with low level analysis tasks, you should attend this talk.

Greg Conti is an Assistant Professor of Computer Science at the United States Military Academy. His research includes security data visualization and web-based information disclosure. He is the author of Security Data Visualization (No Starch Press) and the forthcoming Googling Security (Addison-Wesley). His work can be found at www.gregconti.com and www.rumint.org.
Date:        September 24, 2008
Time: 3:30 PM
Location: Mathematics Conference Room - 4238N
445 West 59th Street, New York City 10019

RSVP: Nicole Daniels at 212-237-8920 or email ndaniels@jjay.cuny.edu.
For additional information please contact Professor Doug Salane, Director of the Center for Cybercrime Studies, at 212-237-8836 or email dsalane@jjay.cuny.edu.

Sunday, September 14, 2008

Linux commands

As you have discovered, Linux is somewhat different than Windows. The paths to files are much different, for example in Windows you have a path like:

C:\Documents and Settings\jlevy\My Documents


However in Linux, there are no drive letters and the slashes go a different direction:

/home/faculty/jlevy


Everything in the file system is mounted after the root directory, which is just a forward slash - /

There are often several users on the same Linux server and each user has his/her own home directory (folder) that has the same name as the username. You can see above that I have my home directory with the same name as my username: jlevy. It is inside that folder that I have permission to create and use new files.

We also learned that when we log in, we can see who we are and which directory we are in by looking at the prompt:

[jlevy@kanga ~]$

You can see my username and the tilde ~ which indicates that I am in my home directory. After you log in, the commandline is simply waiting there for you to issue it a command.

Basic Commands

In the last class we covered some basic Linux commands such as:

passwd changes your password

clear clears the screen
pwd print working directory
tree print out a tree of all
files from location

mkdir create (or make) a new directory
rmdir [directory] remove directory

rm [file] remove file
rm -Rf [dir] remove directory and all files
inside DANGEROUS!

touch [file] create (or update) a file

ls list out files
ls -a list out all files including
hidden files

ls -l list out files with permissions
ls -al list out all files with permissions

cd [path] change directory to [path]

cp [oldfile] [newfile] copy the oldfile to the newfile
or location

mv [oldfile] [newfile] move the oldfile to the newfile
or location

chmod [perms] [file] change the mode (permissions)
to perms for file

pico [file] open file for editing with pico
text editor

exit end session (logout)


One thing to note about Linux: Commands ARE case sensitive so you have to type them in all lower case!