forked from OpenZeppelin/damn-vulnerable-defi
-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
207d65b
commit 8eb38ef
Showing
151 changed files
with
15,727 additions
and
5,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Base debian build (latest). | ||
FROM mcr.microsoft.com/vscode/devcontainers/base:debian | ||
|
||
# Update packages. | ||
RUN apt-get update | ||
|
||
# Install pipx | ||
RUN apt-get install -y pipx | ||
|
||
# Set the default shell to zsh | ||
ENV SHELL=/usr/bin/zsh | ||
|
||
# Running everything under zsh | ||
SHELL ["/usr/bin/zsh", "-c"] | ||
|
||
# Dropping privileges | ||
USER vscode | ||
|
||
# Install rust | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && source $HOME/.cargo/env | ||
|
||
# Install nvm, yarn, npm, pnpm | ||
RUN curl -o- https://raw.githubusercontent.com/devcontainers/features/main/src/node/install.sh | sudo bash | ||
|
||
# Install solc-select | ||
RUN pipx install solc-select | ||
|
||
# Foundry at specific version | ||
RUN curl -L https://foundry.paradigm.xyz | zsh | ||
RUN foundryup --version nightly-cafc2606a2187a42b236df4aa65f4e8cdfcea970 | ||
|
||
# Clean up | ||
RUN sudo apt-get autoremove -y && sudo apt-get clean -y | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "Damn Vulnerable DeFi Devcontainer", | ||
|
||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"features": { | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"NomicFoundation.hardhat-solidity", | ||
"tintinweb.solidity-visual-auditor" | ||
], | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "zsh", | ||
"terminal.integrated.profiles.linux": { "zsh": { "path": "/usr/bin/zsh" } } | ||
} | ||
} | ||
}, | ||
|
||
"postCreateCommand": "zsh" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MAINNET_FORKING_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
node_modules | ||
build | ||
contracts/player-contracts/*.sol | ||
*.solved.js | ||
*.solved.json | ||
cache | ||
.openzeppelin | ||
.vscode | ||
artifacts | ||
cache | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
ignore = dirty | ||
[submodule "lib/openzeppelin-contracts"] | ||
path = lib/openzeppelin-contracts | ||
url = https://github.com/openzeppelin/openzeppelin-contracts | ||
ignore = dirty | ||
[submodule "lib/solmate"] | ||
path = lib/solmate | ||
url = https://github.com/transmissions11/solmate | ||
ignore = dirty | ||
[submodule "lib/solady"] | ||
path = lib/solady | ||
url = https://github.com/vectorized/solady | ||
ignore = dirty | ||
[submodule "lib/openzeppelin-contracts-upgradeable"] | ||
path = lib/openzeppelin-contracts-upgradeable | ||
url = https://github.com/openzeppelin/openzeppelin-contracts-upgradeable | ||
ignore = dirty | ||
[submodule "lib/v2-periphery"] | ||
path = lib/v2-periphery | ||
url = https://github.com/uniswap/v2-periphery | ||
ignore = dirty | ||
[submodule "lib/v2-core"] | ||
path = lib/v2-core | ||
url = https://github.com/uniswap/v2-core | ||
ignore = dirty | ||
[submodule "lib/multicall"] | ||
path = lib/multicall | ||
url = https://github.com/mds1/multicall | ||
ignore = dirty | ||
[submodule "lib/safe-smart-account"] | ||
path = lib/safe-smart-account | ||
url = https://github.com/safe-global/safe-smart-account | ||
ignore = dirty | ||
[submodule "lib/murky"] | ||
path = lib/murky | ||
url = https://github.com/dmfxyz/murky | ||
ignore = dirty | ||
[submodule "lib/v3-periphery"] | ||
path = lib/v3-periphery | ||
url = https://github.com/Uniswap/v3-periphery | ||
[submodule "lib/v3-core"] | ||
path = lib/v3-core | ||
url = https://github.com/Uniswap/v3-core | ||
ignore = dirty | ||
[submodule "lib/permit2"] | ||
path = lib/permit2 | ||
url = https://github.com/Uniswap/permit2 | ||
ignore = dirty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,56 @@ | ||
 | ||
# Damn Vulnerable DeFi | ||
|
||
**A set of challenges to learn offensive security of smart contracts in Ethereum.** | ||
Damn Vulnerable DeFi is _the_ smart contract security playground for developers, security researchers and educators. | ||
|
||
Featuring flash loans, price oracles, governance, NFTs, lending pools, smart contract wallets, timelocks, and more! | ||
Perhaps the most sophisticated vulnerable set of Solidity smart contracts ever witnessed, it features flashloans, price oracles, governance, NFTs, DEXs, lending pools, smart contract wallets, timelocks, vaults, meta-transactions, token distributions, upgradeability and more. | ||
|
||
## Play | ||
Use Damn Vulnerable DeFi to: | ||
|
||
Visit [damnvulnerabledefi.xyz](https://damnvulnerabledefi.xyz) | ||
- Sharpen your auditing and bug-hunting skills. | ||
- Learn how to detect, test and fix flaws in realistic scenarios to become a security-minded developer. | ||
- Benchmark smart contract security tooling. | ||
- Create educational content on smart contract security with articles, tutorials, talks, courses, workshops, trainings, CTFs, etc. | ||
|
||
## Help | ||
## Install | ||
|
||
For Q&A and troubleshooting running Damn Vulnerable DeFi, go [here](https://github.com/tinchoabbate/damn-vulnerable-defi/discussions/categories/support-q-a-troubleshooting). | ||
1. Clone the repository. | ||
2. Checkout the latest release (for example, `git checkout v4.0.0`) | ||
3. Rename the `.env.sample` file to `.env` and add a valid RPC URL. This is only needed for the challenges that fork mainnet state. | ||
4. Either install [Foundry](https://book.getfoundry.sh/getting-started/installation), or use the [provided devcontainer](./.devcontainer/) (In VSCode, open the repository as a devcontainer with the command "Devcontainer: Open Folder in Container...") | ||
5. Run `forge build` to initialize the project. | ||
|
||
## Usage | ||
|
||
Each challenge is made up of: | ||
|
||
- A prompt located in `src/<challenge-name>/README.md`. | ||
- A set of contracts located in `src/<challenge-name>/`. | ||
- A [Foundry test](https://book.getfoundry.sh/forge/tests) located in `test/<challenge-name>/<ChallengeName>.t.sol`. | ||
|
||
To solve a challenge: | ||
|
||
1. Read the challenge's prompt. | ||
2. Uncover the flaw(s) in the challenge's smart contracts. | ||
3. Code your solution in the corresponding test file. | ||
4. Try your solution with `forge test --mp test/<challenge-name>/<ChallengeName>.t.sol`. | ||
If the test passes, you've solved the challenge! | ||
|
||
Challenges may have more than one possible solution. | ||
|
||
### Rules | ||
|
||
- You must always use the `player` account. | ||
- You must not modify the challenges' initial nor final conditions. | ||
- You can code and deploy your own smart contracts. | ||
- You can use Foundry's cheatcodes to advance time when necessary. | ||
- You can import external libraries that aren't installed, although it shouldn't be necessary. | ||
|
||
## Troubleshooting | ||
|
||
You can ask the community for help in [the discussions section](https://github.com/theredguild/damn-vulnerable-defi/discussions). | ||
|
||
## Disclaimer | ||
|
||
All Solidity code, practices and patterns in this repository are DAMN VULNERABLE and for educational purposes only. | ||
All code, practices and patterns in this repository are DAMN VULNERABLE and for educational purposes only. | ||
|
||
DO NOT USE IN PRODUCTION. |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.