Windows
Few words about Microsoft interoperability initiative.
by Matthieu Suiche on Apr.06, 2008, under Debugging, Reverse Engineering, SandMan, Windows
As you probably know, Microsoft released last month several thousands pages of documentation about office file format and Windows protocols.
It means numerous hundreds(thousands?) of functions/algorithms documentation and pseudo-code. But, are these pseudo-function right? It looks not.
While I was reading [MS-DRSR]: Directory Replication Service (DRS) Remote Protocol Specification, I was a bit curious to see the DecompressWin2k3() function (Thanks Aaron, Stefan , and Brendan).
This function is in fact the decompression algorithm called Xpress implemented for the first time in Windows XP and not Windows 2003 as say the name. Xpress algorithm works on 64kb chunks and is used in Windows hibernation file format, Windows Imaging Format (WIM) , Outlook, Exchange, and… LDAP replication service of Active Directory.
I’m quoting below, errors I found in the pseudo-code of DecompressWin2k3(). Here is the C implementation.
while (outputIndex < = outputSize)
should be:
while (outputIndex < outputSize)
if (indicatorBit = 0) then
indicatorBit := copy inputBuffer[inputIndex] as 32-bit integer in
little-endian format
should be:
indicator := copy inputBuffer[inputIndex] as 32-bit integer in
little-endian format
inputIndex := inputIndex + 4
indicatorBit := 32
endif
indicatorBit := indicatorBit - 1
//* check whether the bit specified by indicatorBit is set or not
//* set in indicator. For example, if indicatorBit has value 4
//* check whether the 4th bit of the value in indicator is set
if indicatorBit bit in indicator is not set then
inputBuffer[inputIndex] := outputBuffer[outputIndex]
should be:
outputBuffer[outputIndex] := inputBuffer[inputIndex]
inputIndex := inputIndex + 1
outputIndex := outputIndex + 1
else
length := copy inputBuffer[inputIndex] as 16-bit integer in
little-endian format
inputIndex := inputIndex + 2
offset := length /8
length := length mod 8
if (length = 7) then
if (nibbleIndex = 0) then
nibbleIndex := inputIndex
length := inputBuffer[inputIndex] mod 16
inputIndex := inputIndex + 1
else
length := inputBuffer[inputIndex] / 16
should be:
length := inputBuffer[nibbleIndex ] / 16
nibbleIndex := 0
endif
if (length = 15) then
length := inputBuffer[inputIndex]
inputIndex := inputIndex + 1
if (length = 255) then
length := copy inputBuffer[inputIndex] as 16-bit integer in little-endian format
inputIndex := inputIndex + 2
length := length - (15 + 7)
endif
length := length + 15
endif
length := length + 7
endif
length := length + 3
while (not length = 0)
should be:
while (length != 0)
outputBuffer[outputIndex] := outputBuffer[outputIndex - offset - 1]
outputIndex := outputIndex + 1
length := length - 1
endwhile
endif
endwhile
return
X-Ways Forensics Beta 2 and hibernation file. (coincidence?)
by Matthieu Suiche on Apr.03, 2008, under Forensics, Windows
X-Ways (WinHex editor) Forensics Beta 2 now includes hibernation file(hiberfil.sys) support for Windows XP 32-bit only. Please notice, Sandman library/framework is an open-source project under GNU General Public License v3 to read and write the hibernation file released 2 months ago…
Posted on Friday, Mar 28, 2008 - 1:05:
* Ability to decompress Windows XP 32-bit hiberfil.sys files, whether
active or inactive, to get a dump of physical memory with all in-use
pages from a previous point of time when the computer entered into
hibernation, as well as individually carved xpress chunks from
hiberfil.sys files, including xpress chunks located in the “slack” of
hiberfil.sys that are even older. This feature is available in Edit |
Convert. (forensic license only)
(PS: I’m not beta-tester)
Source.
New attack released - Windows has been vulnerable for 8 years.
by Matthieu Suiche on Mar.18, 2008, under Articles, SandMan, Windows
In November 2007 at PacSec'07, Tokyo, Japan, Nicolas Ruff and I (Matthieu Suiche) presented how to create a readable physical memory dump from the undocumented Microsoft hibernation file.
Last month, I published an open-source public version of this project called SandMan Framework. This framework allows manipulating the hibernation file for offensics (malicious) or forensics uses.
Today, I am going to release a Proof of Concept of the sandman attack using SandMan Framework. This PoC consists in elevating a user CMD shell to SYSTEM level under Windows XP SP3 RC1.
Sandman Framework offers a wide range of possibilities, both offensive and defensive. Like cryptographic keys retrieving in popular encryption software (e.g. TrueCrypt, GPG), privilege
escalation (cf. PoC), login without any password, and so on.
All Windows versions are concerned, from Windows 2000 up to Windows 2008, Windows Vista SP1 included (and possibly Windows Seven).
The following video shows how the system can be subverted in a few minutes. The following points are highlighted:
* Deactivating hibernation feature does not solve the problem.
* The sandman attack affects every Windows version, from Windows 2000 to Windows 2008, 32- and 64-bit alike.
* We can read and write everything everywhere in the physical memory (RAM).
* This attack is feasible in real life on every computer with no hardware requirements.
* The attack has no time limitation. If a computer has been hibernated one
week ago, extracting his physical memory is still possible.
This is far more powerful than other recently demonstrated attacks against physical memory, like Cold Boot and FireWire attacks.
“keep you free from sin, till the sandman he comes”
(Enter SandMan — Metallica)
Physical memory access is fashion…
by Matthieu Suiche on Mar.04, 2008, under Windows
These last weeks several proof of concept were published about physical memory access.
The first one (21 February 2008) was from Princeton university who published a very buzzed proof of concept in video.. This one allows to read the physical memory in a limited time.
The second one was SandMan which is hosted by myself. This one was released 4 days later by the University of Princeton proof of concept and give read/write access to physical memory though the hibernation file.
And few hours ago, a security researcher called Adam Boileau released a tool called Winlockpwn. This last one use firewire port to get read/write access to physical memory.
There is only 2 weeks between the Princeton’s release and Adam’s one. Live forensics looks to be very fashionable…
SandMan 1.0.080226 is out!
by Matthieu Suiche on Feb.26, 2008, under Articles, Reverse Engineering, Windows
Since Windows 2000, Microsoft provides a feature called Hibernation also know as suspend to disk that aims to save the system state into an undocumented file called hiberfil.sys. This file contains all the physical memory saved by the Operating System and aims to be restored by the user the next time the computer is powered on. Live forensics analysis is used to use physical memory dump to recover information on the targeted machine. One of the main problems is to obtain a readable physical memory dump, hibernation is an efficient way to save and load physical memory. Hibernation analysis has notable advantages. System activity is totally frozen, therefore coherent data is acquired and no software tool is able to block the analysis. The system is left perfectly functional after analysis, with no side effects.
The hibernation file opens two valuable doors: The first one is (live?) forensics analysis for defensive computing. Hibernation is an efficient and easy way to get a physical memory dump. But the main issue about it was: How to read the hiberfil.sys? That’s how the idea of SandMan born. The second one is a new (ou pas) concept we will be introduced and called “offensics” which is a portmanteau from “offensive” and “forensics”. If we can read hiberfil.sys, can we rewrite it? The answer is: Yes, with SandMan you can.
SandMan was firstly introduced at PacSec, Japan in November 2007, slides are available in the SandMan section.
* SandMan provides a C Library and a Python portage.
Here is a sample of implementation in Python.
-
#!/usr/bin/python
-
#
-
#
-
#Module Name:
-
#
-
# sample1.py
-
#
-
#Abstract:
-
#
-
# - Display target version.
-
# - Build a physical memory dump from a hibernation file.
-
#
-
#Environment:
-
#
-
# - Python
-
#
-
#Revision History:
-
#
-
# - Matthieu Suiche
-
#
-
-
import sys
-
import sandman
-
-
if len(sys.argv) != 3:
-
print "Matthieu Suiche - http://sandman.msuiche.net/"
-
print "Usage: sample.py hiberfil.sys physical_dump.vmem"
-
sys.exit(1)
-
-
s = sandman.hiber_open(sys.argv[1])
-
-
ver = sandman.hiber_get_version(s);
-
-
print "Windows version %d.%d.%d\n" % (ver & 0xFF, (ver & 0xFF00) >> 8, ver >> 16)
-
-
print "Generate physical memory dump…"
-
-
sandman.hiber_dump(s, sys.argv[2])
-
-
print "Done."
-
-
sandman.hiber_close(s)
* Furthermore, SandMan is open-source and released under GNU General Public License v3, you can have further information on the Google SVN at the following link:
http://code.google.com/p/sandmanlib/.
* Actually, SandMan supports 32bits version of the hibernation file from Windows XP to Windows 2008 Server
To download SandMan, go to the section dedicaced to SandMan here:
http://sandman.msuiche.net/.
