Thursday 5 June 2008

pagefile.sys - not always what it seems!

From time to time I hear colleagues discussing the merits of an artefact reported by Encase as being in pagefile.sys. It may be a picture or even an e-mail attachment as referred to in this Forensic Focus post. I have seen reports detailing these artefacts along with explanations of what virtual memory is.

I have always thought that pagefile.sys was pre-allocated an area of the hard disk and did not necessarily have to write to it all. As this was raised again recently I decided to carry out some tests.

I configured a XP VM not to use a Paging File



and then ran Eraser v5.86.1 with a Task to wipe Unused Space with



which in ASCII is UN. As expected I ended up with most of Unallocated Cluster being overwritten with UNUNUN etc. (\x55 \x4E).

I then turned the pagefile back on and rebooted



I found that a considerable proportion of my (quite large) pagefile.sys was UNUN etc. sampled in this sweeping bookmark-


Full Path Pagefiletest\0\C\pagefile.sys
File Created 05/06/08 09:41:25
Last Written 05/06/08 09:43:35
Physical Size 1,794,691,072
Logical Size 1,794,691,072
Initialized Size 1,794,691,072
Starting Extent 0C-C3307487
File Offset 32763080
Length 3104

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN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NUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN

UNUNUNUNUNUNUNUNUNUNUNUNUNUNUNUN


and shown in this screen print



The moral of the story is that the pagefile.sys is not always what it seems - perhaps more specifically what is reported as being within it may have resided within unallocated clusters prior to pagefile.sys being created or resized.

References


http://www.aumha.org/win5/a/xpvm.php
http://www.petri.co.il/pagefile_optimization.htm

3 comments:

Jamie Levy said...

Very interesting. Thanks for posting about this :-)

Anonymous said...

How long after reboot did you examine pagefile.sys? From the tests that I did using ProcMon, the impression I was left with was that upon creating Pagefile.sys it did so by physically writing the entire file out with \x00. However even 5 minutes after the system was booted I could see that XP was still writing out the 2 gig pagefile.sys file. Plus by that time some of pagefile.sys was already starting to be used.

Anonymous said...

I did some further testing using your methodology of first wiping unallocated with a known pattern. I was still seeing sequences of \x00 in pagefile.sys suggesting it was being wiped. But upon closer comparison of the contents of pagefile.sys and the trace from Procmon I was able to determine that indeed the content originally comes from unallocated (how much I'm not sure as I see a 4096 bytes write at offset 0 on creation of pagefile.sys followed by writes of chunks of 65536 bytes (64K blocks). Within those blocks is where I see segments of \x00. But not full blocks of \x00 (that would be required if it was a case of pagefile.sys being wiped on creation. And beyond the last writes to pagefile.sys I saw the wipe pattern.

I ran this test in VMWare on an updated vanilla XP install. So very little in startups. I also had the NIC disconnected and let the machine sit idle for over 10 minutes after reboot. So it's unlikely that the system was so busy that it didn't get a chance to wipe a pagefile.sys with settings of 128-384K for size. Rather it appears that it simply allocates the space up front using whatever data is there and then that only gets overwritten as activity occurs.

The question then becomes how long would it take on a typical system for the entire pagefile.sys to get overwritten. Once that threshold is passed then it becomes very likely that the data in pagefile.sys came from the current user and not from unallocated which may or may not belong to the current user.

So I guess we can conclude that anything found in pagefile.sys is more likely to belong to the current OS install vs anything found in unallocated.