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

    YARA を Rust で書き直したもの。

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

  • 1

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock ワンタップ実行アプリ(CVE-2026-43499)

    745
  • 2

    IMSIcatcher

    28zaaky/imsicatcher

    不正なGSMセルを展開してSMSを傍受し、メッセージを注入し、モバイル端末を追跡する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

    プランナー/ワーカーエージェント、資産グラフと探索グラフ、MITMトラフィック記録、脆弱性の再テストを備えたLLMマルチエージェント自律ペネトレーションテストプラットフォーム。

    414
  • 6

    DFRoot

    a2333c/dfroot

    Samsung Galaxy S25 Ultra (SM-S938B) 向けの Android root ツール。DirtyFrag CVE-2026-43284 と CVE-2026-43499 を連鎖させ、KernelSU 経由で起動時に自動的に root を取得します。

    413

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →