A RFID/NFC automation testing framework for cards and readers.
Project description
nfctester 🥕
nfctester 是一个专为 RFID/NFC 卡片与 PN532 读卡器设计的自动化测试框架。项目采用严谨的分层架构设计,实现了硬件通信、芯片驱动、卡片逻辑与加密算法的深度解耦,旨在为 RFID 技术研究、漏洞分析及产品测试提供一个健壮且易于扩展的基础平台。
🌟 核心特性
- 分层架构: 清晰的 8 层体系结构,模块化程度高,易于维护与扩展。
- 广泛的协议支持:
- 卡片: Mifare Classic, ISO14443A, NFC Forum Type 2 Tag (NTAG21x/22x 等)。
- 芯片: 深度优化 PN532 HSU (High Speed UART) 驱动,支持位帧 (Bit-framing) 收发。
- 强大加密支持: 内置 AES-128 (CBC)、Mifare Crypto1 算法引擎,支持 NTAG22x AES 互认证。
- 可视化跟踪: 独特的跟踪控制层与协议解析层,提供树状结构化的通信日志输出,完美还原协议交互细节。
- 现代化工具链: 基于
uv进行包管理,集成pytest自动化测试与bump-my-version版本控制。
🏗️ 架构体系 (8-Layer Architecture)
项目遵循高度抽象的设计模式,分为以下八层:
- 硬件传输层 (Hardware): 负责底层字节流传输(如
SerialTransport)。 - 驱动层 (Driver): 实现特定芯片(如 PN532)的协议封装与寄存器操作。
- 卡片逻辑层 (Card): 定义各种 RFID 标签与智能卡的协议行为(Mifare, NTAG 等)。
- 加密算法层 (Crypto): 提供原子级的加密/解密操作(AES, Crypto1)。
- 通用工具层 (Utility): 包含 CRC 校验、位操作等基础辅助函数。
- 跟踪控制层 (Trace): 中心化的日志管理系统,实现业务逻辑与通信监控的分离。
- 协议解析层 (Parsers): 将字节流解析为结构化字段树,供格式化输出使用。
- 脚本/CLI 层 (CLI): 提供开箱即用的命令行工具。
🚀 快速上手
环境准备
推荐使用 uv 进行环境管理:
# 克隆仓库
git clone https://github.com/crthu/nfctester.git
cd nfctester
# 同步依赖
uv sync
运行工具
框架内置了多个实用的 CLI 工具:
- PN532 扫描器:
uv run pn532-scanner
- AES-128 加密工具:
uv run aes128-cli -m encrypt -i <hex_data> -k <hex_key>
运行测试
# 运行所有测试
uv run pytest
# 运行特定模块测试(如加密模块)
uv run pytest tests/crypto/
📄 开源协议
本项目基于 Apache License 2.0 协议开源。详见 LICENSE 文件。
本README由 Gemini 3 Flash 生成
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nfctester-0.0.38.tar.gz.
File metadata
- Download URL: nfctester-0.0.38.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
951c35b122387fcd382a90452fff2b34721f0b61d865a492de53f5300da4436a
|
|
| MD5 |
1116d8e8989f7df1ccc73e2dcb0e3cb9
|
|
| BLAKE2b-256 |
31e70942c01f34463e10cfeb9b6392bcc8e149ea672767c32057bb6412003c67
|
Provenance
The following attestation bundles were made for nfctester-0.0.38.tar.gz:
Publisher:
publish-pypi.yml on CRThu/nfctester
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nfctester-0.0.38.tar.gz -
Subject digest:
951c35b122387fcd382a90452fff2b34721f0b61d865a492de53f5300da4436a - Sigstore transparency entry: 1728411276
- Sigstore integration time:
-
Permalink:
CRThu/nfctester@8120b0584d4ca21bbe6396df3d561e8f731c4976 -
Branch / Tag:
refs/tags/v0.0.38 - Owner: https://github.com/CRThu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8120b0584d4ca21bbe6396df3d561e8f731c4976 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nfctester-0.0.38-py3-none-any.whl.
File metadata
- Download URL: nfctester-0.0.38-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bffed94eec421decab159a1467dc11e03a0be10e54627acaee67f0174fc8d833
|
|
| MD5 |
c1e6cffc039e53db8d57b31fc027830f
|
|
| BLAKE2b-256 |
6ef6e1aa35a751eae260843fb8ce887ae36724ce8397032db34e8afc6351c918
|
Provenance
The following attestation bundles were made for nfctester-0.0.38-py3-none-any.whl:
Publisher:
publish-pypi.yml on CRThu/nfctester
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nfctester-0.0.38-py3-none-any.whl -
Subject digest:
bffed94eec421decab159a1467dc11e03a0be10e54627acaee67f0174fc8d833 - Sigstore transparency entry: 1728411495
- Sigstore integration time:
-
Permalink:
CRThu/nfctester@8120b0584d4ca21bbe6396df3d561e8f731c4976 -
Branch / Tag:
refs/tags/v0.0.38 - Owner: https://github.com/CRThu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8120b0584d4ca21bbe6396df3d561e8f731c4976 -
Trigger Event:
push
-
Statement type: