diff --git a/.gitattributes b/.gitattributes index f123180..c1417e6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ -gigahorse-toolchain/* linguist-vendored \ No newline at end of file +gigahorse-toolchain/* linguist-vendored + +*.html linguist-language=Rust +*.py linguist-language=Rust \ No newline at end of file diff --git a/README.md b/README.md index 9ae363d..879c36d 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,8 @@ An Attacker Contract Identification Tool Implemented in Rust based on BlockWatchdog. +## Quick Start + +```shell RUST_LOG=info cargo run -- ETH 0x10C509AA9ab291C76c45414e7CdBd375e1D5AcE8 +``` diff --git a/src/main.rs b/src/main.rs index 0294b6d..db6a8d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ mod contract; mod flow; +mod outputter; use crate::contract::contract::Contract; use crate::flow::flow_analysis::FlowAnalysis; mod graph; -mod output; use crate::graph::call_graph::CallGraph; -use crate::output::result_structure::{ +use crate::outputter::result_structure::{ ExternalCall, OpCreation, Overlap, Result, SemanticFeatures, }; #[allow(unused_imports)] diff --git a/src/outputter/mod.rs b/src/outputter/mod.rs new file mode 100644 index 0000000..5ee6402 --- /dev/null +++ b/src/outputter/mod.rs @@ -0,0 +1 @@ +pub mod result_structure; diff --git a/src/outputter/result_structure.rs b/src/outputter/result_structure.rs new file mode 100644 index 0000000..277424d --- /dev/null +++ b/src/outputter/result_structure.rs @@ -0,0 +1,51 @@ +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct Result { + pub is_attack: bool, + pub warning: String, + pub attack_matrix: HashMap, + pub analysis_loc: String, + pub platform: String, + pub block_number: u64, + pub time: Option, + pub semantic_features: SemanticFeatures, + pub external_call: ExternalCall, + pub call_paths: Vec, + pub visited_contracts: Vec, + pub visited_contracts_num: usize, + pub visited_funcs: Vec, + pub visited_funcs_num: usize, + pub max_call_depth: u32, + pub contract_funcsigs: Vec, + pub contract_funcsigs_external_call: Vec, + pub sensitive_callsigs: Vec, + pub overlap: Overlap, + pub reentrancy_path_info: HashMap, +} + +#[derive(Serialize, Deserialize)] +pub struct SemanticFeatures { + pub op_creation: OpCreation, + pub op_selfdestruct: bool, + pub op_env: bool, +} + +#[derive(Serialize, Deserialize)] +pub struct OpCreation { + pub op_multicreate: bool, + pub op_solecreate: bool, +} +#[derive(Serialize, Deserialize)] +pub struct ExternalCall { + pub externalcall_inhook: bool, + pub externalcall_infallback: bool, + pub hooks_focused: Vec, +} +#[derive(Serialize, Deserialize)] +pub struct Overlap { + pub has_overlap: bool, + pub overlap_external_call: Vec, +}