Introduction
- It's time for some hands-on experience! In this lab, you'll leverage your Reentrancy knowledge to steal funds from the
Vulnerable Contract. Within the lab environment, you'll update the
Attacker
Contract (i.e.,Attacker.sol
) to exploit a Reentrancy vulnerability within theVulnerable
Contract (i.e.,Vulnerable.sol
). - As explained in the Lab Workflow section, the Challenge Verification Engine will verify your solution.
- For you to pass the lab, you must complete the Lab Challenges.
Prerequisites
Lab Sample
Click on the image to zoom in
Lab Challenges
- Attacker.sol should be able to steal all ETH from Vulnerable.sol
- Attacker.sol should not cause a revert operation
Lab Workflow
- Use the Lab Options section to start the lab.
- Optional: If you previously worked in the lab, you'll need to: i) close any open tabs; ii) navigate to the lab's terminal and execute
revert
. - Review the
Vulnerable.sol
andAttacker.sol
contracts. While doing the review, start to think about how you can updateAttacker.sol
to solve the Lab Challenges. - Add your exploit code to
Attacker.sol
.Warning:Within
Attacker.sol
, please make your changes between the following code comments:// COMMENT GROUP A: START
// COMMENT GROUP A: END
- When you're ready to verify your solution, go to the lab environment's terminal and execute the
cv
command. (This is short for Challenges Verify.) - Behind the scenes, the
cv
command invokesAttacker.attack()
. cv
prints a call stack and verifies that the Lab Challenges have been completed.
Lab Options
Pros
- Access the lab directly through your web browser.
- There are no dependencies to install.
Cons
- Executes on GitHub's servers. This has a financial cost if the free tier is exhausted. Luckily, it's easy to set a spending limit of
0
so you won't be charged (instructions below).
Prerequisites
- Sign up for a Github account.
- IMPORTANT: Github will charge for Codespace usage once the free tier is exhausted. If you don't want to be charged, navigate to this link and ensure the Codespaces spending limit is set to
0
. Blockbash (and its contributors) are not responsible for any unexpected charges.
You must complete the Prerequisites (mentioned above) before starting the lab.
Next Steps
- Complete the steps within the Lab Workflow section.
If you have a question (or problem), please review the Need Help section.
Pros
- If you're already a Visual Studio Code user, your preexisting setup should be applied. This includes keybindings, extensions, etc.
- As the lab isn't being executed within the browser, you'll have a more "native" experience.
- Depending on your computer, the experience might be faster than the Codespace environment.
Cons
- Requires dependencies to be installed (see below).
Prerequisites
- Install Visual Studio Code.
- Install the Dev Containers Extension.
- Install Docker (other container runtimes are not officially supported).
You must complete the Prerequisites (mentioned above) before starting the lab.
Next Steps
- Complete the steps within the Lab Workflow section.
If you have a question (or problem), please review the Need Help section.
Need Help?
- Review the hints within the Lab Challenges section.
- If the hints don't help, leverage this link for further assistance.