关于「限速、黑名单与哈希前缀:在线猜测的天花板」,《口令熵与最小权限》给出的定量结论是什么?

结论:不知道前缀时,攻击者只猜一次的成功率是第一名候选的概率 0.0314。知道 1 个十六进制字符的前缀后,成功率升到 0.1240,是原来的 3.9 倍;2 个字符时 0.3041,9.7 倍;3 个字符时 0.6214,19.8 倍;4 个字符时 0.9463,30.1 倍。原因在「平均桶大小」那一列:20,000 个候选分到 4,096 个桶里,每个桶平均只有 4.9 个;分到 65,536 个桶里,平均每桶 0.3 个,桶里几乎只剩一个候选,前缀就等于答案。

数据口径:书中的公司、账户与概率参数均为示意,全部计算由书中程序生成;本书不是个性化的经营、法律、财务或合规建议,审计流程与小工具不接触任何真实口令。 第六章用最小角色覆盖与找回关系图说明,示意公司期望每年失守 0.4972 个账户,只加固主邮箱就降到 0.1899。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.0314, 0.1240, 0.3, 0.3041, 0.6214, 0.9463

toy population N=20,000, Zipf s=0.8; one guess per account
prefix hbucketsmean sizelam1 given prefixgain over lam1
1161250.00.12403.9
225678.10.30419.7
34,0964.90.621419.8
465,5360.30.946330.1
no prefix: lam1 = 0.0314
demo prefix of sha1('cand-00001'): 5ff41
查看完整验算程序
# Chapter 5. p52: what a hash-prefix breach query leaks.
# A breach-checking service is sent the first h hex digits of the
# password's SHA-1 and returns every leaked hash with that prefix, so
# the password itself never leaves the device. Li et al. (2019) showed
# that the prefix still helps a guessing attacker. Toy population: 20,000
# synthetic strings "cand-00001" and so on with Zipf s = 0.8 popularity
# (illustrative; no real password is used). An attacker who sees the
# prefix guesses the most popular candidate inside that bucket.
import hashlib
import math
from collections import defaultdict

N, S = 20_000, 0.8
cands = ["cand-{:05d}".format(i) for i in range(1, N + 1)]
w = [r ** (-S) for r in range(1, N + 1)]
z = math.fsum(w)
p = [x / z for x in w]
digest = [hashlib.sha1(c.encode("ascii")).hexdigest() for c in cands]

print("toy population N=20,000, Zipf s=0.8; one guess per account")
print("prefix h  buckets  mean size  lam1 given prefix  gain over lam1")
lam1 = p[0]
for h in (1, 2, 3, 4):
    best = defaultdict(float)
    for d, x in zip(digest, p):
        key = d[:h]
        if x > best[key]:
            best[key] = x
    got = math.fsum(best[k] for k in sorted(best))
    print("{:<8d}  {:>7,d}  {:>9.1f}  {:>17.4f}  {:>13.1f}".format(
        h, 16 ** h, N / 16 ** h, got, got / lam1))
print("no prefix: lam1 = {:.4f}".format(lam1))
print("demo prefix of sha1('cand-00001'): {}".format(digest[0][:5]))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《口令熵与撞库攻击、强制改密反安全悖论与一人公司账号最小权限母典》第 5 章「限速、黑名单与哈希前缀:在线猜测的天花板」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-218 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026218,
  author    = {Fan, Yafu},
  title     = {Password Entropy and Credential Stuffing, the Forced-Rotation Paradox and Least-Privilege Accounts for One-Person Firms},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论