awskey

package
v0.783.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package awskey decodes an AWS access key ID (AKIA…/ASIA…/AROA… — the 20-char unique IDs AWS issues for keys, roles, users, and policies) into the **AWS account ID** bit-packed inside it and the **credential type**. A leaked AWS key is prime cloud-pentest / IR loot, and recovering the owning account ID + the key type **offline, without calling AWS** (no `sts get-access-key-info`, no log entry, no detection) is a standard recon technique. Pure offline transform; no network or device.

Wrap-vs-native judgement

Native. The account ID is encoded in the key ID: strip the 4-char type prefix, base32-decode the rest, read the first 6 bytes big-endian, mask with 0x7FFFFFFFFF80 and right-shift 7. A base32 decode + a shift, stdlib only — nothing to wrap. The bit layout was reverse-engineered by Aidan Steele / WithSecure / Truffle Security and is implemented identically across the public tools (e.g. github.com/psanford/aws-account-id-from-key).

Verifiable / no confidently-wrong output

Anchored to two published vectors — ASIAY34FZKBOKMUTVV7A → 609629065308 and ASIAQNZGKIQY56JQ7WML → 029608264753 (the latter is the psanford reference implementation's own test vector). To avoid emitting a bogus account ID for an arbitrary base32 string, only the recognised AWS unique-ID prefixes are accepted; an unknown prefix, a wrong length, or a non-base32 body is rejected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	// KeyID is the input (upper-cased).
	KeyID string `json:"key_id"`
	// KeyType is the 4-char prefix (AKIA, ASIA, AROA, …).
	KeyType string `json:"key_type"`
	// Description is the human meaning of the prefix.
	Description string `json:"description"`
	// AccountID is the 12-digit AWS account ID embedded in the key.
	AccountID string `json:"account_id"`
	// Usable is true for the prefixes that are actual access keys you can
	// authenticate with (AKIA long-term, ASIA temporary); the others are
	// resource unique IDs that merely leak the account.
	Usable bool `json:"usable_credential"`
}

Result is the decoded view of an AWS access key ID.

func Decode

func Decode(keyID string) (*Result, error)

Decode recovers the AWS account ID and credential type from a 20-character AWS access key ID. A wrong length, an unrecognised prefix, or a non-base32 body is rejected rather than decoded into a bogus account.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL