Skip to content

Instantly share code, notes, and snippets.

@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 {}
@cassc
cassc / bsc_contracts_blances_txs.json
Created May 20, 2023 00:57
bsc address with balances and txns
This file has been truncated, but you can view the full file.
{
"0xe852abf44a5125852dde5df5712498aa99da20e7_BabySHIK": {
"num_txs": 20,
"balance": "0 BNB"
},
"0xaf37f0021c5380a8b4ab889a85ea7b1d373f6d81_Burninu": {
"num_txs": 1,
"balance": "0 BNB"
},
"0x7e3fbef6d223df71495cb071565ab3cea29f7d81_Hyco20": {
@cassc
cassc / solc-standard-input-multi-source-with-lib.json
Created May 10, 2023 02:47
Solc standard json input with multiple source files
{
"language": "Solidity",
"sources": {
"contracts/loans/direct/loanTypes/DirectLoanFixedOfferRedeploy.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1\n\npragma solidity 0.8.4;\n\nimport \"./DirectLoanFixedOffer.sol\";\n\n/**\n * @title DirectLoanFixedOfferRedeploy\n * @author NFTfi\n * @notice Same as DirectLoanFixedOffer, we have to duplicate it because we have to re-deploy,\n * but we need the old and the new simultaneously in the coordinator\n *\n *\n * Main contract for NFTfi Direct Loans Fixed Type. This contract manages the ability to create NFT-backed\n * peer-to-peer loans of type Fixed (agreed to be a fixed-repayment loan) where the borrower pays the\n * maximumRepaymentAmount regardless of whether they repay early or not.\n *\n * There are two ways to commence an NFT-backed loan:\n *\n * a. The borrower accepts a lender's offer by calling `acceptOffer`.\n * 1. the borrower calls nftContract.approveAll(NFTfi), approving the NFTfi contract to move their NFT's on their\n * be1
@cassc
cassc / etherscan-contract-with-libs.json
Created May 3, 2023 08:06
Contract from etherscan with libraries
{
"SourceCode": "{{\r\n \"language\": \"Solidity\",\r\n \"sources\": {\r\n \"contracts/loans/direct/loanTypes/DirectLoanFixedOfferRedeploy.sol\": {\r\n \"content\": \"// SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity 0.8.4;\\n\\nimport \\\"./DirectLoanFixedOffer.sol\\\";\\n\\n/**\\n * @title DirectLoanFixedOfferRedeploy\\n * @author NFTfi\\n * @notice Same as DirectLoanFixedOffer, we have to duplicate it because we have to re-deploy,\\n * but we need the old and the new simultaneously in the coordinator\\n *\\n *\\n * Main contract for NFTfi Direct Loans Fixed Type. This contract manages the ability to create NFT-backed\\n * peer-to-peer loans of type Fixed (agreed to be a fixed-repayment loan) where the borrower pays the\\n * maximumRepaymentAmount regardless of whether they repay early or not.\\n *\\n * There are two ways to commence an NFT-backed loan:\\n *\\n * a. The borrower accepts a lender's offer by calling `acceptOffer`.\\n * 1. the borrower calls nftContract.approveAll(NFTfi)