Skip to content
KitploitKITPLOIT
도구익스플로잇블로그
Log in
제출
도구익스플로잇블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

피드문의개인정보© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
merkle-lab — 针对比特币 Merkle 根算法(含 CVE-2012-2459 变异检测机制)设计并实施自动化测试方案,覆盖功能正确性、边界场景与安全回归。 | Kitploit
도구/GitHubGitHub/gj504b123/merkle-lab
静态分析漏洞分析密码学论文与研究学习与教育
GitHubgj504b123/merkle-lab

merkle-lab

针对比特币 Merkle 根算法(含 CVE-2012-2459 变异检测机制)设计并实施自动化测试方案,覆盖功能正确性、边界场景与安全回归。

저장소 보기
2026년 11월 10일아직 검토되지 않음
공유
요청한 언어로 콘텐츠를 사용할 수 없습니다. 영어 버전을 표시합니다.

Automated Testing of the Merkle Root Algorithm

A Merkle root algorithm testing project based on Python + pytest, with tests designed around functional correctness, boundary scenarios, differential testing, real block test vectors, and security regression. After expanding parametrize, there are currently 72 pytest test items in total.

The project also includes an algorithm-level regression for the duplicate-transaction scenario related to CVE-2012-2459: it constructs inputs whose transaction lists differ but whose Merkle roots are identical, and verifies that the mutated detection flag behaves as expected.

1. Test Target

The code under test is located in merkle.py and mainly includes:

  • dsha256(data): applies SHA-256 twice in succession to the input bytes and returns a 32-byte result.
  • compute_merkle_root(tx_hashes): iteratively computes the Merkle root and detects adjacent duplicate hashes at paired positions.
    • Returns (root, mutated).
    • Empty input returns 32 zero bytes, mutated=False.
    • For an odd number of nodes, the last node is duplicated before pairing.
    • mutated detection occurs before odd-node padding.

The current implementation computes the result by copying the input list and generating a new hash list layer by layer, with an extra space complexity of O(n); it is not an in-place constant-space implementation.

2. Test Design

Test CategoryCountDesign MethodMain Coverage
Hand-crafted known answers3Known-answer testing, error guessingTwo leaves, three leaves with odd padding, adjacent duplicate leaves and mutated detection
Differential testing64Independent reference implementation, fixed-seed random dataTransaction sizes from 1 to 64, cross-checked group by group against a recursive reference implementation
Real block test vector1Real-data regressionTransaction list and Merkle root of Bitcoin block at height 170
Boundary testing2Boundary value analysisEmpty input, single-leaf input
CVE security regression2Control inputs, error guessingTwo constructions with 5/6 and 6/8 transactions, verifying identical roots and opposite mutated
Total72

The counts here are the number of test items after pytest parameterization expansion, not the number of test functions.

2.1 Differential Testing

test_merkle.py implements a recursive reference algorithm reference_root() that does not use mutated detection, serving as an independent reference:

  1. Use random.Random(2024 + n) to set a fixed random seed.
  2. For each n ∈ [1, 64], generate n random 32-byte transaction hashes.
  3. Call the iterative implementation under test and the recursive reference implementation respectively.
  4. Compare whether the two sets of Merkle roots are identical.

The fixed seed makes failing inputs reproducible, which helps with locating problems and adding regression cases.

2.2 Real Block Data and Offline Regression

fetch_block_data.py obtains real block data through the public Blockstream API:

  1. Obtain the block hash based on the block height.
  2. Obtain the list of transaction IDs in the block.
  3. Obtain the Merkle root from the block header.
  4. Save the above information as a local JSON test vector.

The currently saved data/block_170.json corresponds to the block at height 170 and contains 2 transaction IDs and the expected Merkle root. Daily pytest runs only read this local file and require no network access; only when re-collecting data is it necessary to connect to the network and install requests.

The tests also handle the difference between Bitcoin RPC display byte order and internal computation byte order: after reading the transaction IDs, they are reversed to internal byte order, and after computation the Merkle root is reversed back to display byte order for comparison.

2.3 CVE-2012-2459 Related Regression

The project includes two sets of algorithm-level control tests:

  • Honest input with 5 transactions, control input with 6 transactions.
  • Honest input with 6 transactions, control input with 8 transactions.

