Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working from home

Zaryab zaryab2000

🏡
Working from home
View GitHub Profile
View AttackContract.sol
pragma solidity ^0.6.0;
//import "@openzeppelin/contracts/utils/Address.sol";
interface ISideEntranceLenderPool {
function deposit() external payable;
function withdraw() external;
function flashLoan(uint256 amount) external ;
}
View sideEntranceLenderPool.sol
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/utils/Address.sol";
interface IFlashLoanEtherReceiver {
function execute() external payable;
}
contract SideEntranceLenderPool {
using Address for address payable;
View puppet.challenge.js
after(async function () {
/** SUCCESS CONDITIONS */
// // Attacker has stolen all tokens from the pool
expect(
await this.token.balanceOf(attacker)
).to.be.bignumber.gte(POOL_INITIAL_TOKEN_BALANCE);
expect(
View selfie.challenge.js
after(async function () {
/** SUCCESS CONDITIONS */
expect(
await this.token.balanceOf(attacker)
).to.be.bignumber.equal(TOKENS_IN_POOL);
expect(
await this.token.balanceOf(this.pool.address)
).to.be.bignumber.equal('0');
});
View AttackContract.sol
pragma solidity ^0.6.0;
import "./SimpleGovernance.sol";
import "./SelfiePool.sol";
import "../DamnValuableTokenSnapshot.sol";
contract AttackerContract{
address public attackerAddress;
SelfiePool public selfiePool;
View truster.challenge.js
const { ether } = require('@openzeppelin/test-helpers');
const { accounts, contract } = require('@openzeppelin/test-environment');
const DamnValuableToken = contract.fromArtifact('DamnValuableToken');
const TrusterLenderPool = contract.fromArtifact('TrusterLenderPool');
const AttackContract = contract.fromArtifact('AttackerContract');
var Web3 = require("web3");
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
View AttackContract.sol
pragma solidity ^0.6.0;
import "./TrusterLenderPool.sol";
contract AttackerContract{
uint256 public totalTokens = 1000000 ether;
address public attackerAddress;
// DamnValuableToken public dvTokenContract;
address public dvTokenContract;
TrusterLenderPool public poolContract;
View TrusterLenderPool.sol
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract TrusterLenderPool is ReentrancyGuard {
IERC20 public damnValuableToken;
constructor (address tokenAddress) public {
View flashLoan function
function flashLoan(
uint256 borrowAmount,
address borrower,
address target,
bytes calldata data
)
external
nonReentrant
{
View AttackContract.sol
pragma solidity ^0.6.0;
contract AttackContract {
address payable pool;
address payable target;
constructor(address payable poolAddress,address payable targetAddress) public {
pool = poolAddress;
target = targetAddress;
}