Automating Disk Forensic Processing with SleuthKit, XML and Python
Simson Garfinkel, Ph.D. Associate Professor Naval Postgraduate School
http://faculty.nps.edu/slgarfin/
May 20, 2009 SADFE 2009
Automating Disk Forensic Processing with SleuthKit, XML and Python - - PowerPoint PPT Presentation
Automating Disk Forensic Processing with SleuthKit, XML and Python Simson Garfinkel, Ph.D. May 20, 2009 SADFE 2009 Associate Professor Naval Postgraduate School http://faculty.nps.edu/slgarfin/ NPS is the Navys Research University.
http://faculty.nps.edu/slgarfin/
May 20, 2009 SADFE 2009
2
3
Encase:
SleuthKit:
4
5
6
for (dirpath,dirnames,filenames) in os.walk(“/mnt”): for filename in filenames: process(dirpath+”/”+filename)
7
file 1 part 1 file 1 part 2 file 2 file 3 file 4
t0 = time.time() fis = fiwalk.fileobjects_using_sax(imagefile) t1 = time.time() print "Time to get metadata: %g seconds" % (t1-t0) print "Native order: " calc_jumps(fis,"Native Order") fis.sort(key=lambda(a):a.byteruns()[0].img_offset) calc_jumps(fis,"Sorted Order")
8
9
disk image: nps-2009-domexusers1
1.Extraction of forensic metadata. 2.Representation of the extracted metadata. 3.Processing.
10
<XML> Output 1 3 2
$ fiwalk [options] -X file.xml imagefile
11
XML
ARFF Body
<XML> Output 1 3 2
fiwalk -n .jpeg /dev/sda # just extract the .jpeg files
12
<XML> Output 1 3 2
*.jpg dgi ../plugins/jpeg_extract *.pdf dgi java -classpath plugins.jar Libextract_plugin *.doc dgi java -classpath ../plugins/plugins.jar word_extract
Manufacturer: SONY Model: CYBERSHOT Orientation: top - left
13
<XML> Output 1 3 2
—file system metadata —file meta data —file content
, tar, CAB) —We can exactly represent the container structure —PyFlag does this with “virtual files” —No easy way to do this with the current TSK/EnCase/FTK structure —(Note: Container files not currently implemented.)
14
<XML> Output 1 3 2
<fiwalk> — outer tag <fiwalk_version>0.4</fiwalk_version> <Start_time>Mon Oct 13 19:12:09 2008</Start_time> <Imagefile>dosfs.dmg</Imagefile> <volume startsector=”512”>
<Partition_Offset>512</Partition_Offset> <block_size>512</block_size> <ftype>4</ftype> <ftype_str>fat16</ftype_str> <block_count>81982</block_count>
<filesize>4096</filesize> <partition>1</partition> <filename>linedash.gif</filename> <libmagic>GIF image data, version 89a, 410 x 143</libmagic> 15
<XML> Output 1 3 2
<fileobject> <filename>WINDOWS/system32/config/systemprofile/「开始」菜单/程序/附件/_rf55.tmp</ filename> <filesize>1391</filesize> <unalloc>1</unalloc> <used>1</used> <mtime>1150873922</mtime> <ctime>1160927826</ctime> <atime>1160884800</atime> <fragments>0</fragments> <md5>d41d8cd98f00b204e9800998ecf8427e</md5> <sha1>da39a3ee5e6b4b0d3255bfef95601890afd80709</sha1> <partition>1</partition> <byte_runs type=’resident’> <run file_offset='0' len='65536' fs_offset='871588864' img_offset='871621120'/> <run file_offset='65536' len='25920' fs_offset='871748608' img_offset='871780864'/> </byte_runs> </fileobject> 16
<XML> Output 1 3 2
<byte_runs type=’resident’> <run file_offset='0' len='65536' fs_offset='871588864' img_offset='871621120'/> <run file_offset='65536' len='25920' fs_offset='871748608' img_offset='871780864'/> </byte_runs>
17
<XML> Output 1 3 2
Manufacturer: SONY Model: CYBERSHOT Orientation: top - left
<fileobject> ... <Manufacturer>SONY</Manufacturer> <Model>CYBERSHOT</Model> <Orientation>top - left</Orientation> ... </fileobject>
—Special characters are automatically escaped.
18
<XML> Output 1 3 2
$ ls -l /corp/images/nps/nps-2009-domexusers/
$
—Depending on the complexity of the disk image.
—You can easily implement a "smart carver" that only carves unallocated sectors.
19
<XML> Output 1 3 2
fiwalk_using_sax(imagefile, xmlfile, flags, callback)
—Very fast and minimal memory footprint
—Reasonably fast; returns a list of all file objects with XML in dictionary
(doc,objs) = fileobjects_using_dom(imagefile, xmlfile, flags)
—Allows modification of XML that’s returned.
20
<XML> Output 1 3 2
fileobject_sax(fileobject) — for the SAX interface fileobject_dom(fileobject) – for the DOM interface
—fi.partition() —fi.filename(), fi.ext() —fi.filesize() —fi.ctime(), fi.atime(), fi.crtime(), fi.mtime() —fi.sha1(), fi.md5() —fi.byteruns(), fi.fragments() —fi.content()*
21
<XML> Output 1 3 2
import fiwalk
print "average file size: ",sum([fi.filesize() for fi in objs]) / len(objs)
import fiwalk
sum_of_sizes = 0 for fi in objs: sum_of_sizes += fi.filesize() print "average file size: ",sum_of_sizes / len(objs) 22
<XML> Output 1 3 2
import fiwalk
for fi in filter(lambda x:x.filesize()==15, objs): print fi
import fiwalk
for fi in objs: if fi.filesize()==15: print fi 23
<XML> Output 1 3 2
<byte_runs type=’resident’> <run file_offset='0' len='65536' fs_offset='871588864' img_offset='871621120'/> <run file_offset='65536' len='25920' fs_offset='871748608' img_offset='871780864'/> </byte_runs>
[byterun[offset=0; bytes=65536], byterun[offset=65536; bytes=25920]]
run.start_sector() — Starting Sector # run.sector_count() run.img_offset
run.fs_offset
run.bytes
run.content()
24
<XML> Output 1 3 2
>>> print fi.byteruns() [byterun[offset=0; bytes=65536], byterun[offset=65536; bytes=25920]]
— Returns all of the contents
— Validates MD5/SHA1 to see if image has file
— Creates a tempfile, optionally calculating hash
25
<XML> Output 1 3 2
26
27
—filelist.py — 110 lines —kiosk.py — 368 lines —loginpanel.py — 70 lines —smb.py — 90 lines —watcher.py — 152 lines
28
29
Extract metadata in Boston. Search from Monterey. Just download what you need.
29
AFF Extract metadata in Boston. Search from Monterey. Just download what you need.
29
AFF XML Extract metadata in Boston. Search from Monterey. Just download what you need.
29
AFF XML http Extract metadata in Boston. Search from Monterey. Just download what you need.
29
AFF XML http
Extract metadata in Boston. Search from Monterey. Just download what you need.
29
AFF XML http
Extract metadata in Boston. Search from Monterey. Just download what you need.
—Jessy Cowan-Sharp —George Dinolt —Beth Rosenberg
30
Questions?