Skip to content

Instantly share code, notes, and snippets.

@cassc
Created April 29, 2024 07:37
Show Gist options
  • Save cassc/70a8516ec1a54132f1969621ecbc7185 to your computer and use it in GitHub Desktop.
Save cassc/70a8516ec1a54132f1969621ecbc7185 to your computer and use it in GitHub Desktop.
sample standard json input with only one input
{
"language": "Solidity",
"settings": {
"optimizer": {
"enabled": false
},
"outputSelection": {
"*": {
"": [
"ast"
],
"*": [
"*"
]
}
}
},
"sources": {
"Filename.sol": {
"content": "\n// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\npragma experimental ABIEncoderV2;\n\ncontract Test {\n struct Sig { uint8 v; bytes32 r; bytes32 s;}\n\n function claim(bytes32 _msg, Sig memory sig) public {\n address signer = ecrecover(_msg, sig.v, sig.r, sig.s);\n // require(signer == owner);\n payable(msg.sender).transfer(address(this).balance);\n }\n\n function vec_add(uint[2] memory a, uint[2] memory b) public returns (uint[2] memory c){\n c[0] = a[0] + b[0]; //overflow\n c[1] = a[1] + b[1]; //overflow\n }\n}\n\ncontract BugSample {\n uint256 uzero = 0;\n uint256 umax = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\n uint256 guards = 1;\n address winner;\n address owner;\n bool reentrancy_guard = false;\n\n constructor() {\n owner = msg.sender;\n }\n\n function overflow_add(uint256 b) public view returns (uint256) {\n return umax + b; // OVERFLOW\n }\n\n function underflow_minus(uint256 b) public view returns (uint256) {\n return uzero - b; // UNDERFLOW\n }\n\n function div_by_zero(uint256 m) public view returns (uint256) {\n return m / uzero; // DIVISION_BY_ZERO\n // Not a bug (always revert after solidity 0.4.0)\n }\n\n function reentrancy_withdraw() public {\n require(guards > 0, \"Must have some guards left\");\n (bool success, ) = payable(msg.sender).call{value: 1 ether}(\"\"); // REENTRANCY, UNCHECKED_SEND\n require(success);\n guards = 0;\n }\n\n function access_control(uint256 _guards, address addr) public {\n // POSSIBLE_ACCESS_CONTROL_BUG\n require(reentrancy_guard == false);\n reentrancy_guard = true;\n (bool success, ) = address(addr).call(\"\");\n require(success);\n guards = _guards;\n reentrancy_guard = false;\n }\n\n function assert_failure(uint256 _umax) public payable {\n assert(_umax > 0); // ASSERTION_FAILURE\n umax = _umax;\n }\n\n function guess(uint256 i) public payable {\n require(msg.value > 0, \"Must pay to play\");\n\n if (block.timestamp % i == 89) {\n // TIME_STAMP\n winner = msg.sender;\n }\n\n if (block.number % i == 97) {\n // BLOCK_NUMBER\n winner = msg.sender;\n }\n }\n\n function exception(address addr) public {\n address(addr).call(\"0x1234\"); // EXCEPTION_DISORDER, ADDRESS_VALIDATION\n }\n\n function kill() public {\n selfdestruct(msg.sender); // UNPROTECTED_SELFDESTRUCT\n }\n bool lock1;\n bool lock2;\n function unlock1 () public {\n lock1 = true;\n }\n function unlock2 () public {\n lock2 = true;\n }\n function three_step_bug() public {\n require(lock1);\n require(lock2);\n selfdestruct(msg.sender);\n }\n}\n"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment