This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://twitter.com/0xYYY_/status/1562091599731228672 | |
# put this before `source $ZSH/oh-my-zsh.sh` | |
FOUNDRY_PLUGIN_DIR=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/foundry | |
fpath+=$FOUNDRY_PLUGIN_DIR | |
fup () { | |
if ! command -v foundryup &> /dev/null | |
then | |
echo "Install foundryup first: https://getfoundry.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from typing import Tuple | |
bytes32 = int | |
address = int | |
@dataclass | |
class Context: | |
context_address: address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from z3 import * | |
selector = BitVec('selector', 32) | |
expr = 107 + 4 * (selector % 16) | |
codesize = 128 | |
s = Solver() | |
s.add(expr < codesize) | |
possible_jump_table_values = set([]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define macro MAIN() = takes(0) returns(0) { | |
// sol.stop | |
__VERBATIM(0x01) | |
// sol.ctxSetting | |
__VERBATIM(0x00) | |
// store origin at memory location 0 | |
origin push0 mstore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reverse bytes received in calldata (abcd -> dcba) | |
// https://twitter.com/huff_language/status/1583894073487654913 | |
// code length 206 | |
/// @author Philippe Dumonet <[email protected]> -- https://twitter.com/real_philogy/status/1584304102418223104 | |
/// @author karma (@0xkarmacoma) -- https://twitter.com/0xkarmacoma/status/1584239664310779904 | |
/// @author kaden.eth (@0xKaden) -- https://twitter.com/0xKaden/status/1584280521089376256/ | |
#define macro reverse_word() = takes(1) returns(1) { | |
// [x0] | |
0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compiles to the following bin-runtime: 7f2a447b3991925d0aa0728f5e78315948d6cb14530bc6ae127f114971abe35db87f452f5b4ef4b2336fc516af2a17113e27f69f612162a8c9321c7e2401c78629dd18600052596000f3 | |
// (run with e.g. `evm --code <bin-runtime> run | cast --to-ascii`) | |
#define macro MAIN() = takes(0) returns(0) { | |
0x2a447b3991925d0aa0728f5e78315948d6cb14530bc6ae127f114971abe35db8 // ciphertext | |
0x452f5b4ef4b2336fc516af2a17113e27f69f612162a8c9321c7e2401c78629dd // key (which happens to be the keccak hash of the message) | |
xor | |
0x00 mstore | |
// returns 0x6F6B207765206E65656420746F20676F20547572696E6720636F6D706C657465 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.17; | |
import {Test} from "forge-std/Test.sol"; | |
import {stdJson} from "forge-std/StdJson.sol"; | |
import {console2} from "forge-std/console2.sol"; | |
contract TestJson is Test { | |
/// @dev fields need to be sorted alphabetically (see docs of vm.parseJson()) | |
struct ContractURISchema { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.15; | |
import {console2} from "forge-std/console2.sol"; | |
contract FizzBuzz { | |
modifier fizz(uint256 n) { | |
_; | |
if (n % 3 == 0 && n % 5 != 0) { | |
console2.log("Fizz"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# quine.etk | |
# ⬜ => ⬜ | |
# A quine is a computer program which takes no input and produces a copy of its own source code as its only output. | |
# 0x80...f3 is the compiled code excluding the push16 instruction (from dup1 to return) | |
push16 0x8060801b17606f5953600152602136f3 | |
# --- stack --- | |
dup1 # code code | |
push1 128 # 128 code code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
import time | |
from multiprocessing import Pool, Event | |
def init_pool_processes(the_shutdown_event): | |
''' | |
Initialize each process with the global shutdown event |
NewerOlder