winrm-pentest 0.1.0

Async WinRM 2.0 (WS-Management) client for offensive security — NTLM/Kerberos/CredSSP auth, remote PowerShell, encoded-command exec, SMB-free file upload. Cross-platform. Pre-alpha
Documentation
//! Trivial RFC-4122 v4 UUID generator — used for `wsa:MessageID` and shell
//! selectors. We deliberately do NOT pull the `uuid` crate: a randoms→hex
//! print is 20 lines and keeps our dep tree at 8 crates.

use std::time::{SystemTime, UNIX_EPOCH};

/// Return a lowercase 8-4-4-4-12 UUIDv4. Entropy source is not cryptographic —
/// this is a WSMan message-correlation id, not a session key. Do not use for
/// anything security-sensitive.
pub fn uuid_v4() -> String {
    let mut b = [0u8; 16];
    let mut s = seed();
    for chunk in b.chunks_mut(8) {
        s = xorshift64(s);
        chunk.copy_from_slice(&s.to_le_bytes()[..chunk.len()]);
    }
    // RFC 4122: set version (0100) in byte 6, variant (10) in byte 8.
    b[6] = (b[6] & 0x0f) | 0x40;
    b[8] = (b[8] & 0x3f) | 0x80;
    format!(
        "{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
        b[0], b[1], b[2], b[3],
        b[4], b[5],
        b[6], b[7],
        b[8], b[9],
        b[10], b[11], b[12], b[13], b[14], b[15]
    )
}

fn seed() -> u64 {
    // Time × pointer address — enough entropy to distinguish envelopes on the
    // same tick. Replace with getrandom before any production use.
    let t = SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .map(|d| d.as_nanos() as u64)
        .unwrap_or(0x5eed_c0de);
    t ^ (&t as *const u64 as u64)
}

fn xorshift64(mut x: u64) -> u64 {
    if x == 0 {
        x = 0xdead_beef_cafe_babe;
    }
    x ^= x << 13;
    x ^= x >> 7;
    x ^= x << 17;
    x
}