
Generates CSS-only payloads that exfiltrate secret tokens from web pages via attribute selectors and background-image requests, then reconstructs them with De Bruijn graph stitching.

Open-source web application security scanner for automated vulnerability detection, manual penetration testing, and API security testing with a proxy-based interception engine.

Fast YAML-based vulnerability scanner with template-driven detection engine for automated security testing across web apps, APIs, networks, DNS, and cloud infrastructure.

Web vulnerability scanner written in Python3
CSS token exfiltration tool
Frag is a tool for extracting secret tokens from web pages using only CSS — no JavaScript required. It generates CSS payloads that use attribute selectors and background-image URLs to exfiltrate overlapping token fragments to an attacker-controlled server, then reconstructs the full token using De Bruijn graph traversal and Eulerian path algorithms.
This is useful in contexts where CSS injection is possible but JavaScript is blocked — such as webmail clients, HTML email rendering, or pages with strict Content Security Policies.
Frag extracts lowercase hex tokens (0-9a-f), and also mixed-case alphanumeric (A-Za-z0-9), base64 (A-Za-z0-9+/=) and base64url (A-Za-z0-9-_) tokens. See Charsets.
Fragment exfiltration — For every possible window of 3 or 4 characters in the token's charset, a CSS attribute selector (*=) fires a background-image request to your server if the token's attribute contains it. Two small rule sets (^=/$=, or *= with the known surrounding text) leak the token's first and last two characters.
Reconstruction — Frag builds the token one character at a time, keeping only tokens of the configured length that match the leaked start and end and contain nothing but leaked windows.
Noise handling — Charset characters from the rest of the attribute (e.g. bac in callback, or junk query parameters) also leaks and can link into the token. Candidates are ranked by how cheaply the windows they leave unused can be explained as one contiguous run of junk, so junk is left over rather than spliced into the token.
Ambiguity reporting — Only the set of windows leaks, not their order or count, so different tokens can leak identical data. When that happens every equally plausible token is listed as a candidate rather than one being picked at random.
The window size trades CSS size against accuracy. Measured on random hex tokens in an anchor href followed by random hex junk:
| Window | CSS | Single correct guess, 12 chars | 24 chars | 40 chars | 64 chars |
|---|---|---|---|---|---|
| 4 chars (default) | ~4.03 MB | 100% | 100% | 99.5% | ~97% |
| 3 chars | ~260 KB | ~97% | ~72% | ~28% | ~1% |
With 3-char windows the real token is still in the candidate list ~98% of the time at 40 chars; it just isn't the only answer. CSS size also grows with the length of your server's origin, since it appears in every rule.
Unmatched probes contribute no background layer: each matched custom property contains url(...),, and the background joins empty fallbacks such as var(--a,)var(--b,)none. Frag conservatively retains its limit of 25,000 probe references per box, introduced after large background lists crashed Chrome. The 4-char hex payload and every non-hex payload still spread references across the element and its ::before/::after. Any existing pseudo-element content is replaced, and if the page's styles override their backgrounds, those windows won't leak. The 3-char hex payload uses only the element itself.
CSS sizes above are UTF-8 bytes (decimal KB/MB) for the anchor preset with an HTTP 127.0.0.1:3000 collector. Compact property names, short attribute-value escapes, empty fallbacks and the abbreviated IPv4 collector reduce the four-character payload from 4.67 MB to 4.03 MB without removing probes. Blind extraction additionally nests repeated field selectors and combines equivalent URL-start probes: a four-character csrf input on a form drops from 7.12 MB to 5.09 MB, and an anchor's token parameter from 6.68 MB to 4.35 MB. With localhost:3000, which must keep its hostname, the targeted payload is ~4.30 MB (four characters) or ~278 KB (three characters).
Probing every mixed-case window doesn't scale: 3-char alphanumeric windows alone would be 62³ = 238,328 rules (~15 MB), and would need about ten 25,000-layer boxes when an element only has three. Non-hex charsets therefore leak two smaller sets in one payload:
[href*=abc i]) over the lowercased alphabet: 36 characters for alphanumeric, 39 for base64, 38 for base64url. They reconstruct the token in lowercase exactly as hex does. 36³ windows are about as sparse as hex's 16⁴, so accuracy is close to 4-char hex.[href*=aB], sent as /c/aB), about 3,700–4,100 rules. Each letter's case is chosen so that every pair in the cased token leaked. A casing that leaves the token's own leaked pairs unexplained ranks lower. Pairs from the known surrounding text are expected leftovers.A / in a leaked chunk is sent as %2F so it stays in one path segment. Non-hex charsets only offer 3-char windows: 4-char ones would need 1.7M+ rules. The start and end rules match up to 8 characters of the known text around the token rather than 2, because a bigger alphabet would also match elsewhere in the URL, e.g. n=lo in &operation=login.
Measured on random tokens in the anchor preset (with and without random junk in the same charset after the href) and in a hidden input (test/stitch.test.js):
| Charset | CSS (anchor / hidden) | Single correct guess, 6–40 chars | 64 chars | Token listed, 6–40 chars |
|---|---|---|---|---|
| alphanumeric | ~3.17 / 3.31 MB | ~98% | ~77–85% | 100% |
| base64 | ~3.99 / 4.17 MB | ~99% | ~75–85% | 100% |
| base64url | ~3.69 / 3.85 MB | ~99% | ~75–85% | 100% |
Case ties (e.g. a lowercase copy of part of the token elsewhere in the attribute) come back as candidates. If no casing fits at all, e.g. because a pair request was lost, the token is returned in lowercase and flagged as such. Base64 inside URLs is often percent-encoded (%2B, %2F, %3D), which these windows won't match, so use base64url or another field there.
When testing in the UI, inject each payload into a fresh page: a browser won't re-request an image URL it already loaded in the same page, and alphanumeric, base64 and base64url share most window URLs.
The targeted mode and blind recon mode treat a quiet gap of one second as the boundary between extractions: the server waits for that gap before stitching, and the first request after it starts a fresh extraction. One-shot mode also waits for a quiet gap before stitching, but keeps hits across gaps so a delayed lane cannot erase an earlier one. Reset or reconfigure one-shot mode before a separate injection.
The rates above average over a range of lengths, but accuracy depends strongly on how long the token is — and for 3-char hex it falls off sharply past ~24 characters. The table below breaks it out. Each cell is single% (listed%): single is how often Frag returns exactly one answer and it is the real token; listed is how often the real token is among the returned candidates (so the gap between them is how often it comes back as one of several equally plausible answers). Measured over 200 random tokens per cell in the anchor preset (with and without random same-charset junk after the href) and in a hidden input; non-hex charsets use 3-char windows plus case pairs. Regenerate from the same leak/stitch pipeline as test/stitch.test.js (seed 0xabcd).