Both sets of tests verify:

  • The control input, by duplicating the last transaction, yields a Merkle root byte-for-byte identical to that of the honest input.
  • The honest input's mutated=False, and the constructed input's mutated=True.

Verification boundary: This project verifies the duplicate-transaction construction and the mutated detection logic in the Python implementation. It does not start bitcoind, nor does it verify that real nodes reject blocks or network consensus behavior; it should not be described as a complete reproduction of the consensus vulnerability in a real network.

3. Project Structure

merkle_lab/
├─ merkle.py             # 双 SHA-256、Merkle 根及 mutated 检测
├─ test_merkle.py        # pytest 测试与递归参考实现
├─ fetch_block_data.py   # 可选:重新采集真实区块数据
├─ data/
│  └─ block_170.json     # 本地真实区块测试向量
└─ README.md

4. Environment Setup

Python 3.9 or later is recommended (random data generation uses random.Random.randbytes).

Create and activate a virtual environment in the project root directory:

python -m venv .venv

Windows:

.venv\Scripts\activate
python -m pip install pytest

macOS / Linux:

source .venv/bin/activate
python -m pip install pytest

requests is only needed when re-collecting block data:

python -m pip install requests

5. Running the Tests

Please execute this in the project root directory to ensure the tests can read data/block_170.json:

python -m pytest -q

On Windows, you can also skip activating the virtual environment and run directly:

.venv\Scripts\python.exe -m pytest -q

If you only want to view the test collection results:

python -m pytest --collect-only -q

The actual number of passing tests and execution time are subject to the results of a complete run on your local machine; this project's documentation does not pre-fill unverified pass rates or execution times.

6. Optional: Re-collecting block data

After installing requests, run the following in the project root directory:

python fetch_block_data.py

This command accesses the Blockstream public API and overrides data/block_170.json. Running this script is not required for normal test execution.

7. Reproducibility Notes

  • The randomized differential tests use fixed seeds, so the same inputs can be generated repeatedly.
  • Real block data is saved as local JSON to prevent fluctuations in external services from affecting routine regression runs.
  • Each test category is located in test_merkle.py, so you can quickly locate the corresponding scenario by combining it with the test name.
  • The test scope focuses primarily on algorithms and input construction; it does not replace Bitcoin Core's full node, block validation, or network consensus testing.
도구 다운로드

관련 도구

  • ghidra

    Ghidra는 소프트웨어 리버스 엔지니어링(SRE) 프레임워크입니다.

  • capa

    Rule-based static and dynamic analysis tool that identifies capabilities in PE, ELF, .NET, and shellcode files, mapping them to MITRE ATT&CK techniques for malware triage.

  • yara-x

    Rust로 재작성된 YARA.

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

  • 1

    ghostlock-app

    yukonga/ghostlock-app

    # GhostLock 원탭 실행 앱 (CVE-2026-43499)

    745
  • 2

    IMSIcatcher

    28zaaky/imsicatcher

    SMS를 가로채고, 메시지를 주입하며, 모바일 기기를 추적하기 위해 악성 GSM 셀을 배포하는 IMSI Catcher 플랫폼

    732
  • 3

    Callisto

    jetp1ane/callisto

    Ghidra를 통해 실행 파일을 디컴파일하고, Semgrep으로 의사 C 코드를 스캔하며, GPT-3.5-Turbo를 사용하여 결과를 검증해 거짓 양성을 줄이는 자동화된 바이너리 취약점 분석 도구입니다.

    610
  • 4

    opencti

    opencti-platform/opencti

    오픈 사이버 위협 인텔리전스 플랫폼

    546
  • 5

    ARTEX

    baarai/artex

    LLM 멀티 에이전트 자율 침투 테스트 플랫폼으로, 플래너/워커 에이전트, 자산 및 탐색 그래프, MITM 트래픽 기록, 취약점 재테스트 기능을 제공합니다.

    414
  • 6

    DFRoot

    a2333c/dfroot

    삼성 Galaxy S25 Ultra(SM-S938B)용 Android 루트 도구로, DirtyFrag CVE-2026-43284와 CVE-2026-43499를 연쇄하여 KernelSU를 통해 부팅 시 자동으로 루트 권한을 획득합니다.

    413

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →