Investigating Windows systems with Linux

Window Kit

© Max, Fotolia

© Max, Fotolia

Author(s): , Author(s):

A forensics expert explains how to extract interesting details from a confiscated Windows hard disk using standard Linux tools.

Criminals, intruders, and corporate saboteurs leave data behind on the hard disks of any computers they visit. Many of these computers are Windows systems, but you don't need Windows to extract valuable forensic information from a Windows hard disk. In this article, I will describe some simple techniques for getting forensic data from a Windows disk using Linux.

Before starting any forensic analysis, it is important to create a copy of the storage medium you will be investigating, either as a 1:1 copy or as an image or collection of images. You can copy the medium as a raw image (with dd) or use a format such as Expert Witness Format (EWF).

EWF is a proprietary format developed by Guidance Software [1] that is also supported by the X-Ways [2] commercial forensic tool. EWF images are compressed and thus are far smaller than raw images.

Linux tools such as Linux Encase (Linen) or Ewfacquire [3] will help you create an EWF image. Linen is included on the Helix forensics CD [4] as a free contribution by Guidance Software, but the dd tool, which is included on any Linux distribution, will normally do the trick. If you use dd, you can even launch a copy of the Windows system in a virtual environment such as VMware; EWF will not let you launch Windows without the proprietary add-on software because of its compressed format.

A command such as dd if=/dev/sda of=win_hd.dd bs=4096 conv=noerror, sync will create a dd image. Instead of /dev/sda, just specify the disk you want to copy. The block size bs=4096 accelerates the copy. The conv parameter ensures that the copy will not terminate if it encounters defective sectors.

By entering fdisk -lu, you can obtain information on the disk image. The administrator simply needs to pass in the image name (Listing 1).

Listing 1

Getting Information with fdisk

01 # fdisk -lu win_hd.dd
02 Disk win_hd.dd: 0 MB, 0 bytes
03 120 heads, 63 sectors/track, 0 cylinders, total 0 sectorsUnits = sectors of 1 * 512 = 512 bytes
04 Disk identifier: 0x840b840b
05 Device        Boot      Start        End    Blocks        Id        System
06 win_hd.dd1    *         63           6327719163828+      7         HPFS/NTFS

In Listing 1, the image contains a partition; the filesystem is NTFS. The disktype program from the standard Debian repositories provides more information (Listing 2). The partition obviously contains the Windows bootloader.

Listing 2

Disktype Data

01 # disktype win_hd.dd
02 --- win_hd.dd
03 Regular file, size 3.021 GiB (3243663360 bytes)
04 DOS/MBR partition map
05 Partition 1: 3.017 GiB  (3239760384 bytes, 6327657 sectors from 63, bootable)
06   Type 0x07 (HPFS/NTFS)
07   Windows NTLDR boot loader
08   NTFS file system
09     Volume size 3.017 GiB (3239759872 bytes, 6327656 sectors)

To access the filesystem, the administrator first needs to mount it. The partition starts with sector 63, which is normal for a hard disk. The exception to this is Microsoft's latest offspring, Windows Vista, in which the first sector is 2047. The mount command thus specifies the matching offset:

# losetup -o $((63*512)) /dev/loop0 U win_hd.dd
# mount -o ro,noatime,noexec /dev/loop0 /mnt

A quick glance at /mnt reveals the startup files and filesystem of a Windows drive. A quick glance at the boot.ini file reveals that they belong to a Windows 2000 Server (Listing 3).

Listing 3

Windows Filesystem

01 # ls -l /mnt
02 Total 787024
03 -r-------- 1 root root    150528 2003-06-19 13:05 arcldr.exe
04 -r-------- 1 root root    163840 2003-06-19 13:05 arcsetup.exe
05 -r-------- 1 root root         0 2007-12-02 11:59 AUTOEXEC.BAT
06 -r-------- 1 root root       186 2007-12-02 11:43 boot.ini
07 -r-------- 1 root root         0 2007-12-02 11:59 CONFIG.SYS
08 dr-x------ 1 root root      4096 2007-12-02 14:14 Dokumente und Einstellungen
09 dr-x------ 1 root root     24576 2007-12-02 14:14 WINNT
10 (...)
11 # cat /mnt/boot.ini
12  [boot loader]
13  timeout=30
14  default=multi(0)disk(0)rdisk(0)partition(1)\ WINNT
15 [operating systems]
16  multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000 Server" /fastdetect
17 (...)

Seeking with Find

Criminal investigators often use the Linux find command with the --exec or xargs xx options to search for files with illegal content. After creating and mounting an image, find /mnt -type f will give you a detailed list of files. Because this approach does not take file names with blanks or non-standard characters into account, the investigator might opt for find /mnt -type f -print0 | xargs -0 ls -al.

Hash values help find identical and suspicious files on a system. You can create a hash automatically with a command such as find /mnt -type f -print0 | xargs -0 md5sum; you can even compare the hashes on the fly with existing reference material. However, it makes more sense to create a file containing hashes for all files (Figure 1).

Hashes Find Duplicates

In most cases, investigators already have hashes for files they want to find. Forensics experts compile databases with hashes of known files to help search for criminal material. If you just want to filter out Microsoft DLLs on a system you are investigating, this approach is useful.

A simple grep command will find any correlations between the subject of the investigation and your search targets. The following command, from which we have removed the individual filenames, saves a list of hashes for existing files in a file called big.txt:

# find /mnt -type f -print0 | xargs -0 md5sum | awk '{print $1}' | sort -g | uniq > big.txt

The awk command takes the hash values in the first column; sort -g sorts them, and uniq removes duplicate entries. An investigator who has stored the desired hash values in a file called small.txt, can then run grep -f small.txt big.txt to find duplicates, and thus any matching files.

Keyword Search

Forensic investigators search confiscated systems for specific keywords.

Creating a text file with the search keys for this purpose – such as keywords.txt – is a good idea. For example, you could add the words password and secret.

The command line

# cat win_hd.dd | strings | egrep -i --color -f keywords.txt

searches the complete Windows image for the keywords password and secret and highlights them in red in the output, as you can see in Figure 2. This approach is particularly interesting if you extend the search beyond the filesystem to other areas of a hard disk, such as:

  • the swap file or hibernation file,
  • unallocated areas of the disk,
  • file slack data
  • deleted files.

To find keywords stored in the 16-bit Unicode text that the Windows NT operating systems use, you must tell the strings command whether to perform a little – or big – endian [5] search. The required arguments are either -eb or -el. Listing 4 uses Ntfsundelete as an example of restoring files via inode allocations.

Listing 4

Restoring Files

01 # ntfsundelete -u -i11137 /dev/loop0
02 Inode    Flags  %age  Date            Size  Filename
03 -----------------------------------------------------
04 11137    FN..   0%    2003-06-19   50688  msiinst.exe
05 Undeleted 'msiinst.exe' successfully.
06 file msiinst.exe
07 msiinst.exe: MS-DOS executable PE  for MS Windows (DLL) (GUI) Intel 80386 32-bit

Read full article as PDF:

Investigating_Windows_Systems.pdf (1.47 MB)

Related content

  • OCFA

    Automate the forensics process with the Dutch police department's Open Computer Forensics Architecture.

  • Caine

    Caine is a Linux distribution based on Ubuntu 10.04 for forensic scientists and security-conscious administrators. Poised to do battle against IT ne’er-do-wells, Caine has a comprehensive selection of software, a user-friendly GUI, and responsive support.

  • Tracing Intruders Intro

    You don't need expensive proprietary tools to practice the craft of computer forensics.

  • Memory Analysis

    In computer forensics, memory analysis is becoming increasingly important as a means for investigating security incidents. In this article, we provide an overview of the various memory dumping options on Linux and introduce the support in Linux for the Volatility Analysis Framework.

  • BackTrack and Sleuth Kit

    Once you determine a system has been attacked, boot to the BackTrack Live forensics distro and start your investigation with Sleuth Kit.

comments powered by Disqus

Direct Download

Read full article as PDF:

Investigating_Windows_Systems.pdf (1.47 MB)

News