Skip to content

smartcontract2025/Bytecode_pattern_extractor

Repository files navigation

Smart Contract Bytecode Graph Constructor and expert pattern extrctor

A tool for constructing graphs from smart contract bytecode (opcodes) and annotating nodes using specially designed expert patterns. The designed expert pattern encouraged by the source code based approaches from:

  1. [IJCAI 2021] Smart Contract Vulnerability Detection: From Pure Neural Network to Interpretable Graph Feature and Expert Pattern Fusion
  2. [TKDE 2021] Combining Graph Neural Networks with Expert Knowledge for Smart Contract Vulnerability Detection

Features

  • Bytecode-to-Graph Conversion: Constructs control flow graphs (CFGs) directly from Ethereum bytecode
  • Expert Pattern Annotation: Implements specialized vulnerability detection patterns for:
    • Timestamp dependency
    • Reentrancy vulnerabilities
    • Infinite loops

Installation

git clone https://github.com/yourusername/smart-contract-graph-constructor.git
cd smart-contract-graph-constructor
pip install -r requirements.txt

Expert Pattern Implementation

Our implementation extends the expert patterns from the cited papers to work directly with bytecode:

Timestamp Dependency Pattern Detects blocks containing TIMESTAMP or BLOCKHASH opcodes and their data-dependent successors

Reentrancy Pattern Identifies dangerous call sequences following the checks-effects-interactions pattern

Infinite Loop Pattern Detects potential unbounded loops through jump analysis

Output Format Generated graphs follow this JSON structure:

{
  "nodes": ["block_1", "block_2", ...],
  "edges": [[0, 1], [1, 2], ...],
  "target_nodes": [3, 5, ...]
}

For more details please see our paper and code...

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages