Skip to content

Kiinzu/foundry-casino-heist

Repository files navigation

Foundry Casino Heist

Logo

A Collection of Casino Heist's Challenges written in Foundry- Perfect for those who doesn't want to deploy anything and want to exercise their Test Writting skill in Foundry.

You can find the reading material in our website at Casino Heist.

Requirement

What you need to prepare:

  1. Foundry
  2. Snacks 🍫🍪

Mini-Guide

This is the directory and its usage.

  • /src - all vulnerable contracts here.
  • /test - all test files
  • /reading-mats/docs - all vulnerabilities Explanation (Archived Version from CasinoHeist.v0)
  • /reading-mats/Mithrough - all Mitigations & Walkthroughs (Archived Version from CasinoHeist.v0)

How to Play

  1. Clone the Repository
$ git clone https://github.com/Kiinzu/foundry-casino-heist.git
$ cd /foundry-casino-heist
$ forge install foundry-rs/forge-std \
    OpenZeppelin/openzeppelin-contracts \
    OpenZeppelin/openzeppelin-contracts-upgradeable
  1. You will find the Challenge in the /src accordingly to their Category.

    • Basic (Introductory)
    • Common (Common Vulnerabilities)
    • Advance (Advance?)
    • VIP (Easier Stuff, trust me)
  2. You will find all the test in one folder /test (Basic, Common, VIP in one place).

  3. Some might require you to write Exploit Contract, some you can just edit the Test Directly. There will be // Write Exploit Here, that's the only place you should edit and some may include vm.warp(), you might also want to change this if you think you need it.

// Example: test/MasterOfBlackjack.t.sol
    function testIfSolved() public {
        // Setup for Player
        vm.startPrank(player, player);
        vm.deal(player, 1 ether);

        // Write Exploit here
        vm.warp(19); // Feel free to change this to any block.timestamp that satisfy the requirement

        vm.stopPrank();
        assertEq(challSetup.isSolved(), true);
    }

⚠️ - Do Not Change the Setup for player!

  1. To Test if the challenge is solved, simply run make, see Make List for more information
# Example of Foundry Test Challenge
# Example for vip_bank-of-people (Test)
$ make vip_bank-of-people

# Example of Deployed Challenge (Anvil)
# Example for deploy_basic_briefing
# Deploying Briefing in Local Anvil, will return credential for player
$ make deploy_basic_briefing 
> == Logs ==
  ========== DEPLOYING SETUP ==========
  Setup deployed at: 0x5FbDB2315678afecb367f032d93F642f64180aa3
  ====================================
  
  ========== PLAYER SETUP ==========
  Player Address    :  0x70997970C51812dc3A010C7d01b50e0d17dc79C8
  Player Private Key:  40606737760334725431406512677033654118342507952694270066784247067953537247501
  Player Balance    :  1 ether
  ====================================

$ make solve_basic_briefing
> == Logs ==
    ========== CHECKING SOLUTION ==========
    Setup at          :  0x5FbDB2315678afecb367f032d93F642f64180aa3
    First Celebrator  :  0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
    Balance of Express:  0
    STATUS: NOT SOLVED
    ========================================
  [X] Challenge not solved yet
  [!] Destroying the Challenge Instance
  [!] Stopping Anvil...
  [o] Anvil stopped.  
  [!] Please create another instance by calling: 'make deploy_basic_briefing'
  1. That's it! You good to go.

Make List

Some challenges in Casino Heist are designed to be played on a deployed Anvil Instance using Foundry, while others can be solved in test mode or in their deployed form.

The table below litst the available modes for each challenge — deployed, test, or both — along with the recommended way to play each challenge.

///////////////////// Test Deployed Recommended
Briefing basic_briefing deploy_basic_briefing Deployed
Bulls Eye basic_bulls-eye - Test
Gearing Up basic_gearing-up deploy_basic_gearing-up Test
Isolated basic_isolated - Test
Peek A Slot basic_peek-a-slot - Test
After You - common_after-you Deployed
Bar common_bar - Test
Casino Vault common_casino-vault - Test
Cheap Glitch common_cheap-glitch - Test
Entry Point common_entry-point - Test
Gorengan common_gorengan - Test
Inju Bank common_inju-bank - Test
Master of Blackjack common_master-of-blackjack deploy_common_master-of-blackjack Deployed
Roulette common_roulette deploy_common_roulette Deployed
Silent Dealer common_silent-dealer - Test
Singular Identity common_singular-identity - Test
Symbol of Noble common_symbol-of-noble - Test
Take My Money common_take-my-money - Test
Unlimited Credit Line common_unlimited-credit-line - Test
Voting Frenzy common_voting-frenzy - Test
VVVIP Member common_vvvip-member - Test
Casino Bankbuster advance_casino-bankbuster - Test
Double Dipping advance_double-dipping - Test
False Hope advance_false-hope - Test
Guardian advance_guardian - Test
Salt and Steel - advance_salt-and-steel Deployed
The Waltz advance_the-waltz - Test
Bank of People vip_bank-of-people - Test
Executive Problems vip_executive-problems - Test
Inju's Gambit vip_inju-gambit - Test
IPWD vip_ipwd - Test
Pupol BFT vip_pupol-nft - Test

About

Casino Heist is a playground for learning Solidity Smart Contract Security

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors