Giter Club home page Giter Club logo

mevsec-ctf-brownie's Introduction

๐Ÿ”จ Mevsec CTF Solution Setup Using Brownie ๐Ÿ”ง

๐Ÿ“‹ Description

A step-by-step guide to setting up a Brownie project for solving Mevsec CTF challenges, enabling you to deploy and interact with Ethereum smart contracts using Brownie framework.

CTF: https://ctf.mevsec.com/

๐Ÿ“ Prerequisites

Make sure you have the following installed before proceeding:

  • Python 3.7+
  • Brownie framework
  • Ganache or another Ethereum development environment

๐Ÿš€ Getting Started

1๏ธโƒฃ Install Python 3.x from the official Python website: https://www.python.org/downloads/

2๏ธโƒฃ Install Brownie framework using pip:

pip install eth-brownie

3๏ธโƒฃ Set up a Ganache or other Ethereum development environment for local testing and development. (Optional brownie will do it automatically just have to install & configure)

4๏ธโƒฃ Create a new directory for your Mevsec CTF solution project and navigate to it in the terminal.

5๏ธโƒฃ Initialize a new Brownie project using the brownie init command.

6๏ธโƒฃ Add the smart contracts provided in the Mevsec CTF challenge to the contracts directory in the project.

7๏ธโƒฃ Write tests for the smart contracts in the tests/ directory to verify the solutions.

8๏ธโƒฃ Compile the smart contracts using the brownie compile command.

9๏ธโƒฃ Deploy the smart contracts to the local development environment using the brownie run command and interact with them to solve the challenges.

๐Ÿ“‚ Project Structure

Your Mevsec CTF Solution project structure should look like this:

Intro-YouTube_&_Blog_DONE/
โ”œโ”€โ”€ contracts
โ”‚   โ”œโ”€โ”€ Setup.sol
โ”‚   โ””โ”€โ”€ VideoChalllengeIntro.sol
โ”œโ”€โ”€ interfaces
โ”œโ”€โ”€ reports
โ”œโ”€โ”€ scripts
โ””โ”€โ”€ tests

Solution

  • Put the corresponding contracts in the contracts directory
  • Get the RPC URL, Private Key, and instance ID like this. Depending on the challenge the number changes from 0, 1 & so on. This is an example for the first challenge.
curl '5.196.27.132:8080/create_challenge?challenge_number=0'
{
  "message": "New instance of mevsec_ctf0 created. The RPC URL to connect to this private blockchain is  http://ctf.mevsec.com:50659. The Setup contract has been deployed at the following address: 0x876807312079af775c49c916856A2D65f904e612. If you need to deploy a contract or send a tx you can use the account 0x133756e1688E475c401d1569565e8E16E65B1337 with the private key 0xedbc6d1a8360d0c02d4063cdd0a23b55c469c90d3cfbc2c88a015f9dd92d22b3. Please don't forget you will need the following ID to flag => 662a97aa2ca4263410b6ea03cfd0fe818f44d35c9bf79bd64ac72c846218fea3. Be careful the instance will stop automatically after 20 minutes..",
  "status": "success"
}
  • Based on the data we got add the mevsec RPC url to brownie config like this
brownie networks add Ethereum mevsec host=http://ctf.mevsec.com:50659 chainid=1337
  • Run brownie compile to build.
  • Add brownie-config.yaml
dotenv: .env
networks:
  default: mainnet-fork
  mevsec:
    verify: False
wallets:
  from_key: ${PRIVATE_KEY}
  • Add .env file as these values are static. For all the challenge they will be same
export PRIVATE_KEY=0xedbc6d1a8360d0c02d4063cdd0a23b55c469c90d3cfbc2c88a015f9dd92d22b3
  • For local testing run
# local testing
brownie run scripts/hack.py

# mevsec network
brownie run scripts/hack.py --network mevsec

๐Ÿ“š Resources

๐ŸŽ‰ Congratulations! Your Mevsec CTF Solution project is now set up with Brownie, ready for Ethereum smart contract development and solving the Mevsec CTF challenges. Happy coding! ๐Ÿš€๐Ÿ’ก๐Ÿ”“๐Ÿ”

Current Rankings

mevsec-ctf-brownie's People

Contributors

aviksaikat avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.