win_events: Determine if the WBCL was for a cold boot (as opposed to a resume from hibernation) (#209)

This commit is contained in:
Tom D 2021-04-07 16:08:29 -07:00 committed by GitHub
parent 1bbba0bdfd
commit 1ceeedc8dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -149,6 +149,8 @@ const (
// WinEvents describes information from the event log recorded during
// bootup of Microsoft Windows.
type WinEvents struct {
// ColdBoot is set to true if the system was not resuming from hibernation.
ColdBoot bool
// BootCount contains the value of the monotonic boot counter. This
// value is not set for TPM 1.2 devices and some TPMs with buggy
// implementations of monotonic counters.
@ -409,6 +411,19 @@ func (w *WinEvents) readBootCounter(header microsoftEventHeader, r *bytes.Reader
return nil
}
func (w *WinEvents) readTransferControl(header microsoftEventHeader, r *bytes.Reader) error {
i, err := w.readUint(header, r)
if err != nil {
return fmt.Errorf("transfer control: %v", err)
}
// A transferControl event with a value of 1 indicates that bootmngr
// launched WinLoad. A different (unknown) value is set if WinResume
// is launched.
w.ColdBoot = i == 0x1
return nil
}
func (w *WinEvents) readBitlockerUnlock(header microsoftEventHeader, r *bytes.Reader, pcr int) error {
if header.Size > 8 {
return fmt.Errorf("bitlocker data too large (%d bytes)", header.Size)
@ -721,6 +736,8 @@ func (w *WinEvents) readSIPAEvent(r *bytes.Reader, pcr int) error {
return w.readBootCounter(header, r)
case bitlockerUnlock:
return w.readBitlockerUnlock(header, r, pcr)
case transferControl:
return w.readTransferControl(header, r)
case osKernelDebug, codeIntegrity, bootDebugging, testSigning: // Parse boolean values.
return w.readBooleanByteEvent(header, r)

View File

@ -25,6 +25,7 @@ import (
func TestParseWinEvents(t *testing.T) {
want := &WinEvents{
ColdBoot: true,
BootCount: 4,
DEPEnabled: true,
CodeIntegrityEnabled: true,