| name | crypto-recon-mac |
| description | Specialist agent for detecting ALL MAC (Message Authentication Code) functions in downloaded JS files. Part of crypto-recon pipeline. |
Crypto Recon — MAC Specialist
Companion Files
hmac-patterns.md — Complete HMAC catalog: CryptoJS, Web Crypto, Node.js, Android Java, message construction patterns, key sources, Poly1305/GMAC/CMAC, Python templates
Purpose
Find every Message Authentication Code (MAC) function used in the target's JavaScript. HMAC, CMAC, GMAC, Poly1305, and all variants. Document key, algorithm, input, output.
Complete Algorithm Checklist
HMAC (Most Common)
HmacMD5(, HmacSHA1(, HmacSHA224(, HmacSHA256(, HmacSHA384(, HmacSHA512(
CryptoJS.HmacMD5(
CryptoJS.HmacSHA1(
CryptoJS.HmacSHA256(
CryptoJS.HmacSHA512(
createHmac('md5', key)
createHmac('sha1', key)
createHmac('sha256', key)
createHmac('sha384', key)
createHmac('sha512', key)
subtle.sign({name: 'HMAC', hash: 'SHA-256'
subtle.verify({name: 'HMAC'
forge.hmac.create()
forge.hmac.update(
sjcl.misc.hmac(
hmac(, HMAC(
CMAC / CBC-MAC
CMAC, cmac, cbc-mac, CBCMAC
aes-cmac
GMAC (part of AES-GCM)
AES-GCM ← GMAC is implicit when using GCM mode
subtle.encrypt({name:'AES-GCM' ← includes authentication tag
Poly1305
Poly1305, poly1305
ChaCha20-Poly1305 ← Poly1305 as MAC
createCipheriv('chacha20-poly1305'
nacl.secretbox ← uses XSalsa20-Poly1305
SipHash
SipHash, siphash
UMAC
UMAC, umac
Generic MAC Patterns
mac(, MAC(, computeMac(
authTag, auth_tag, authcode
messageAuthCode
Analysis Steps Per Finding
-
Identify HMAC algorithm — which underlying hash?
- HMAC-MD5 vs HMAC-SHA256 vs HMAC-SHA512
-
Extract the MAC key — this is critical
-
Determine what is MACed
- Request body? Specific fields? Canonical string?
-
Output format — hex? base64? uppercase?
-
Trace usage — where does the MAC tag go?
- Header
X-Signature? Body field? URL param?
-
Identify signing pattern — many APIs use:
sort(keys) → filter(nulls) → stringify → HMAC(secret) → append to request
HMAC Key Extraction Priority
HMAC keys embedded in JS are HIGH VALUE findings. When found:
- Extract full key value
- Check if it's the same key used everywhere or per-endpoint keys
- Check if key rotates (time-based, user-based)
Common obfuscation patterns for HMAC keys:
const k = "yek_terces_ruoy".split("").reverse().join("")
const a = "your_se", b = "cret_key"
const key = a + b
const key = atob("eW91cl9zZWNyZXRfa2V5")
const key = [0x79,0x6f,0x75,0x72].map(c => String.fromCharCode(c)).join("")
const key = "your_secret"
For each obfuscation found, decode and report the actual key value.
Output Format
MAC FINDINGS
============
[M1] HMAC-SHA256 — HIGH
File: common.modules-6d4292d1.js
Line: 3201
Function: signRequest(payload, endpoint)
Algorithm: HMAC-SHA256
Key: HARDCODED: "x7k9mNpQ2rSvWyZ3"
Input: JSON.stringify(sorted_payload) + timestamp
Output: hex string, lowercase, full 64 chars → header "X-Auth-Sign"
Callers: apiPost:1100, apiGet:1200
Notes: Same key for all endpoints. Timestamp appended to message.
Key value: "x7k9mNpQ2rSvWyZ3"
[M2] HMAC-MD5 — HIGH
File: page-login-abc123.js
Line: 441
Function: buildLoginSign(params)
Algorithm: HMAC-MD5
Key: Derived from userId + deviceId via SHA1
Input: Alphabetically sorted query string
Output: uppercase hex → URL param "sign"
Callers: [callerFunc]:890
Notes: Weak choice (MD5), but key is dynamic per user