Skip to content

Instantly share code, notes, and snippets.

View zaryab2000's full-sized avatar
💻
Deciphering Smart Contract Security

Zaryab zaryab2000

💻
Deciphering Smart Contract Security
View GitHub Profile
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 ;
}
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/utils/Address.sol";
interface IFlashLoanEtherReceiver {
function execute() external payable;
}
contract SideEntranceLenderPool {
using Address for address payable;
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(
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');
});
pragma solidity ^0.6.0;
import "./SimpleGovernance.sol";
import "./SelfiePool.sol";
import "../DamnValuableTokenSnapshot.sol";
contract AttackerContract{
address public attackerAddress;
SelfiePool public selfiePool;
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"));
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;
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 {
function flashLoan(
uint256 borrowAmount,
address borrower,
address target,
bytes calldata data
)
external
nonReentrant
{
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;
}