Skip to content

Instantly share code, notes, and snippets.

@cassc
cassc / Preservation.t.sol
Created April 11, 2024 08:59
Preservation Attacker
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
contract Preservation {
// public library contracts
address public timeZone1Library;
address public timeZone2Library;
address public owner;
@cassc
cassc / NaughtCoinTest.sol
Created April 11, 2024 08:55
NaughtCoinTest
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
interface NaughtCoin{
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
@cassc
cassc / GatekeeperTwoAttacker.sol
Created April 11, 2024 08:47
GatekeeperTwo attacker
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
contract GatekeeperTwo {
address public entrant;
modifier gateOne() {
require(msg.sender != tx.origin);
@cassc
cassc / GatekeeperOneAttacker.sol
Created April 11, 2024 08:42
GatekeeperOneAttacker.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
contract GatekeeperOne {
address public entrant;
modifier gateOne() {
require(msg.sender != tx.origin);
@cassc
cassc / rekt.news.bugs.md
Created October 6, 2023 04:14
rekt.news bugs summary by chatgpt3.5

11-rekt

  • Contract names: Eleven.finance, Nerve Finance, NRV vault, Eleven "MasterMind" farming contract
  • Contract hex addresses: Not mentioned in the article
  • Bug types mentioned in the article:
    1. Vulnerable function (emergencyBurn()) in the intermediate vault contract
    2. Flashloan exploit
    3. Logic issue
    4. Unauthorized withdrawal
@cassc
cassc / standard-input.json
Created September 26, 2023 02:36
Comilation standard json input with remapping
{
"sources": {
"Filename.sol": {
"content": "import \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\npragma solidity >=0.7 <0.9.0;\n\n/**\n * @title Storage\n * @dev Store & retrieve value in a variable\n * @custom:dev-run-script ./scripts/deploy_with_ethers.ts\n */\ncontract Storage {\n\n uint256 number;\n\n /**\n * @dev Store value in variable\n * @param num value to store\n */\n function store(uint256 num) public {\n number = num;\n }\n\n /**\n * @dev Return value \n * @return value of 'number'\n */\n function retrieve() public view returns (uint256){\n return number;\n }\n}"
}
},
"language": "Solidity",
"settings": {
"remappings": ["@openzeppelin=node_modules/@openzeppelin/", "@asldfas=none-exists"]
}
@cassc
cassc / xyk.py
Created August 21, 2023 02:20
Python plot x*y=k
import numpy as np
import matplotlib.pyplot as plt
# Define the function y = k/x
def f(x, k=100):
return k / x
# Generate x values
x = np.linspace(0.1, 10, 400) # Start from 0.1 to avoid division by zero
y = f(x)
@cassc
cassc / info.md
Created August 4, 2023 02:41
A collection of ChatGPT answers

The repository you've provided is for a project called Foundry, which is a fast, portable, and modular toolkit for Ethereum application development written in Rust. Here's a general guide on how to read the source code of a Rust project like this one:

  1. Understand the Project Structure: Rust projects usually have a specific structure. The main code is typically in the src directory. In this case, the project seems to be divided into multiple modules such as forge, cast, anvil, chisel, etc. Each of these directories represents a different component of the Foundry toolkit.

  2. Start with main.rs or lib.rs: In a Rust project, the entry point is usually a file named main.rs or lib.rs. In this case, each module might have its own entry point. Look for these files to understand how the program starts.

  3. Read the README and Documentation: The README.md file and other documentation can provide a high-level overview of the project. Foundry's README gives a brief description of what ea

@cassc
cassc / yab.reverts.sol
Created July 26, 2023 08:37
various reverts in solidity
pragma solidity ^0.8.0;
import "hardhat/console.sol";
contract A {
function willRevert() public pure {
revert("This is an error message");
}
function willAssert() public pure {
@cassc
cassc / github-clone-by-user.py
Created July 18, 2023 02:38
Clone all github repos
# python github-clone-by-user.py username --skip-forks --excluded project1 project2
import requests
import subprocess
import argparse
import os
def clone_or_fetch_repo(username, token, skip_forks):
headers = {'Authorization': f'token {token}'} if token else {}