Fake Flash Drive Tester: CLI and Claude Code Skill
Overview
A Windows tool that proves whether a USB flash drive or SD card really holds its advertised capacity, packaged both as a standalone command-line script and as a Claude Code skill. The capacity test writes self-identifying data in doubling stages with unbuffered, write-through I/O and re-reads the entire written range after every stage, so a small fake is caught in an early stage and a wrap-around fake cannot hide. Failures are classified as discarded (zeros), wrap-around (with the real capacity worked out from the wrap distance) or garbage, and reported with claimed size, real size, multiplier and a region map. It refuses the system drive, network and optical drives, and non-empty drives unless told otherwise. Read-only commands identify the drive and list red flags, and check it for malware: autorun and shortcut-worm heuristics, a report-only Microsoft Defender scan, and a BadUSB check that flags keyboard or network functions hiding behind the storage. One standard-library Python file, no installs. 63 tests pass on Python 3.11 and 3.14 on Windows 11; no physical removable drive was tested for this release.
Source preview
def run_stages(tester, cap, start, out=print):
"""Write in doubling stages up to `cap` bytes, fully re-verifying after each.
Returns a Verdict whose kind is PASS, FAKE, WRITE-FAIL or READ-FAIL.
"""
stage = max(int(start) // SEC * SEC, SEC)
first = True
while tester.written < cap:
ok, note, wrate = tester.write_to(min(stage, cap))
res = tester.verify()
good = res.counts.get('OK', 0) * SEC
if res.error is not None:
return Verdict('READ-FAIL', res.error[0], res.error[1], None)
if res.first_bad is not None:
off, state, src = res.first_bad
out(' [{:>9.2f} MiB written] verified {:9.2f} MiB good, CORRUPTION FOUND'.format(
tester.written / MIB, good / MIB))
return Verdict('FAKE', off, note if not ok else None, (state, src, res.counts, res.runs))
if not ok:
out(' [{:>9.2f} MiB] {}'.format(tester.written / MIB, note))
return Verdict('WRITE-FAIL', tester.written, note, None)
out(' [{:>9.2f} MiB written @ {:>10}] verified {:9.2f} MiB good ({:.1f} MB/s read)'.format(
tester.written / MIB, note, good / MIB, res.read_mbps))
if first and tester.written < cap:
est = estimate_seconds(cap - tester.written, wrate, res.read_mbps * 1e6)
out(' (at these speeds the rest of the test takes roughly %s if the drive is genuine)'
% fmt_duration(est))
first = False
stage *= 2
return Verdict('PASS', tester.written, None, None)Excludes tax, added at checkout where it applies.