Giter Site home page Giter Site logo

tsmithv11 / goatcasino Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ethereumsec/goatcasino

0.0 0.0 0.0 24 KB

Intentionally vulnerable dApp for learning blockchain and smart contract security.

Home Page: https://www.nccgroup.trust/us/our-research/discovering-smart-contract-vulnerabilities-with-goatcasino/

License: MIT License

Shell 3.56% JavaScript 45.85% Solidity 50.59%

goatcasino's Introduction

Welcome to the GOAT Casino!

Try your luck(or skills) at the various games in the casino to win fabulous tokens and prizes!

This is under development so there may be a disappointing amount of games at the moment but there are more to come and plenty of things to exploit in the meantime.

To Begin:

  1. Install dependencies

    1. The latest version of node
    2. sudo apt install npm
    3. sudo npm install -g truffle ganache-cli
  2. Run ./start_challenge.sh to start testrpc, deploy the casino to your local testnet, and begin simulating the other players

  3. Review the code in the contracts/ directory to find vulnerabilities

  4. Make proof of concept scripts to obtain as many CasinoTokens as you can! (look at the simulated user scripts in exec/simuilated-users/ directory to get an idea of how to interact with the contracts if you are stuck)

Rules:

  1. Only perform actions as the "attacker", which is the first account in the testrpc. I made it easy because that's the account truffle will use by default but if you want to be sure you are right, you can use the library at GOATlib/GOATConfig.js and use GOATConfig.accounts.attacker for all your calls. I know you have access to the actual owner accounts and the other players since it's on testrpc and I'm not impressed with your script to cycle through the accounts and call transfer.
  2. You can change the contracts/deployment code/simulated users as much as you like for debugging purposes, but keep in mind that your solutions should work on the unmodified code by the end.

Directory structure:

  • GOATlib/: Library with code used by the various JavaScript files.
  • build/: The directory Truffle creates when it compiles the project. It contains information on all of the contracts in the project including the compiled bytecode and the addresses of the deployed contracts.
  • contracts/: The smart contract code.
  • exec/simulated-users/: Scripts controlling the simulated gamblers playing the various games.
  • exec/examples: Example scripts that you can refer to when building your exploits
  • migrations/: scripts executed by truffle for deployment. They are executed in alphabetical order and can offer insights into how the contracts are initialized and how they fit together.

Contract Descriptions

All of the games in the GOATCasino use an ERC20-compliant token, which is defined in the CasinoToken.sol file. The CasinoToken makes use of some widely-used zeppelin contracts to implement much of the standard functionalities of a token. You can use the contract defined in CasinoExchange.sol to buy and sell CasinoTokens in exchange for ether.

The Faucet.sol file defines a contract which can be used once per user to get a free supply of CasinoTokens to try out the games.

The Vault.sol contract holds a reserve of funds for the owner to access. Equal portions of the vault's funds are protected by separate methods of access controls in order to better protect the funds if one method is found to be insufficient.

Finally, the only game in the casino at the moment is the lottery. Users can purchase tickets by number from 0 to 255. Each minute, a user can trigger the checkWin function to generate the winning ticket number, reward the winner with the prize money (mius the house's cut) and starts a new round by clearing the purchased tickets. If nobody purchased the winning ticket, then the round continues for another minute of purchasing before a new winning ticket can be chosen.

goatcasino's People

Contributors

semgrep-bot 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.