/
heimdall.rs
71 lines (53 loc) · 1.77 KB
/
heimdall.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
mod decompile;
use clap::{Parser, Subcommand};
use heimdall_common::{
ether::evm::{
disassemble::*,
}
};
use heimdall_config::{ config, get_config, ConfigArgs };
#[derive(Debug, Parser)]
#[clap(name = "heimdall", author = "Jonathan Becker <jonathan@jbecker.dev>", version)]
pub struct Arguments {
#[clap(subcommand)]
pub sub: Subcommands,
}
#[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 = "decompile", about = "Decompile EVM bytecode to Solidity")]
Decompile(decompile::DecompilerArgs),
#[clap(name = "disassemble", about = "Disassemble EVM bytecode to assembly")]
Disassemble(DisassemblerArgs),
#[clap(name = "config", about = "Display and edit the current configuration")]
Config(ConfigArgs),
#[clap(name = "cache", about = "Manage cached files for Heimdall.")]
Cache(decompile::DecompilerArgs),
}
fn main() {
let args = Arguments::parse();
let configuration = get_config();
match args.sub {
Subcommands::Decompile(cmd) => {
println!("{:#?}", cmd)
}
Subcommands::Disassemble(mut cmd) => {
// if the user has not specified a rpc url, use the default
match cmd.rpc_url.as_str() {
"" => { cmd.rpc_url = configuration.rpc_url.clone(); }
_ => {}
};
disassemble(cmd);
}
Subcommands::Config(cmd) => {
config(cmd);
}
Subcommands::Cache(cmd) => {
println!("{:#?}", cmd)
}
}
}