Code Monkey home page Code Monkey logo

damn-vulnerable-defi-foundry's Introduction

Damn Vulnerable DeFi - Foundry Version ⚒️

Open in Gitpod

Github Actions Telegram Support

Twitter Follow

Visit damnvulnerabledefi.xyz

Acknowledgement

Big thanks to Tincho who created the first version of this game and to all the fellows behind the Foundry Framework

Damn Vulnerable DeFi is the wargame to learn offensive security of DeFi smart contracts.

Throughout numerous challenges you will build the skills to become a bug hunter or security auditor in the space. 🕵️‍♂️

How To Play 🕹️

  1. Install Foundry

First run the command below to get foundryup, the Foundry toolchain installer:

curl -L https://foundry.paradigm.xyz | bash

Then, in a new terminal session or after reloading your PATH, run it to get the latest forge and cast binaries:

foundryup
  1. Clone This Repo and install dependencies
git clone https://github.com/nicolasgarcia214/damn-vulnerable-defi-foundry.git
cd damn-vulnerable-defi-foundry
forge install
  1. Code your solutions in the provided [NAME_OF_THE_LEVEL].t.sol files (inside each level's folder in the test folder)
  2. Run your exploit for a challenge
make [CONTRACT_LEVEL_NAME]

or

./run.sh [LEVEL_FOLDER_NAME]
./run.sh [CHALLENGE_NUMBER]
./run.sh [4_FIRST_LETTER_OF_NAME] 

If the challenge is executed successfully, you've passed!🙌🙌

Tips and tricks ✨

  • In all challenges you must use the account called attacker. In Forge, you can use the cheat code prank or startPrank.
  • To code the solutions, you may need to refer to the Foundry Book.
  • In some cases, you may need to code and deploy custom smart contracts.

Preinstalled dependencies

ds-test for testing, forge-std for better cheatcode UX, and openzeppelin-contracts for contract implementations.

damn-vulnerable-defi-foundry's People

Contributors

0xmp avatar 0xvv avatar devnet0x avatar jeffchen006 avatar joleeee avatar lmanini avatar nicolasgarcia214 avatar perelyn-sama avatar principursa avatar teawaterwire avatar vielite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

damn-vulnerable-defi-foundry's Issues

SideEntrance Test setUp assert fails

function setUp() public {
utils = new Utilities();
address payable[] memory users = utils.createUsers(1);
attacker = users[0];
vm.label(attacker, "Attacker");
sideEntranceLenderPool = new SideEntranceLenderPool();
vm.label(address(sideEntranceLenderPool), "Side Entrance Lender Pool");
vm.deal(address(sideEntranceLenderPool), ETHER_IN_POOL);
assertEq(address(sideEntranceLenderPool).balance, ETHER_IN_POOL);
attackerInitialEthBalance = address(attacker).balance;
assertEq(attackerInitialEthBalance, 0);

The setUp function ends with an assert check that the attacker's address holds 0 Ether. This assert fails because when a new user account is created from Utilities (attacker in this case) 100 eth is automatically dealt to that account.

[Spoilers] Unable to sign transaction with other private key

I'm on compromised, and I've found some private keys, but I'm not sure it's possible to sign and "broadcast" transaction inside solidity

Is the intended solution to just vm.prankStart() with the public address? so vm.prankStart(vm.addr(privkey))

testAfter -> after and testFailAfter -> FailAfter

In testFailExploit

In looks like testFailExploit is a test that is meant to file. And testFailAfter is meant to be a helper that is not actually run. However because it starts with the word test it is automatically run as a test. Is this right?

If so I propose renaming the after functions so that they are not run as standalone tests.

Error when running Puppet tests

What version of Foundry are you on?

forge 0.2.0 (9e3ab9b 2024-01-04T00:18:01.892563000Z)

Describe the bug

For the first Puppet I get this error:

Encountered 1 failing test in test/Levels/puppet/Puppet.t.sol:Puppet
[FAIL. Reason: setup failed: missing field `stateMutability` at line 34 column 8] setUp() (gas: 0)

For Puppet V2 there is the following error:

Encountered 1 failing test in test/Levels/puppet-v2/PuppetV2.t.sol:PuppetV2
[FAIL. Reason: setup failed: duplicate field `bytecode` at line 403 column 14] setUp() (gas: 0)

Why could this happen and what to do?

It seems to be an error deploying uniswapv2

What version of Foundry are you on?

forge 0.2.0 (82a74a6 2022-10-01T00:10:04.763218971Z)

Describe the bug

This is what im seeing

[⠢] Compiling...
No files changed, compilation skipped
2022-10-01T03:25:19.025715Z ERROR forge::runner: setUp failed reason="data did not match any variant of untagged enum ArtifactBytecode" contract=0xb4c79dab8f259c7aee6e5b2aa729821864227e84

Running 1 test for test/Levels/free-rider/FreeRider.t.sol:FreeRider
[FAIL. Reason: Setup failed: data did not match any variant of untagged enum ArtifactBytecode] setUp() (gas: 0)
Test result: FAILED. 0 passed; 1 failed; finished in 1.32ms

Failing tests:
Encountered 1 failing test in test/Levels/free-rider/FreeRider.t.sol:FreeRider
[FAIL. Reason: Setup failed: data did not match any variant of untagged enum ArtifactBytecode] setUp() (gas: 0)

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.