Skip to main content

A RFID/NFC automation testing framework for cards and readers.

Project description

nfctester 🥕

License Python Version

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)

项目遵循高度抽象的设计模式,分为以下八层:

  1. 硬件传输层 (Hardware): 负责底层字节流传输(如 SerialTransport)。
  2. 驱动层 (Driver): 实现特定芯片(如 PN532)的协议封装与寄存器操作。
  3. 卡片逻辑层 (Card): 定义各种 RFID 标签与智能卡的协议行为(Mifare, NTAG 等)。
  4. 加密算法层 (Crypto): 提供原子级的加密/解密操作(AES, Crypto1)。
  5. 通用工具层 (Utility): 包含 CRC 校验、位操作等基础辅助函数。
  6. 跟踪控制层 (Trace): 中心化的日志管理系统,实现业务逻辑与通信监控的分离。
  7. 协议解析层 (Parsers): 将字节流解析为结构化字段树,供格式化输出使用。
  8. 脚本/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

nfctester-0.0.35.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nfctester-0.0.35-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file nfctester-0.0.35.tar.gz.

File metadata

  • Download URL: nfctester-0.0.35.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

Hashes for nfctester-0.0.35.tar.gz
Algorithm Hash digest
SHA256 8352c8e307abe6753e16c68718c09d386222a3d96b06db5d23947c7f842fedc5
MD5 6ac93af53990c12028318edeb876799b
BLAKE2b-256 23d4b03edddd7e7f84e15acf377ce8e9c7a14dbb67e69a5d78bddcc4c27976a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for nfctester-0.0.35.tar.gz:

Publisher: publish-pypi.yml on CRThu/nfctester

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nfctester-0.0.35-py3-none-any.whl.

File metadata

  • Download URL: nfctester-0.0.35-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

Hashes for nfctester-0.0.35-py3-none-any.whl
Algorithm Hash digest
SHA256 ad6edf78ee98df70949135aaa8482561b9198a4c3fdcf0507c1967bff9971d03
MD5 e3f2cad7298bc4680ad32fed4a91ef93
BLAKE2b-256 c0ddac0666fdfd374371de1b70e2832fa3dfc0f6389f8993b7135dacfdee59c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for nfctester-0.0.35-py3-none-any.whl:

Publisher: publish-pypi.yml on CRThu/nfctester

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page