|
|
|
@ -34,23 +34,30 @@ def exitWithError(message): |
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Bug hunting on the Ethereum blockchain') |
|
|
|
|
|
|
|
|
|
parser.add_argument('-d', '--disassemble', action='store_true', help='disassemble, specify input with -c or -a') |
|
|
|
|
parser.add_argument('-t', '--trace', action='store_true', help='trace, use with -c or -a and --data (optional)') |
|
|
|
|
parser.add_argument('-g', '--graph', help='generate a call graph', metavar='OUTPUT_FILE') |
|
|
|
|
parser.add_argument('-l', '--fire-lasers', action='store_true', help='detect vulnerabilities, use with -c or -a') |
|
|
|
|
parser.add_argument('-c', '--code', help='hex-encoded bytecode string ("6060604052...")', metavar='BYTECODE') |
|
|
|
|
parser.add_argument('-a', '--address', help='contract address') |
|
|
|
|
parser.add_argument('-o', '--outfile') |
|
|
|
|
parser.add_argument('--ipc', help='use ipc interface', action='store_true') |
|
|
|
|
parser.add_argument('-v', type=int, help='log level (0-2)') |
|
|
|
|
parser.add_argument('--data', help='message call input data for tracing') |
|
|
|
|
parser.add_argument('--search', help='search the contract database') |
|
|
|
|
parser.add_argument('--xrefs', help='get xrefs from contract in database', metavar='CONTRACT_HASH') |
|
|
|
|
parser.add_argument('--hash', help='calculate function signature hash', metavar='SIGNATURE') |
|
|
|
|
parser.add_argument('--init-db', action='store_true', help='Initialize the contract database') |
|
|
|
|
parser.add_argument('--sync-all', action='store_true', help='Also sync contracts with zero balance') |
|
|
|
|
parser.add_argument('--rpchost', default='127.0.0.1', help='RPC host') |
|
|
|
|
parser.add_argument('--rpcport', type=int, default=8545, help='RPC port') |
|
|
|
|
|
|
|
|
|
commands = parser.add_argument_group('commands') |
|
|
|
|
commands.add_argument('-d', '--disassemble', action='store_true', help='disassemble, specify input with -c or -a') |
|
|
|
|
commands.add_argument('-t', '--trace', action='store_true', help='trace, use with -c or -a and --data (optional)') |
|
|
|
|
commands.add_argument('-g', '--graph', help='generate a call graph', metavar='OUTPUT_FILE') |
|
|
|
|
commands.add_argument('-l', '--fire-lasers', action='store_true', help='detect vulnerabilities, use with -c or -a') |
|
|
|
|
commands.add_argument('-s', '--search', help='search the contract database') |
|
|
|
|
commands.add_argument('--xrefs', help='get xrefs from contract in database', metavar='CONTRACT_HASH') |
|
|
|
|
commands.add_argument('--hash', help='calculate function signature hash', metavar='SIGNATURE') |
|
|
|
|
commands.add_argument('--init-db', action='store_true', help='initialize the contract database') |
|
|
|
|
|
|
|
|
|
inputs = parser.add_argument_group('input arguments') |
|
|
|
|
inputs.add_argument('-c', '--code', help='hex-encoded bytecode string ("6060604052...")', metavar='BYTECODE') |
|
|
|
|
inputs.add_argument('-a', '--address', help='contract address') |
|
|
|
|
inputs.add_argument('--data', help='message call input data for tracing') |
|
|
|
|
|
|
|
|
|
options = parser.add_argument_group('options') |
|
|
|
|
options.add_argument('--sync-all', action='store_true', help='Also sync contracts with zero balance') |
|
|
|
|
options.add_argument('--rpchost', default='127.0.0.1', help='RPC host') |
|
|
|
|
options.add_argument('--rpcport', type=int, default=8545, help='RPC port') |
|
|
|
|
options.add_argument('--ipc', help='use IPC interface instead of RPC', action='store_true') |
|
|
|
|
options.add_argument('--disable-physics', action='store_true', help='disable graph physics simulation') |
|
|
|
|
options.add_argument('-v', type=int, help='log level (0-2)', metavar='LOG_LEVEL') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
db_dir = os.environ['DB_DIR'] |
|
|
|
@ -101,7 +108,12 @@ if (args.disassemble or args.graph or args.fire_lasers): |
|
|
|
|
|
|
|
|
|
elif (args.graph): |
|
|
|
|
|
|
|
|
|
html = generate_callgraph(disassembly) |
|
|
|
|
if (args.disable_physics): |
|
|
|
|
physics = False |
|
|
|
|
else: |
|
|
|
|
physics = True |
|
|
|
|
|
|
|
|
|
html = generate_callgraph(disassembly, physics) |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
with open(args.graph, "w") as f: |
|
|
|
|