Skip to content

Instantly share code, notes, and snippets.

@owenThurm
owenThurm / UUPSImplementation.sol
Last active January 6, 2024 17:37
UUPS Implementation
pragma solidity 0.8.19;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
contract UUPSImpl is Initializable, OwnableUpgradeable, UUPSUpgradeable {
constructor() {
@owenThurm
owenThurm / IsItVulnerable.sol
Created July 28, 2023 19:42
Solidity Vulnerability
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.0;
contract IsItVulnerable {
bytes public currentCode;
function setReferralCode(
string memory code,
@owenThurm
owenThurm / contracts...Reentrancy...CrossContractReentrancy.sol
Created May 31, 2023 01:13
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// this line is added to create a gist. Empty file is not allowed.
@owenThurm
owenThurm / DecodeCreateOrderParams.sol
Created May 30, 2023 15:14
Decode CreateOrderParams
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../src/exchange/DepositHandler.sol";
import "../src/exchange/WithdrawalHandler.sol";
@owenThurm
owenThurm / Rewarder.sol
Created May 27, 2023 14:53
Yul Exploit
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.19;
import "hardhat/console.sol";
import "./ERC20/IERC20.sol";
import "./ERC20/ERC20.sol";
import "hardhat/console.sol";
// user 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4
@owenThurm
owenThurm / PracticeExam1Q1.sol
Last active March 6, 2023 16:36
Practice Exam 1
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
// Allows user to swap deposited token for another
contract SwapProtocol {
// token address -> user address balance
mapping(address => mapping(address => uint256)) balances;
// ...
@owenThurm
owenThurm / GasGrief.sol
Created January 24, 2023 03:41
63/64 Gas Exploit Scenario
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
interface ICallback {
function beforeExecution() external;
}
/** Exploit Desc: **/
// The GasGriefer is used as a `callbackContract` on a swapOrder
@owenThurm
owenThurm / tagging.py
Created August 25, 2021 16:14
Email and SMS library tagging
from app.models.library import LibraryItem, LibraryTag, LibraryTagCategory, TaggedLibraryItem
flow_type = 0
# Grab channel category
channel_category = LibraryTagCategory.objects.get(library_type=flow_type, name="Channel")
# Make new Email and SMS Tag
@owenThurm
owenThurm / orderedandviewed.py
Last active July 14, 2021 18:59
Ordered and Viewed Product custom events csv
from app.services.events import EventLogService
from app.services.plans import AVAILABLE_PLANS
from app.models import Company, CompanyStatistic
from collections import namedtuple
import csv
event_service = EventLogService()
custom_stats = []
viewed_and_ordered_stats = []
high_plans = []
@owenThurm
owenThurm / gist:6caa845028f9944ede9bbb12f9eef426
Last active July 14, 2021 17:04
Large customer custom started checkout data csv snippet
from app.services.events import EventLogService
from app.services.plans import AVAILABLE_PLANS
from app.models import Company, CompanyStatistic
from collections import namedtuple
event_service = EventLogService()
custom_stats = []
started_checkout_stats = []
high_plans = []
rows = []