astraguard 1.1.7

Official AstraGuard SDK - license validation, HWID binding, anti-debug, and offline cache for Rust applications
Documentation

astraguard

Official AstraGuard SDK for Rust - license validation, HWID binding, anti-debug, and offline grace-period cache.

crates.io docs.rs

Features

  • License key validation and activation via the AstraGuard API
  • Hardware ID (HWID) derivation and binding
  • AES-256-GCM encrypted offline cache with a configurable grace period
  • HMAC-SHA256 response authentication (fail-closed)
  • Background heartbeat for continuous license verification
  • Anti-debug detection (Windows): IsDebuggerPresent, NtQueryInformationProcess, Frida pipe/DLL check, timing check
  • Anti-VM detection (Windows, x86_64): CPUID vendor string, VM driver files, process names, MAC OUI check
  • XOR-obfuscated sensitive string constants (prevents trivial strings extraction)
  • Automatic update checks via /check-update

Installation

[dependencies]

astraguard = "1"

tokio = { version = "1", features = ["full"] }

Quick Start

use astraguard::AstraGuardClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = AstraGuardClient::new("https://api.astraguard.io", "your-product-id")?;

    // Validate license (falls back to encrypted offline cache on network failure)
    let details = client.verify_license("XXXX-XXXX-XXXX-XXXX").await?;
    if details.raw.valid {
        println!("License valid!");
        // Access feature flags (only enabled features are ever included)
        for feature_name in &details.raw.features {
            println!("Feature enabled: {feature_name}");
        }
    }

    Ok(())
}

Response Authentication

Protect against MITM response spoofing by enabling HMAC verification:

let client = AstraGuardClient::new("https://api.astraguard.io", "product-id")?
    .with_response_auth("BASE64_KEY_FROM_DASHBOARD");

When set, responses without a valid x-astraguard-hmac header are rejected (fail-closed).

Security Checks

let mut client = AstraGuardClient::new("https://api.astraguard.io", "product-id")?;
client.set_auto_enforce_security(true); // enables anti-debug + anti-VM on every verify_license call

Or start the background anti-debug monitor explicitly:

astraguard::security::anti_debug::start_background_monitor();
// thread runs forever, calls process::exit(1) silently if a debugger is detected

Heartbeat

client.start_heartbeat(300, Some(|| {
    eprintln!("License lapsed  -  shutting down");
    std::process::exit(1);
}));

Update Check

let update = client.check_for_updates("1.0.0").await?;
if update.has_update {
    println!("Update available: {}", update.latest_version);
}

Platform Support

Feature Windows Linux macOS
License validation
Offline cache
HWID via MachineGuid - -
HWID fallback (hostname+user)
Anti-debug (IsDebuggerPresent, NtQuery, Frida) - -
Anti-VM (CPUID, processes, files, MAC) ✅ (x86_64) - -

License

MIT - see LICENSE.

Links