Skip to content

Commit

Permalink
Add command line arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jan 10, 2020
1 parent a1d5cdd commit 80c0f1f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
9 changes: 9 additions & 0 deletions manticore/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def positive(value):
"--txnoether", action="store_true", help="Do not attempt to send ether to contract"
)

eth_flags.add_argument("--txvictim", type=str, help="Address of a deployed contract to attack")

eth_flags.add_argument(
"--txaccount",
type=str,
Expand All @@ -180,6 +182,13 @@ def positive(value):
"--contract", type=str, help="Contract name to analyze in case of multiple contracts"
)

eth_flags.add_argument(
"--rpc",
type=str,
dest="url",
help="Url of an Ethereum node to connect to. Must be of the form 'IP:PORT'",
)

eth_detectors = parser.add_argument_group("Ethereum detectors")

eth_detectors.add_argument(
Expand Down
8 changes: 7 additions & 1 deletion manticore/ethereum/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ..core.plugin import Profiler
from .manticore import ManticoreEVM
from .plugins import FilterFunctions, LoopDepthLimiter, VerboseTrace, KeepOnlyIfStorageChanges
from ..platforms.evm_world_state import RemoteWorldState
from ..utils.nointerrupt import WithKeyboardInterruptAs
from ..utils import config

Expand Down Expand Up @@ -70,7 +71,11 @@ def choose_detectors(args):


def ethereum_main(args, logger):
m = ManticoreEVM(workspace_url=args.workspace)
world_state = None
if args.url is not None:
world_state = RemoteWorldState(args.url)

m = ManticoreEVM(workspace_url=args.workspace, world_state=world_state)

if args.quick_mode:
args.avoid_constant = True
Expand Down Expand Up @@ -114,6 +119,7 @@ def ethereum_main(args, logger):
tx_limit=args.txlimit,
tx_use_coverage=not args.txnocoverage,
tx_send_ether=not args.txnoether,
contract_account=int(args.txvictim, base=0),
tx_account=args.txaccount,
tx_preconstrain=args.txpreconstrain,
compile_args=vars(args), # FIXME
Expand Down
23 changes: 13 additions & 10 deletions manticore/ethereum/manticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,23 +993,26 @@ def multi_tx_analysis(
tx_limit=None,
tx_use_coverage=True,
tx_send_ether=True,
contract_account: int = None,
tx_account="attacker",
tx_preconstrain=False,
args=None,
compile_args=None,
):
owner_account = self.create_account(balance=1000, name="owner")
attacker_account = self.create_account(balance=1000, name="attacker")
# Pretty print
logger.info("Starting symbolic create contract")

contract_account = self.solidity_create_contract(
solidity_filename,
contract_name=contract_name,
owner=owner_account,
args=args,
compile_args=compile_args,
)

if contract_account is None:
# Pretty print
logger.info("Starting symbolic create contract")

contract_account = self.solidity_create_contract(
solidity_filename,
contract_name=contract_name,
owner=owner_account,
args=args,
compile_args=compile_args,
)

if tx_account == "attacker":
tx_account = [attacker_account]
Expand Down

0 comments on commit 80c0f1f

Please sign in to comment.