Zokyo Automated Tools
  • πŸ€–Unlocking Smart Contract Security: A Comprehensive Guide to Automated Vulnerability Analysis
  • 🐍Mastering Slither: A Comprehensive Guide to Smart Contract Vulnerability Detection
    • πŸš€Prerequisites
      • πŸ’»Code Editor
      • 🐍Setting up Python and Configuring Virtual Environments
      • πŸ”­Setting Up Git
      • πŸ‘ŠGit Bash
    • ⚑What Is Static Analysis
    • 🐍What Is Slither
    • πŸ“©Setting Up Slither: Installation and Virtual Environment Configuration
    • πŸ”©Installing solc and Crytic Compile: Foundation Tools for Slither
    • πŸ”Analyzing Smart Contracts Locally with Slither
      • πŸ—ΊοΈHandling Import Errors in Slither: A Guide on Solc Remappings
      • πŸ›£οΈHandling Path Errors In Slither
    • 🌍Analyzing Smart Contracts Already Deployed On Main-nets
    • πŸ”ŒExploring Slither's Tools and Printers: A Comprehensive Tutorial
    • πŸ€–Using Bash Scripts for Batch Analysis with Slither
    • πŸ’»Slither Intermediate Representation
    • 🌐Slither Python API
    • ⚠️Custom Detectors in Slither
      • 🀝Leveraging Custom Detectors from the Community
        • πŸ€—Leveraging Custom Detectors from the Community: Spotlight on the pessimistic.io Team
      • 🌱Making your own detectors
  • βš›οΈOyente: Symbolic Execution Tool
    • 😎What Is Symbolic Execution?
Powered by GitBook
On this page
  1. Mastering Slither: A Comprehensive Guide to Smart Contract Vulnerability Detection

Using Bash Scripts for Batch Analysis with Slither

PreviousExploring Slither's Tools and Printers: A Comprehensive TutorialNextSlither Intermediate Representation

Last updated 1 year ago

Benefits

  1. Automation: Bash scripts automate the repetitive task of typing commands to analyze multiple contracts individually, making the process more efficient.

  2. Batch Processing: Multiple contracts can be analyzed sequentially without manual intervention.

  3. Customization: The bash script can be customized to handle different networks, manage outputs, and handle errors specifically.

  4. Logging: The analysis results and error messages can be redirected and saved into specific files for later review and record-keeping.

Pre-requisites

  • Git Bash: Ensure that Git Bash is installed, as it allows for the execution of bash scripts on Windows.

  • Virtual Environment: Make sure the virtual environment where Slither is installed is properly set up.

Writing the Bash Script

Here is a reference bash script that you can use:

#!/bin/bash

# Navigate to the virtual environment directory
cd /c/Users/Omar/Desktop/SlitherVE/env

# Activate the virtual environment
source ./Scripts/activate

# Run Slither on a contract from the mainnet and save the output to a file
slither 0x8FE00a685Bcb3B2cc296ff6FfEaB10acA4CE1538 > mainnet_output.txt 2> mainnet_errors.txt

echo "Mainnet analysis completed."

# Run Slither on a contract from Arbitrum and save the output to a file
slither arbi:0xc20DE37170B45774e6CD3d2304017fc962f27252 > arbitrum_output.txt 2> arbitrum_errors.txt

echo "Arbitrum analysis completed."

Explanation

  • The script starts by navigating to the virtual environment directory.

  • It then activates the virtual environment.

  • Subsequently, the script runs Slither on contracts from different networks.

  • The results of the Slither analysis are saved into text files, and error messages are saved separately.

  • Echo commands are used to print messages indicating the completion of analysis for each network.

Execution

  1. Save the above script into a file with a .sh extension, e.g., slither_analysis.sh.

  2. Open Git Bash.

  3. Navigate to the directory where your bash script is located.

  4. Make the script executable by running: chmod +x slither_analysis.sh.

  5. Execute the script: ./slither_analysis.sh.

Conclusion

Using bash scripts for batch analysis with Slither is a robust method to automate, customize, and efficiently manage the analysis of multiple contracts across various networks. Ensure that all pre-requisites are properly set up and that the script is customized according to your specific needs and paths.

🐍
πŸ€–
Book an audit with Zokyo
Download Git Bash