Echidna/Medusa Trace Parser is a Python script designed to parse Echidna and Medusa traces and generate corresponding Solidity test functions. This tool simplifies the process of converting fuzzer output into usable Solidity tests, making it easier to replay call sequences.
- Parse Fuzzer Call Traces: Extracts function calls, parameters, delays, and 'from' addresses from Echidna and Medusa traces.
- Generate Solidity Test Functions: Automatically creates Solidity test functions based on the parsed data.
- User-Friendly Input: Allows users to paste traces directly into the terminal.
- Format Detection: Automatically detects whether the input is an Echidna or Medusa trace.
- Python 3.x
- Basic familiarity with the command line
-
Clone the repository:
git clone https://github.com/Enigma-Dark/fuzz-trace-parser.git cd fuzz-trace-parser
-
Download the Script: Alternatively, download the script file directly and save it in a directory of your choice.
-
Ensure Python is Installed: You can check if Python is installed by running:
python3 --version
If it's not installed, download and install it from python.org.
To run the Trace Parser from any directory in your terminal, follow these steps:
If you're using macOS or Linux, you can make the script executable:
- Open your terminal.
- Navigate to the directory where the script is located:
cd /path/to/your/directory
- Run the following command to make the script executable:
chmod +x fuzz_parser.py
To run the script from anywhere, you can add its directory to your system's PATH.
- Open your terminal.
- Edit your shell configuration file (like
~/.bashrc
,~/.bash_profile
, or~/.zshrc
) and add the following line, replacing/path/to/your/directory
with the actual path where your script is located:export PATH="$PATH:/path/to/your/directory"
- Save the file and run:
(or the corresponding file for your shell).
source ~/.bashrc
- Search for "Environment Variables" in the Start menu.
- Click on "Edit the system environment variables".
- In the System Properties window, click on "Environment Variables".
- In the "System variables" section, find and select the
Path
variable, then click "Edit". - Click "New" and add the full path to the directory where your script is saved.
- Click OK to save your changes.
-
Open your terminal.
-
Run the script from anywhere:
fuzz_parser.py
or if you haven't made it executable:
python3 fuzz_parser.py
-
Input your fuzzer call trace:
- Paste your Echidna or Medusa call trace directly into the terminal.
- Press Enter twice to finish input.
-
View the Generated Solidity Test Function: The tool will output the generated Solidity test function to the terminal.
Paste your Echidna or Medusa call trace below. Press Enter twice to finish:
Tester.function_name(param1, param2) from: 0x12345 Time delay: 5
*wait* Time delay: 3
Detected Echidna trace format
Generated Foundry Test Function:
function test_replay() public {
_setUpActor(0x12345);
_delay(5);
Tester.function_name(param1, param2);
_delay(3);
}
Paste your Echidna or Medusa call trace below. Press Enter twice to finish:
1) Tester.deposit(uint256,uint8,uint8)(1239852167739453881995240, 0, 0) (block=2, time=2, gas=1250000000, gasprice=1, value=0, sender=0x10000)
2) Tester.donateUnderlying(uint256,uint8,uint8)(45369402357901978417531215225742791157530708442686125403256020909207651452, 0, 11) (block=2138, time=175249, gas=1250000000, gasprice=1, value=0, sender=0x30000)
Detected Medusa trace format
Generated Foundry Test Function:
function test_replay() public {
_setUpActor(0x10000);
_delay(2);
Tester.deposit(1239852167739453881995240, 0, 0);
_setUpActor(0x30000);
_delay(175247);
Tester.donateUnderlying(45369402357901978417531215225742791157530708442686125403256020909207651452, 0, 11);
}
Contributions are welcome! If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your branch and submit a pull request.
This project is not open-source.
For any inquiries or feedback, feel free to reach out on the organization's Discord server.