ethpector package

Subpackages

Submodules

ethpector.analysis module

class ethpector.analysis.ClassificationMatches(symbolic: list[ethpector.classify.classification.InterfaceMatch], disassembly: list[ethpector.classify.classification.InterfaceMatch], bytecode: list[ethpector.classify.classification.KnownBytecode], address: list[ethpector.classify.classification.KnownAddress])[source]

Bases: object

Summarizes the potential matches of a given bytecode with known interfaces , byte-codes of addresses.

address: list[ethpector.classify.classification.KnownAddress]
bytecode: list[ethpector.classify.classification.KnownBytecode]
disassembly: list[ethpector.classify.classification.InterfaceMatch]
symbolic: list[ethpector.classify.classification.InterfaceMatch]
class ethpector.analysis.CodeAnalysis(address: str, code: str, config: Configuration, online_resolver: DataProvider)[source]

Bases: object

The main class that aggregates all analysis functionality.

aa

Analysis based on the disassembly and simple dataflow.

Type:

AssemblyAnalyzer

online_resolver

Abstract data provider. Is responsible for fetching data from online sources (node, etherscan, 4bytes etc)

Type:

DataProvider

sa

Analysis capabilities based on symbolic execution

Type:

SymbolicAnalyzer

code_hash()[source]
get_address()[source]
get_annotated_dissassembly() <ethpector.data.datatypes.ToJsonDecorator object at 0x7f8ff35d2f70>[source]
get_bytecode()[source]
get_call_summary() list[ethpector.analysis.InstructionOverview][source]
get_function_summary() FunctionOverview[source]
get_identifier()[source]
get_interface_matches(threshold=0.5) ClassificationMatches[source]
get_online_resolver()[source]
get_sender_constraint_functions() FunctionOverview[source]
get_source_summary()[source]
get_storage_summary() StorageOverview[source]
get_summary()[source]
class ethpector.analysis.FunctionOverview(entry_point: FunctionEntrypoint, detailed_overview: list[ethpector.data.datatypes.FunctionSummary], sender_constraint: Optional[SenderConstraintFunction])[source]

Bases: object

Summary of functions found in the program

detailed_overview: list[ethpector.data.datatypes.FunctionSummary]
entry_point: FunctionEntrypoint
sender_constraint: Optional[SenderConstraintFunction]
class ethpector.analysis.InstructionOverview(instruction: Instruction, detailed_overview: Optional[AnnotationBase])[source]

Bases: object

Instruction and its annotation.

detailed_overview: Optional[AnnotationBase]
instruction: Instruction
class ethpector.analysis.StorageOverview(reads: list[ethpector.analysis.InstructionOverview], writes: list[ethpector.analysis.InstructionOverview])[source]

Bases: object

Reads and writes found to permanent storage found in the program.

reads: list[ethpector.analysis.InstructionOverview]
writes: list[ethpector.analysis.InstructionOverview]

ethpector.main module

class ethpector.main.OutputWriter(config: Configuration, identifier: str)[source]

Bases: object

The output writer takes care of writing output either to a file or to std out. The behavior depends on the config option config.to_file .. attribute:: config

Configuration of the tool

type:

Configuration

header

If data is written to stdout headers are inserted between file to make them separable. The field keeps track if header was already written for a particular file.

Type:

dict

identifier

Defines the folder used to write the output. Usually an address of the hash of the bytecode

Type:

str

open_files

Stores the open files to be closed when the scope ends

Type:

dict

ensureheader(file)[source]
get_folder()[source]
get_full_filename(filename)[source]
write(data, file)[source]
ethpector.main.extract_information(address: str, code: str, config: Configuration) CodeAnalysis[source]

Provides a high level interface to the ethpector functionality.

Parameters:
  • address (str) – Hex-string of an address prefixed with 0x. The address is used to acquire the bytecode to analyze for etherscan or a rpc node connection.

  • code (str) – Hex-string of the bytecode

  • config (Configuration) – Configuration to use.

Returns:

Object wrapping the available data extraction functions.

Return type:

CodeAnalysis

ethpector.main.main(args)[source]

Main entry point of the ethpector command-line tool.

Parameters:

args (TYPE) – Description

ethpector.main.output_result(report: CodeAnalysis, config: Configuration)[source]

Writes the output based on the current configuration provided.

Parameters:
  • report (CodeAnalysis) – Interface to the analysis data.

  • config (Configuration) – The configuration defines what data should be produced

ethpector.main.parse_args(args)[source]

Parses the arguments provided on the command-line.

Parameters:

args (list) – List of command-line arguments.

Returns:

Parsed command-line args object

Return type:

Object

ethpector.main.run()[source]
ethpector.main.setup_logging(loglevel)[source]

Sets up the ethpector logging format.

Parameters:

loglevel (TYPE) – Logging.level

Module contents