Skip to content

Instantly share code, notes, and snippets.

View pcaversaccio's full-sized avatar
💯
Percent Commitment

sudo rm -rf --no-preserve-root / pcaversaccio

💯
Percent Commitment
View GitHub Profile
@pcaversaccio
pcaversaccio / 0x732e9b5f59C9A442Db18F7D57Dd2BBFC804281CB.txt
Last active September 17, 2023 14:00
Decompiled contract 0x732e9b5f59C9A442Db18F7D57Dd2BBFC804281CB. I used the Dedaub Decompiler (https://library.dedaub.com/decompile).
// Decompiled by library.dedaub.com
// 2022.11.28 11:00 UTC
// Data structures and variables inferred from the use of storage instructions
uint256 owner_0_0_19; // STORAGE[0x0] bytes 0 to 19
uint256 owner_1_0_19; // STORAGE[0x1] bytes 0 to 19
function () public payable {
revert();
@pcaversaccio
pcaversaccio / ReturnBombExample.sol
Last active November 28, 2023 19:13
This is a returnbomb attack example.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
/**
* @title Returnbomb attack example
* @author pcaversaccio
*/
contract Evil {
uint256 public counter;
@pcaversaccio
pcaversaccio / Storage.sol
Created September 29, 2022 14:34
Struct writing (memory vs. storage) comparison.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
contract Storage {
struct SomeStruct {
uint16 a;
uint16 b;
uint16 c;
uint16 d;
}
@pcaversaccio
pcaversaccio / 4e2b890ab80095ee8fe286920b86039c.json
Last active September 27, 2022 19:29
Hardhat build artifact for BatchDistributor.
{"id":"4e2b890ab80095ee8fe286920b86039c","_format":"hh-sol-build-info-1","solcVersion":"0.8.17","solcLongVersion":"0.8.17+commit.8df45f5f","input":{"language":"Solidity","sources":{"contracts/BatchDistributor.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/**\n * @dev Error that occurs when transferring ether has failed.\n * @param emitter The contract that emits the error.\n */\nerror EtherTransferFail(address emitter);\n\n/**\n * @title Native and ERC-20 Token Batch Distributor\n * @author Apps with love AG, info@appswithlove.com\n * @notice Helper smart contract for batch sending both\n * native and ERC-20 tokens.\n * @dev Since we use nested struct objects, we rely on the ABI coder v2.\n * The ABI coder v2 is activated by default since Solidity `v0.8.0`.\n * @custom:security-contact info@appswithlove.com\n */\n\ncontract BatchDistributor {\n us
@pcaversaccio
pcaversaccio / DoubleOrNothing.sol
Last active September 30, 2022 23:45
DoubleOrNothing: Send ETH to the contract and either get double back (if the randomness beacon + a pre-committed nonce is even) or lose the bet (if the randomness beacon + a pre-committed nonce is odd). The assumption is that the contract is sufficiently funded by enough lost bets!
// SPDX-License-Identifier: WTFPL
pragma solidity 0.8.17;
/**
* @dev Error that occurs when called by a contract account.
* @param emitter The contract that emits the error.
*/
error ContractCallsAreNotAllowed(address emitter);
/**
@pcaversaccio
pcaversaccio / ERC20Mock.sol
Last active June 12, 2022 17:28
An ERC20 mock contract that is deployed directly with Solidity using the `Create2Deployer`.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Mock class using ERC20
contract ERC20Mock is ERC20 {
constructor(
string memory name,
string memory symbol,
@pcaversaccio
pcaversaccio / Merge.sol
Last active September 13, 2022 19:19
This smart contract determines whether "The Merge" has already taken place or not.
// SPDX-License-Identifier: WTFPL
pragma solidity 0.8.16;
contract Merge {
uint72 private constant _DIFFICULTY_THRESHOLD = 2**64;
/**
* @dev A difficulty value greater than `2**64` indicates that a transaction is
* being executed in a PoS block. Also note that the `DIFFICULTY` opcode (0x44)
@pcaversaccio
pcaversaccio / LookupContract.sol
Last active May 30, 2022 11:58
How to deploy a smart contract on Hedera using Hardhat.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract LookupContract {
mapping(string => uint256) public myDirectory;
constructor(string memory _name, uint256 _mobileNumber) {
myDirectory[_name] = _mobileNumber;
}
@pcaversaccio
pcaversaccio / decompiled_deus_finance_dao_attack_contract.txt
Created April 28, 2022 10:05
Decompiled DEUS Finance DAO attack contract 0x1f56CCfE85Dc55558603230D013E9F9BfE8E086C. I used the Panoramix decompiler.
# Palkeoramix decompiler.
def storage:
ownerAddress is addr at storage 0
stor1 is addr at storage 1
stor2 is addr at storage 2
stor3 is addr at storage 3
stor4 is addr at storage 4
stor5 is addr at storage 5
stor6 is addr at storage 6
@pcaversaccio
pcaversaccio / decompiled_beanstalk_flash_loan_contract.txt
Last active April 22, 2022 11:40
Decompiled Beanstalk flash loan exploit contract 0x79224bC0bf70EC34F0ef56ed8251619499a59dEf. I used the Panoramix decompiler.
# I failed with these:
# - unknownfa461e33(?)
# All the rest is below.
#
def execute(address _target, bytes _data): # not payable
require calldata.size - 4 >=′ 64
require _target == _target
require _data <= 18446744073709551615
require _data + 35 <′ calldata.size