-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
get_bytecode
, get_calldata
to args
- Loading branch information
1 parent
9ac619a
commit 9b84172
Showing
14 changed files
with
106 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
//! clap [Args](clap::Args) for logging configuration. | ||
// Mostly taken from [reth](https://github.com/paradigmxyz/reth) | ||
use clap::{Parser, Subcommand}; | ||
|
||
use clap::{ArgAction, Args, ValueEnum}; | ||
use heimdall_cache::CacheArgs; | ||
use heimdall_config::ConfigArgs; | ||
use heimdall_core::{ | ||
heimdall_cfg::CFGArgs, heimdall_decoder::DecodeArgs, heimdall_decompiler::DecompilerArgs, | ||
heimdall_disassembler::DisassemblerArgs, heimdall_dump::DumpArgs, | ||
heimdall_inspect::InspectArgs, | ||
}; | ||
use heimdall_tracing::{ | ||
tracing_subscriber::filter::Directive, FileWorkerGuard, HeimdallTracer, LayerInfo, LogFormat, | ||
Tracer, | ||
|
@@ -12,6 +18,51 @@ use std::{ | |
}; | ||
use tracing::{level_filters::LevelFilter, Level}; | ||
|
||
#[derive(Debug, Parser)] | ||
#[clap(name = "heimdall", author = "Jonathan Becker <[email protected]>", version)] | ||
pub struct Arguments { | ||
#[clap(subcommand)] | ||
pub sub: Subcommands, | ||
|
||
#[clap(flatten)] | ||
pub logs: LogArgs, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
#[clap( | ||
about = "Heimdall is an advanced Ethereum smart contract toolkit for forensic and heuristic analysis.", | ||
after_help = "For more information, read the wiki: https://jbecker.dev/r/heimdall-rs/wiki" | ||
)] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum Subcommands { | ||
#[clap(name = "disassemble", about = "Disassemble EVM bytecode to assembly")] | ||
Disassemble(DisassemblerArgs), | ||
|
||
#[clap(name = "decompile", about = "Decompile EVM bytecode to Solidity")] | ||
Decompile(DecompilerArgs), | ||
|
||
#[clap(name = "cfg", about = "Generate a visual control flow graph for EVM bytecode")] | ||
CFG(CFGArgs), | ||
|
||
#[clap(name = "decode", about = "Decode calldata into readable types")] | ||
Decode(DecodeArgs), | ||
|
||
#[clap(name = "config", about = "Display and edit the current configuration")] | ||
Config(ConfigArgs), | ||
|
||
#[clap(name = "cache", about = "Manage heimdall-rs' cached files")] | ||
Cache(CacheArgs), | ||
|
||
#[clap(name = "dump", about = "Dump the value of all storage slots accessed by a contract")] | ||
Dump(DumpArgs), | ||
|
||
#[clap( | ||
name = "inspect", | ||
about = "Detailed inspection of Ethereum transactions, including calldata & trace decoding, log visualization, and more" | ||
)] | ||
Inspect(InspectArgs), | ||
} | ||
|
||
/// The log configuration. | ||
#[derive(Debug, Args)] | ||
#[clap(next_help_heading = "LOGGING")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,24 @@ | ||
pub(crate) mod log_args; | ||
pub(crate) mod args; | ||
pub(crate) mod output; | ||
|
||
use args::{Arguments, Subcommands}; | ||
use clap::Parser; | ||
use eyre::{eyre, Result}; | ||
use log_args::LogArgs; | ||
use heimdall_cache::cache; | ||
use output::{build_output_path, print_with_less}; | ||
use tracing::info; | ||
|
||
use clap::{Parser, Subcommand}; | ||
|
||
use heimdall_cache::{cache, CacheArgs}; | ||
use heimdall_common::utils::{ | ||
hex::ToLowerHex, | ||
io::file::write_file, | ||
version::{current_version, remote_nightly_version, remote_version}, | ||
}; | ||
use heimdall_config::{config, ConfigArgs, Configuration}; | ||
use heimdall_config::{config, Configuration}; | ||
use heimdall_core::{ | ||
heimdall_cfg::{cfg, CFGArgs}, | ||
heimdall_decoder::{decode, DecodeArgs}, | ||
heimdall_decompiler::{decompile, DecompilerArgs}, | ||
heimdall_disassembler::{disassemble, DisassemblerArgs}, | ||
heimdall_dump::{dump, DumpArgs}, | ||
heimdall_inspect::{inspect, InspectArgs}, | ||
heimdall_cfg::cfg, heimdall_decoder::decode, heimdall_decompiler::decompile, | ||
heimdall_disassembler::disassemble, heimdall_dump::dump, heimdall_inspect::inspect, | ||
}; | ||
|
||
#[derive(Debug, Parser)] | ||
#[clap(name = "heimdall", author = "Jonathan Becker <[email protected]>", version)] | ||
pub struct Arguments { | ||
#[clap(subcommand)] | ||
pub sub: Subcommands, | ||
|
||
#[clap(flatten)] | ||
logs: LogArgs, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
#[clap( | ||
about = "Heimdall is an advanced Ethereum smart contract toolkit for forensic and heuristic analysis.", | ||
after_help = "For more information, read the wiki: https://jbecker.dev/r/heimdall-rs/wiki" | ||
)] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum Subcommands { | ||
#[clap(name = "disassemble", about = "Disassemble EVM bytecode to assembly")] | ||
Disassemble(DisassemblerArgs), | ||
|
||
#[clap(name = "decompile", about = "Decompile EVM bytecode to Solidity")] | ||
Decompile(DecompilerArgs), | ||
|
||
#[clap(name = "cfg", about = "Generate a visual control flow graph for EVM bytecode")] | ||
CFG(CFGArgs), | ||
|
||
#[clap(name = "decode", about = "Decode calldata into readable types")] | ||
Decode(DecodeArgs), | ||
|
||
#[clap(name = "config", about = "Display and edit the current configuration")] | ||
Config(ConfigArgs), | ||
|
||
#[clap(name = "cache", about = "Manage heimdall-rs' cached files")] | ||
Cache(CacheArgs), | ||
|
||
#[clap(name = "dump", about = "Dump the value of all storage slots accessed by a contract")] | ||
Dump(DumpArgs), | ||
|
||
#[clap( | ||
name = "inspect", | ||
about = "Detailed inspection of Ethereum transactions, including calldata & trace decoding, log visualization, and more" | ||
)] | ||
Inspect(InspectArgs), | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let args = Arguments::parse(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters