Your scraper runs green. HTTP 200, parse succeeds, rows land in the database. Then a client asks why your dashboard says a product costs “ЮЫ.ÑД and you discover the price column has been garbage since day one. Not broken — lying. The site served you a perfect CSS-styled, correctly-positioned string of characters that no CSS validator, no HTML parser, and no human reader would ever flag. Every character was rendered by a custom font whose glyph for the codepoint your parser read as E is actually drawn as 7.
This is font obfuscation — one of the most effective anti-scraping techniques ever deployed. In this article I build the obfuscated font from scratch, then attack it — recover the full mapping in milliseconds — and score the fight honestly, including the variant that actually survives. Everything below ran on this machine before publication: no API keys, no cloud OCR, no ML model. The disclosure box above applies — pointing a scraper at an unwilling site is a legal question, not an engineering one.
The trick, precisely
When a browser renders text, it takes the codepoints in the DOM, looks each one up in the loaded font’s character map (the cmap table inside the font file), and draws the glyph attached to that codepoint. The pixels on screen come from the glyph outlines. The text in your clipboard, your parser’s DOM, and the search engine’s index come from the codepoints. Those are two independent layers, and font obfuscation is the act of editing one layer while the other stays visually identical.
The technique targets the Unicode Private Use Area (U+E000–U+F8FF) — codepoints Unicode leaves unassigned for vendor-internal use. A site replaces every 0-9 and . in its price strings with a random PUA codepoint, then ships a font binding those codepoints to glyph outlines copied from real digits. A human sees 142.6. Your BeautifulSoup pipeline sees \ue11c\ue146\ue106\ue1ad\ue139 — stored, exported, reported, silently, because nothing crashes.
Worth naming now: some sites skip the font file entirely and draw digits as inline SVG or canvas bitmaps — same idea, harder target. That’s where this arms race ends up; the honest answer is that SVG replacement beats the cracker below.
Proof this is a live, maintained arms race
I checked the ecosystem the day this article was written (November 17, 2026), via the GitHub API, from this server:
eatmoreduck/boss-zhipin-scraper— a scraper for BOSS Zhipin (China’s biggest job board, which obfuscates salary figures with custom fonts), 1,764 stars, updated the same day I checked. Its README explicitly advertises “bypasses font anti-crawl” and outputs plaintext salary JSON.solarhell/font_obfuscator— a Rust defender tool that generates obfuscated fonts for your own site. 172 stars, updated October 2026. The fact that the defender side ships as a packaged service tells you the technique is production practice, not a CTF curiosity.- A cluster of maoyan/dianping font-mapping repos (e.g.
zxjlm/Poirot, 62 stars, “automatically maps font files to encodings, mainly for breaking Chinese font anti-crawlers”).
I also pointed a single unauthenticated GET at maoyan.com (the canonical font-obfuscation example) from this datacenter IP: it 302’d straight to verify.meituan.com/...action=spiderindefence. That’s the outer wall — the font trick sits behind bot walls, which is why so few people ever notice their data was poisoned even after they get through. Defender tools packaged as services, attacker tools with four-figure star counts, a top-50 site gating its numbers behind both: this is worth an afternoon of your engineering time.
Build the weapon first
Step one is building the exact artifact a defensive engineer ships. This generator uses fontTools (4.68.0 at time of writing) to clone the 0-9. glyph outlines out of DejaVu Sans and re-bind each to a random PUA codepoint.
# gen_site.py — build the obfuscated web font (defender side)
from fontTools.fontBuilder import FontBuilder
from fontTools.pens.ttGlyphPen import TTGlyphPen
from fontTools.ttLib import TTFont
import random, json
BASE = '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
OUT = 'pricedata.woff2'
rng = random.Random(42)
fakes = rng.sample([0xE100 + i for i in range(200)], 11)
mapping = dict(zip(fakes, '0123456789.')) # PUA codepoint -> real char
base = TTFont(BASE)
glyph_set = base.getGlyphSet()
cmap = base.getBestCmap()
fb = FontBuilder(unitsPerEm=base['head'].unitsPerEm, isTTF=True)
fb.fontFamily = 'PriceData'
glyphs = {'.notdef': TTGlyphPen(glyph_set).glyph()}
fb_mapping, metrics = {}, {'.notdef': (600, 0)}
for fake, real in mapping.items():
pen = TTGlyphPen(glyph_set)
glyph_set[cmap[ord(real)]].draw(pen) # clone the real digit's outline
gkey = f'g{fake:04x}'
glyphs[gkey] = pen.glyph()
fb_mapping[fake] = gkey
metrics[gkey] = (600, 0)
fb.setupGlyphOrder(['.notdef'] + [k for k in glyphs if k != '.notdef'])
fb.setupCharacterMap(fb_mapping)
fb.setupGlyf(glyphs)
fb.setupHorizontalMetrics(metrics)
fb.setupHorizontalHeader(ascent=800, descent=-200)
fb.setupNameTable({'familyName': 'PriceData', 'styleName': 'Regular'})
fb.setupOS2(sTypoAscender=800, sTypoDescender=-200, usWinAscent=800, usWinDescent=200)
fb.setupPost()
fb.save(OUT)
json.dump({str(k): v for k, v in mapping.items()}, open('site_mapping.json', 'w'))
That script exited 0 and produced a 1,772-byte WOFF2 with 11 glyphs, with this random assignment baked in (yours differs every run — that’s the point):
U+E1A3->0 U+E11C->1 U+E106->2 U+E1BD->3 U+E146->4 U+E13E->5
U+E139->6 U+E123->7 U+E1BC->8 U+E11A->9 U+E1AD->.
The server side is one function — the entire obfuscation layer:
# fake_page.py — encode "142.6" the way an obfuscating site ships it
import json
mapping = {int(k): v for k, v in json.load(open('site_mapping.json')).items()}
rev = {v: k for k, v in mapping.items()}
text = '142.6'
encoded = ''.join(chr(rev[c]) for c in text)
Output: \ue11c\ue146\ue106\ue1ad\ue139 — five codepoints, same length, zero visual difference under the loaded font. Length and shape checks (NNN.N regexes) still pass. That’s why this bug survives code review: every structural signal is intact; only the semantics are rotated.
The crack: two independent signals
Now the attacker side. You pull the WOFF2 like any asset — it’s in the CSS @font-face, or one manual page view’s network tab; no protected endpoints involved. The file hands you two signals, and using both is what makes the recovery robust instead of lucky.
Signal 1 — the cmap structure. Eleven cmap entries, all inside U+E000–U+F8FF, none outside. That’s not a subtle tell; that’s a confession. An anonymous font mapping exactly digits-plus-punctuation onto PUA is an obfuscation font, and its existence tells you the site runs a data-protection layer worth modeling.
Signal 2 — glyph outlines. Codepoints got scrambled; the outlines are copied from a real font (in production targets, whatever system family the site mimics). Render each PUA glyph with freetype, render your candidate charset from the base font, normalize both (crop to ink box, resize to 32×32, scale 0–1), and score every pair with normalized cross-correlation. Template matching — the cheapest tool in the vision drawer, no training data needed because templates come from any font on your own disk.
# crack_font.py — attacker side: recover the glyph -> real-char mapping
import json
from fontTools.ttLib import TTFont
import freetype
import numpy as np
from PIL import Image
WEBFONT = 'pricedata.woff2'
BASE = '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
CHARSET = '0123456789.,$%kgm'
font = TTFont(WEBFONT)
cmap = font.getBestCmap()
pua = [cp for cp in cmap if 0xE000 <= cp <= 0xF8FF]
print(f'PUA codepoints: {len(pua)}/{len(cmap)}')
face = freetype.Face(WEBFONT); face.set_char_size(48 * 64)
bface = freetype.Face(BASE); bface.set_char_size(48 * 64)
def render(f, ch):
f.load_char(ch)
b = f.glyph.bitmap
if b.rows * b.width == 0:
return np.zeros((1, 1), np.float32)
return np.array(b.buffer, np.float32).reshape(b.rows, b.width)
def normalize(arr):
a = 255.0 - arr # ink = high
if a.max() > 0: a = a / a.max()
rows = np.where(a.max(axis=1) > 0.05)[0]
cols = np.where(a.max(axis=0) > 0.05)[0]
if len(rows) == 0: return np.zeros((8, 8), np.float32)
a = a[rows.min():rows.max()+1, cols.min():cols.max()+1]
img = Image.fromarray((a * 255).astype(np.uint8)).resize((32, 32))
return np.array(img, np.float32) / 255.0
web = {cp: normalize(render(face, chr(cp))) for cp in pua}
tpl = {ch: normalize(render(bface, ch)) for ch in CHARSET}
def ncc(a, b):
a = a - a.mean(); b = b - b.mean()
d = np.sqrt((a * a).sum() * (b * b).sum())
return float((a * b).sum() / d) if d > 0 else 0.0
recovered = {}
for cp, wg in web.items():
ranked = sorted(((ch, ncc(wg, t)) for ch, t in tpl.items()),
key=lambda kv: kv[1], reverse=True)
recovered[cp] = (ranked[0][0], ranked[0][1] - ranked[1][1])
for cp, (ch, margin) in sorted(recovered.items()):
print(f'U+{cp:04X} -> {ch!r} margin={margin:.3f}')
Actual output from the run that preceded this article — every glyph, matched against a 16-character template set:
U+E106 -> '2' ncc=0.966 margin=0.510
U+E11A -> '9' ncc=0.945 margin=0.249
U+E11C -> '1' ncc=0.970 margin=0.615
U+E123 -> '7' ncc=0.970 margin=0.467
U+E139 -> '6' ncc=0.979 margin=0.362
U+E13E -> '5' ncc=0.982 margin=0.396
U+E146 -> '4' ncc=0.939 margin=0.655
U+E1A3 -> '0' ncc=0.967 margin=0.335
U+E1AD -> '.' ncc=0.706 margin=0.343
U+E1BC -> '8' ncc=0.944 margin=0.292
U+E1BD -> '3' ncc=0.995 margin=0.317
ACCURACY: 11/11 = 100%
Eleven for eleven, against a font generated seconds earlier with a random permutation, on a 2-CPU VPS box, in well under a second of compute. The weakest score is the period (0.706) — punctuation carries little ink, so its correlation surface is flatter — and even it wins its top match by a 0.343 margin over the runner-up. Total attack cost: one HTTP fetch you’d make anyway to load the page in a browser, plus milliseconds of CPU.
Why this is unwinnable at this tier
Look at what the defender controls: the codepoints (read for free), the glyph assignment (scrambled — but the cracker doesn’t need the assignment, it reads shapes), the delivery (WOFF2, self-describing by design). The attacker needs only the font file (served publicly, necessarily), a template font (hundreds on their disk), and a rasterizer (stdlib). Every element of the attack is a commodity.
The margin column matters more than the accuracy column. A margin of 0.25–0.65 means the correct template won decisively, not on a technicality. To break this class of attack you’d need the glyph shapes themselves to stop resembling any font the attacker can template — which brings us to what actually survives.
What survives (and what it costs you)
Glyph geometry randomization. If every rendering of a digit uses a different outline — perturbed control points, swapped strokes, glyphs regenerated per session — template matching against a static base font dies. Now the attacker needs per-glyph classification (a small CNN trained on your font’s outputs), which is no longer an afternoon script but is still a weekend project, and each rotation cycle resets their training data. This is the real arms race: the sites that still use font obfuscation in 2026 rotate geometry so a harvested mapping table from zxjlm/Poirot-style projects goes stale.
Per-request font generation. Ship a unique font per session (the obfuscator tools support this). Cache-friendly it is not: every first-party visitor and every CDN edge needs its own WOFF2, and your cache hit ratio — the thing that makes your site fast — becomes the casualty. You are now spending infrastructure to defend data, and you should price that spend against what the data is worth.
Skip the font entirely. Inline SVG paths or canvas-drawn digits leave no cmap, no font file, no template target. This is the strongest variant and the direction serious targets have moved. The counter is real ML OCR on rendered pixels — costing orders of magnitude more per page than the 11-line matcher above. Defense doesn’t win; it reprices the attacker’s stack. That repricing is the entire product.
The economics for a data owner: per-session rotation costs engineering up front, a few kilobytes per session, and permanent cache complexity — in exchange, “every script kiddy reads my prices free” becomes “only attackers with vision pipelines and maintenance budgets do.” The sites doing it are the ones selling exactly the data everyone wants.
The part that matters to you, the builder
If you run the scraper side: audit every numeric field you store today. One check — digits should be U+0030–0039, anything in the PUA range is a smoking gun — tells you whether you’ve been publishing garbage to clients who trusted your green checkmarks. PUA characters survive into CSV exports, into Excel, and get multiplied. The failure is silent by construction.
If you run the data side: the tiered ladder is plain cmap scrambling (hours to build, minutes to crack — shown above), then geometry rotation per session (days to build, weeks of attacker maintenance), then non-text rendering (the reprieve, until someone trains a CNN on your pixels). Pick the rung that matches what one month of leaked data costs you, not the rung that demos well.
And if you’re the one being asked to “just get the data”: what you’re really being asked to build is the outer wall (browser automation that passes the bot checks) plus this mapping layer plus a drift monitor, because mappings change and your job dies quietly the day the site rotates without telling you. That stack — bot-wall traversal, glyph recovery, rotation-resistant OCR, and the monitoring that notices when any layer shifts — is a system, not a script. It’s also precisely the kind of system we build for clients: custom scraping infrastructure that survives contact with defended targets, priced per target instead of per hope.
Butuh versi custom dari pipeline ini — atau mau diintegrasikan ke sistem yang udah lu jalanin? Email ke [email protected] (detail lengkap di halaman /hire-us).
Tested environment: Python 3.14, fontTools 4.68.0, freetype-py 2.13.2, Pillow, numpy — all open source, no API keys. Every script in this article was executed to exit 0 on November 17, 2026 before publication; output shown is verbatim. The attack ran against a font generated on my own machine, not against any third party’s live data. Live-site probe referenced (maoyan.com) was a single unauthenticated GET that returned a bot-wall redirect. Bypassing a site’s protections may violate its terms of service and, depending on jurisdiction, the law — that determination belongs to you and your lawyer, not to a blog post.