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
const { ether, expectRevert } = require('@openzeppelin/test-helpers');
const { accounts, contract } = require('@openzeppelin/test-environment');
const DamnValuableToken = contract.fromArtifact('DamnValuableToken');
const UnstoppableLender = contract.fromArtifact('UnstoppableLender');
const ReceiverContract = contract.fromArtifact('ReceiverUnstoppable');
const { expect } = require('chai');
describe('[Challenge] Unstoppable', function () {
contract UnstoppableLender is ReentrancyGuard {
using SafeMath for uint256;
IERC20 public damnValuableToken;
uint256 public poolBalance;
constructor(address tokenAddress) public {
require(tokenAddress != address(0), "Token address cannot be zero");
damnValuableToken = IERC20(tokenAddress);
}
const { ether, balance } = require('@openzeppelin/test-helpers');
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const LenderPool = contract.fromArtifact('NaiveReceiverLenderPool');
const FlashLoanReceiver = contract.fromArtifact('FlashLoanReceiver');
const myAttackContract = contract.fromArtifact('AttackContract');
const { expect } = require('chai');
describe('[Challenge] Naive receiver', function () {
const { ether, balance } = require('@openzeppelin/test-helpers');
const { accounts, contract } = require('@openzeppelin/test-environment');
const SideEntranceLenderPool = contract.fromArtifact('SideEntranceLenderPool');
const SideEntranceAttacker = contract.fromArtifact('SideEntranceAttacker');
const { expect } = require('chai');
describe('[Challenge] Side entrance', function () {
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;
}
function flashLoan(
uint256 borrowAmount,
address borrower,
address target,
bytes calldata data
)
external
nonReentrant
{
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 {
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;
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 "./SimpleGovernance.sol";
import "./SelfiePool.sol";
import "../DamnValuableTokenSnapshot.sol";
contract AttackerContract{
address public attackerAddress;
SelfiePool public selfiePool;