Forensic Analysis1 - Students
Forensic Analysis1 - Students
1.0
DECEMBER 2016
About ENISA
The European Union Agency for Network and Information Security (ENISA) is a centre of network and
information security expertise for the EU, its member states, the private sector and Europe’s citizens.
ENISA works with these groups to develop advice and recommendations on good practice in information
security. It assists EU member states in implementing relevant EU legislation and works to improve the
resilience of Europe’s critical information infrastructure and networks. ENISA seeks to enhance existing
expertise in EU member states by supporting the development of cross-border communities committed to
improving network and information security throughout the EU. More information about ENISA and its
work can be found at www.enisa.europa.eu.
Contact
For contacting the authors please use cert-relations@enisa.europa.eu.
For media enquires about this paper, please use press@enisa.europa.eu.
Legal notice
Notice must be taken that this publication represents the views and interpretations of ENISA, unless
stated otherwise. This publication should not be construed to be a legal action of ENISA or the ENISA
bodies unless adopted pursuant to the Regulation (EU) No 526/2013. This publication does not
necessarily represent state-of the-art and ENISA may update it from time to time.
Third-party sources are quoted as appropriate. ENISA is not responsible for the content of the external
sources including external websites referenced in this publication.
This publication is intended for information purposes only. It must be accessible free of charge. Neither
ENISA nor any person acting on its behalf is responsible for the use that might be made of the
information contained in this publication.
Copyright Notice
© European Union Agency for Network and Information Security (ENISA), 2016
Reproduction is authorised provided the source is acknowledged.
02
Forensic analysis
1.0 | December 2016
Table of Contents
1. Forward 4
2. Story that triggers incident handling and investigation processes. 5
3. Environment preparation 6
4. Memory analysis 9
Checking memory dump file 9
Scanning memory with Yara rules 10
Analysis of the process list 13
Network artefacts analysis 14
5. Disk analysis 16
Mounting Windows partition and creating timeline 16
Antivirus scan 25
Filesystem analysis 26
Application logs analysis 30
Decompiling Python executable 38
Prefetch analysis 41
System logs analysis 44
6. Registry analysis 48
Copying and viewing registry 48
Inspecting registry timeline 50
UserAssist 51
List of installed applications 52
7. Building the timeline 55
03
Forensic analysis
1.0 | December 2016
1. Forward
This three-day training module will follow the tracks of an incident handler and investigator, teaching best
practices and covering both sides of the breach. It is technical in nature and has the aim to provide a
guided training for both incident handlers and investigators while providing lifelike conditions. Training
material mainly uses open source and free tools.
04
Forensic analysis
1.0 | December 2016
The customer’s organization has found out that some of its sensitive data has been detected in online text
sharing application. Due to the legal obligations and for business continuity purposes CSIRT team has been
tasked to conduct an incident response and incident investigation to mitigate the threats.
Breach contains sensitive data and includes a threat notice that in a short while more data will follow. As
the breach leads to specific employee’s computer then CSIRT team, tasked to investigate the incident,
follows the leads.
Workstation 1
Workstation/Phone 2
05
Forensic analysis
1.0 | December 2016
3. Environment preparation
All the practical exercises will be done using CAINE Linux. Import the provided virtual machine appliance
which contains additional set of scripts and all files necessary for completing the exercises.
Next, attach separate storage drive with evidence files (memory dump and disk image) – evidence.vmdk.
Then start CAINE virtual machine and try to login into the system (user: enisa, password: enisa).
After logging into the system mount partition with the evidence files in read only mode. The easiest way to
accomplish this is to use “Mounter” utility. “Mounter” can be started by clicking on the green hard drive
icon at the bottom panel. Then choose partition with evidence files and click OK.
06
Forensic analysis
1.0 | December 2016
After this operation evidence data should be available at the /media directory (in this case /media/sdb1).
Now open terminal and go to /media/sdb1/Windows directory (or any other directory where partition
with evidence files was mounted) which contains three files:
Calculate checksums using md5sum command and then compare its output with checksums stored in
MD5SUMS file.
07
Forensic analysis
1.0 | December 2016
08
Forensic analysis
1.0 | December 2016
4. Memory analysis
Correct profile to use is Win10x86_44B89EEA1. Additionally to make commands execute faster specify
addresses of DTB, KDBG and KPCR structures:
To check if everything is working try to list processes with the pslist command:
Since all following commands during Windows memory analysis will be used with the same set of
parameters, for convenience create alias to vol.py:
1
This profile was introduced in one of the applied patches. When code is merged into main Volatility repository name
of this profile might change.
09
Forensic analysis
1.0 | December 2016
Scan memory using yarascan plugin and the previously created rules file:
10
Forensic analysis
1.0 | December 2016
11
Forensic analysis
1.0 | December 2016
Check in which processes UPX and Xtreme RAT rules were detected.
12
Forensic analysis
1.0 | December 2016
Search the process list for the PIDs of processes containing malicious code from the previous task:
Search for parent processes of explorer.exe, svchost.exe and update.exe (PIDs: 4748 and 5860):
Check the command line which was used to start given process using the dlllist plugin:
13
Forensic analysis
1.0 | December 2016
Inspection of the list can reveal a few connections to nonstandard TCP ports:
There were also some connections to tcp/80 (HTTP) and tcp/443 (HTTPs):
14
Forensic analysis
1.0 | December 2016
15
Forensic analysis
1.0 | December 2016
5. Disk analysis
Start Autopsy (system menu -> Forensic Tools -> Autopsy 2.24):
16
Forensic analysis
1.0 | December 2016
If the web browser wasn’t yet started in the system, it should start now. Otherwise open new tab in
browser and go to http://localhost:9999/autopsy.
Create new case by clicking “New Case” and then filling the form as presented on the screenshot below.
Then click “New Case” again.
17
Forensic analysis
1.0 | December 2016
On the next page you will be informed about path to the case files (including some intermediate results).
Click “Add Host”.
On the next page, specify at least a Host Name and then click “Add Host”. It’s also worth to specify GMT
time zone to be sure this time zone will be used for displaying times during file analysis.
18
Forensic analysis
1.0 | December 2016
The next step will be to add disk image as an evidence file. To add a new image click “Add Image” and then
“Add Image File”.
19
Forensic analysis
1.0 | December 2016
In the next form specify the path to the disk image and check if Type is set to Disk.
Now Autopsy will analyse partition table on the provided disk image and let user decide which partitions
add to the case. In this case, it should be enough to add only the main Windows partition.
20
Forensic analysis
1.0 | December 2016
After clicking “Add”, Autopsy will display information that a new image was added and linked with the
case. At this point, the analyst can decide whether to add an additional image file or proceed with the
analysis. Click “Ok” since there are no more evidence files to add.
21
Forensic analysis
1.0 | December 2016
Create a file activity timeline which will be quite useful during later analysis. To create a timeline, select
partition C:\ and click “File Activity Time Lines”.
22
Forensic analysis
1.0 | December 2016
Select all options as presented on the screenshot below and click “Ok”:
Now Autopsy will start the analysis of the filesystem on the C:\ partition. Depending on the partition size
and number of files this might take some time.
23
Forensic analysis
1.0 | December 2016
Fill the form as presented on the screenshot below and click “Ok”.
24
Forensic analysis
1.0 | December 2016
If opening a timeline in a browser leads to a browser crash try opening it in a text editor (e.g. vim, nano).
Antivirus scan
Perform an antivirus scan of the mounted filesystem.
25
Forensic analysis
1.0 | December 2016
Filesystem analysis
Start by searching on the timeline (either in browser or text editor) for update.exe file which was detected
during the memory analysis.
Later at 13:03:04 according to standard $STANDARD_INFORMATION attribute, update.exe MFT entry was
changed. Note that 13:03:04 is also the time when update.exe process was created according to memory
analysis.
Go back to the main Autopsy panel, choose partition C:\ and click “Analyze”.
26
Forensic analysis
1.0 | December 2016
Click “Meta Data” and enter 101287 as MFT Entry Number (value can be read from timeline).
One pretty useful information for the forensic analysis that can be read from this page are MACB
timestamp values as read from $STANDARD_INFORMATION and $FILE_NAME attributes.
27
Forensic analysis
1.0 | December 2016
Go back to the timeline and check what happened shortly before 13:02:57. Quick analysis should reveal
that one second before 13:02:57 file 3568226350[1].exe was created.
Moreover shortly before that, multiple Firefox cache files were created suggesting Firefox activity. Among
those files there is a file in which ClamAV detected an exploit code.
Another way to browse filesystem is to use the Autopsy File Analysis utility. To do this, go to the main
Autopsy panel and choose analysis of C:\ partition.
28
Forensic analysis
1.0 | December 2016
29
Forensic analysis
1.0 | December 2016
Open new terminal window and change directory to the location of the previously generated body file
(created by Autopsy during timeline preparation):
Next, using mactime tool generate small timeline and filter results using grep:
30
Forensic analysis
1.0 | December 2016
Check in Autopsy timestamps of both crash dump files (.dmp and .extra) from pending subdirectory:
31
Forensic analysis
1.0 | December 2016
After clicking OK, the history of visited pages should appear. If the list is empty, make sure all options in the
Advanced Window were set correctly (Options -> Advanced Options).
Next it’s worthwhile to set the time zone to GMT and sort list elements by the Visit Time column. Due to a
Wine bug, you might need to scroll down and up list to refresh it to make the changes take effect.
32
Forensic analysis
1.0 | December 2016
Scroll down to the date of the incident, 16/08/2016, and analyse websites visited by the user.
2
http://www.nirsoft.net/utils/mozilla_cache_viewer.html
33
Forensic analysis
1.0 | December 2016
After clicking OK, MZCacheView will load data from the cache files. This operation might take a short time.
After the data is fully loaded, change dates to GMT time zone (the same as in Browsing History View tool)
and sort content by Last Modified date.
Scrolling down to the date of the incident, shortly after visiting the blog.mycompany.ex website, multiple
other files were downloaded from another domain, blog.mysportclub.ex:
34
Forensic analysis
1.0 | December 2016
Export cache files to separate directory for further analysis and to keep evidence data in one place.
To export cache data, select all entries related to blog.mysportclub.ex domain. Then right click on selected
items and choose “Copy Selected Cache Files To…”.
In the next window, specify an output directory (if this directory doesn’t exist it should be created first!).
35
Forensic analysis
1.0 | December 2016
The same should be repeated for blog.mycompany.ex domain (changing only the output directory).
Perform an analysis of the exported cache files. A good starting point would be an analysis of the index file
of the blog.mycompany.ex website:
Now switching to the analysis of cache files from blog.mysportclub.ex, open /wp-
content/uploads/hk/task/opspy/index.php file (previously saved to blog.mysportclub.ex as
index.php.htm).
36
Forensic analysis
1.0 | December 2016
Open the first file found. Additionally to make viewing easier it’s good to replace all ‘\n’ phrases with
actual characters of new line.
Scroll down to the middle of the file where cmd variable is defined.
37
Forensic analysis
1.0 | December 2016
Extract from executable .pyc files using unpy2exe3 script. Two .pyc files should be extracted.
Next using uncompyle64 tool try decompiling the bytecode in .pyc files to the original python code.
3
https://github.com/matiasb/unpy2exe
38
Forensic analysis
1.0 | December 2016
4
https://pypi.python.org/pypi/uncompyle6/
39
Forensic analysis
1.0 | December 2016
40
Forensic analysis
1.0 | December 2016
Prefetch analysis
To parse Windows 10 prefetch files use 505Forensics script5. Script can be found at
~/training/tools/win10_prefetch/. Run this script and save its output to prefetch.csv file. Then open
prefetch.csv file in LibreOffice Calc.
LibreOffice should correctly propose separating values by commas. In the Text Import window just click Ok.
5
http://www.505forensics.com/windows-10-prefetch/
41
Forensic analysis
1.0 | December 2016
Select all data cells and from Data menu choose sort. Then choose column D (Last Run Time 0) for primary
sort key (Sort Key 1).
42
Forensic analysis
1.0 | December 2016
Table data should now be sorted by last run time of the binaries.
43
Forensic analysis
1.0 | December 2016
Convert previously copied EVTX files to XML format using evtxdump.pl utility.
Open any of the XML files and inspect XML structure of system logs.
44
Forensic analysis
1.0 | December 2016
Run ~/training/tools/logparse.py script with --help parameter to view script usage information:
Using logparse.py script search for all events that were logged between 14:03:00 and 14:05:00.
45
Forensic analysis
1.0 | December 2016
Search for all events mentioning “hydra.exe” phrase – possibly logged at different period of time. This can
be done by specifying pattern filter to logparse.py.
46
Forensic analysis
1.0 | December 2016
47
Forensic analysis
1.0 | December 2016
6. Registry analysis
Start Windows Registry Recovery (WRR) tool from ~/training/tools/WRR/WRR.exe using Wine.
48
Forensic analysis
1.0 | December 2016
Check what information can be extracted from registry using WRR tool.
Choose Raw Data function from the left panel to view the original registry structure.
49
Forensic analysis
1.0 | December 2016
Scroll timeline until date of the incident when GhCtxq8t key was modified.
Inspect contents of GhCtxq8t key using WRR tool and Raw Data function.
50
Forensic analysis
1.0 | December 2016
Search for PuTTY related entries on the registry timeline created from NTUSER.DAT file.
UserAssist
To quickly decode and extract information about UserAssist use userassist plugin from the RegRipper tool:
51
Forensic analysis
1.0 | December 2016
Each Uninstall subkey contains some information about application (varying between subkeys) like
installation date, path to uninstall binary, app version or install source.
52
Forensic analysis
1.0 | December 2016
By browsing subkeys in Uninstall key, check Mozilla Firefox and Adobe Flash Player versions.
53
Forensic analysis
1.0 | December 2016
Check the last modification date of WinPcapInst key by right clicking on the subkey and choosing
Properties from the context menu.
54
Forensic analysis
1.0 | December 2016
To get better picture of the whole incident at the end it’s worth to build timeline with all timestamps
collected from different sources. List below presents all timestamps obtained from the previous tasks.
Observations that should be correlated with other logs (network logs, logs from other hosts) were
additionally bolded.
Prefetch files
12:55:53 Start of firefox.exe
UserAssist keys
Creation of Firefox cache file possibly containing exploit code (CVE- AV scan
13:02:53
2012-3993) Filesystem analysis
AV scan
13:02:56 Creation of 3568226350[1].exe file (referred in one of the cache files)
Filesystem analysis
13:02:57 Start of svchost.exe process containing Xtreme RAT code Memory analysis
13:03:04 Start of update.exe process with Xtreme RAT code Memory analysis
55
Forensic analysis
1.0 | December 2016
Prefetch files
13:14:47 Execution of mimikatz.exe and creation of mimikatz.log file
Filesystem analysis
Prefetch files
13:14:50 Execution of browserpassworddump.exe and creation of bpd.log
Filesystem analysis
Prefetch files
14:04:44 Execution of Hydra.exe (possible dictionary attack)
System logs
14:10:49 Possible login to some remote host (Plink.exe execution) Prefetch files
14:11:20 Possible login to some remote host (Plink.exe execution) Prefetch files
14:11:26 Modification of PuTTY SshHostKeys (RSA key pointing to 192.168.5.10) Registry analysis
14:17:45 Possible login to some remote host (Plink.exe execution) Prefetch files
14:20:44 Possible login to some remote host (Plink.exe execution) Prefetch files
14:22:45 Possible login to some remote host (Plink.exe execution) Prefetch files
14:23:31 Possible login to some remote host (Plink.exe execution) Prefetch files
56
Forensic analysis
1.0 | December 2016
57
ENISA
European Union Agency for Network
and Information Security
Science and Technology Park of Crete (ITE)
Vassilika Vouton, 700 13, Heraklion, Greece
Athens Office
1 Vass. Sofias & Meg. Alexandrou
Marousi 151 24, Athens, Greece