Skip to main content

LapsBlob

Struct LapsBlob 

Source
pub struct LapsBlob {
    pub update_timestamp: u64,
    pub blob: Vec<u8>,
}
Expand description

The header Windows LAPS puts in front of the DPAPI-NG blob in msLAPS-EncryptedPassword: an update timestamp and the blob length.

Fields§

§update_timestamp: u64

FILETIME of the last password update.

§blob: Vec<u8>

The DPAPI-NG blob itself.

Implementations§

Source§

impl LapsBlob

Source

pub fn parse(b: &[u8]) -> Result<LapsBlob>

Split an msLAPS-EncryptedPassword attribute value into its header and blob.

Examples found in repository?
examples/inspect_blob.rs (line 35)
16fn main() -> ExitCode {
17    let args: Vec<String> = std::env::args().skip(1).collect();
18    let raw_mode = args.iter().any(|a| a == "--raw");
19    let Some(path) = args.iter().find(|a| !a.starts_with("--")) else {
20        eprintln!("usage: inspect_blob [--raw] <blob.bin>");
21        return ExitCode::FAILURE;
22    };
23
24    let bytes = match std::fs::read(path) {
25        Ok(b) => b,
26        Err(e) => {
27            eprintln!("cannot read {path}: {e}");
28            return ExitCode::FAILURE;
29        }
30    };
31
32    let blob_bytes = if raw_mode {
33        bytes
34    } else {
35        match LapsBlob::parse(&bytes) {
36            Ok(l) => {
37                println!(
38                    "LAPS header: updated {} (FILETIME {}), {} byte blob",
39                    filetime_to_iso(l.update_timestamp),
40                    l.update_timestamp,
41                    l.blob.len()
42                );
43                l.blob
44            }
45            Err(e) => {
46                eprintln!(
47                    "not a LAPS attribute value ({e}); retry with --raw if this is a bare CMS blob"
48                );
49                return ExitCode::FAILURE;
50            }
51        }
52    };
53
54    let blob = match ProtectedBlob::parse(&blob_bytes) {
55        Ok(b) => b,
56        Err(e) => {
57            eprintln!("CMS parse failed: {e}");
58            return ExitCode::FAILURE;
59        }
60    };
61
62    let id = &blob.key_identifier;
63    println!("key identifier");
64    println!("  version            {}", id.version);
65    println!(
66        "  flags              {:#010x}{}",
67        id.flags,
68        if id.is_public_key() {
69            " (public key)"
70        } else {
71            ""
72        }
73    );
74    println!("  root key           {}", id.root_key_id);
75    println!(
76        "  tree node          L0 {} · L1 {} · L2 {}",
77        id.l0, id.l1, id.l2
78    );
79    println!("  kdf                {} ", id.kdf_algorithm);
80    match id.hash() {
81        Ok(h) => println!("  kdf hash           {}", h.name()),
82        Err(e) => println!("  kdf hash           UNPARSED: {e}"),
83    }
84    println!("  secret algorithm   {}", id.secret_algorithm);
85    println!(
86        "  private/public len {} / {}",
87        id.private_key_length, id.public_key_length
88    );
89    println!(
90        "  domain / forest    {} / {}",
91        id.domain_name, id.forest_name
92    );
93    println!("content");
94    println!("  key wrap           {}", blob.key_wrap_oid);
95    println!("  content cipher     {}", blob.content_cipher_oid);
96    println!(
97        "  nonce              {} ({} bytes)",
98        hex(&blob.nonce),
99        blob.nonce.len()
100    );
101    println!("  tag length         {}", blob.tag_len);
102    println!("  wrapped key        {} bytes", blob.encrypted_key.len());
103    println!(
104        "  ciphertext         {} bytes",
105        blob.encrypted_content.len()
106    );
107    println!(
108        "\nTo decrypt: ask a DC for root key {} at L0 {} (MS-GKDI GetKey), then\n\
109         GroupKeyEnvelope::parse(response) and dpapi_ng::decrypt(&blob, &envelope).",
110        id.root_key_id, id.l0
111    );
112
113    ExitCode::SUCCESS
114}
Source

pub fn protected(&self) -> Result<ProtectedBlob>

Parse the contained DPAPI-NG blob.

Trait Implementations§

Source§

impl Clone for LapsBlob

Source§

fn clone(&self) -> LapsBlob

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LapsBlob

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more