Skip to content

Instantly share code, notes, and snippets.

View rocky's full-sized avatar

R. Bernstein rocky

View GitHub Profile
@rocky
rocky / CallScript.json
Created March 7, 2019 08:35
solc import json
This file has been truncated, but you can view the full file.
{
"compiler": {
"name": "solc",
"version": "0.4.24+commit.e67f0147.Emscripten.clang"
},
"updatedAt": "2019-03-07T07:11:10.142Z",
"sources": {
"/src/external-vcs/github/aragonOS/contracts/common/Autopetrified.sol": {
"contracts": [
{
@rocky
rocky / CallScript.json
Created March 7, 2019 08:35
solc import json
This file has been truncated, but you can view the full file.
{
"compiler": {
"name": "solc",
"version": "0.4.24+commit.e67f0147.Emscripten.clang"
},
"updatedAt": "2019-03-07T07:11:10.142Z",
"sources": {
"/src/external-vcs/github/aragonOS/contracts/common/Autopetrified.sol": {
"contracts": [
{
@rocky
rocky / fileIndex.js
Created February 26, 2019 02:01
some truffle-security stuff.
#!/usr/bin/env node
const srcmap = require('../lib/srcmap');
const sourceMaps = [
// ConvertLib
["ConvertLib sourcemap",
"34:155:0:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24"],
["ConvertLib deployed",
"34:155:0:-;;;;;;;;;;;;;;;;;;;;;;;;;55:132;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;55:132:0;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;126:20;169:14;160:6;:23;153:30;;55:132;;;;:::o"],
@rocky
rocky / ConverLib2.json
Last active February 27, 2019 01:21
more MythX-friendly solc JSON
{
"contracts": {
"/home/rocky/truffle/mythjs-should-detect/bernhard_medium_post/contracts/ConvertLib.sol": {
"ConvertLib": {
"abi": [
{
"constant": true,
"inputs": [
{
"name": "amount",
@rocky
rocky / ConverLibDHarvey.as
Created February 11, 2019 22:12
Constructed versus deployed EVM bytecode
$ evm-dasm -l short -c "0x738af6a7af30d840ba137e8f3f34d54cfb8beba6e230146080604052600436106050576000357c01000000000000000000000000000000000000000000000000000000009004806396e4ee3d146055575b600080fd5b608860048036036040811015606957600080fd5b810190808035906020019092919080359060200190929190505050609e565b6040518082815260200191505060405180910390f35b600081830290509291505056fea165627a7a723058202be5020944431115fd11565bc533b62243271e3e94c4fd7f1fcbcc25af1121ed0029"
Invalid opcode at position 362, opcode=0x2b
PUSH20 8af6a7af30d840ba137e8f3f34d54cfb8beba6e2
ADDRESS
EQ
PUSH1 80
PUSH1 40
MSTORE
PUSH1 04
CALLDATASIZE
@rocky
rocky / MemberAccess.ts
Created November 23, 2018 23:07
tx.origin antlr vs solc
// Return true if node is the tx.origin which refers to an
// address.
function txOriginViolation(node: any, issues: Issue[]): boolean {
const attrib = node.attributes;
if (attrib.type !== "address") {
return false;
}
if (attrib.member_name !== "origin") {
return false
}
@rocky
rocky / FunctionDefinition.ts
Created November 23, 2018 13:08
Maru AntlR and solc AST for SWC-100
// Rules involving the solc FunctionDefinition AST node
"use strict";
import { Issue, Severity } from '../issue';
function defaultVisibilityFunctionViolation(node: any, issues: Issue[]): boolean {
if (node.attributes.visibility === "default") {
const mess = `Function ${node.attributes.name} visibility is not set and defaults to "public".`;
const issue = new Issue(node.src, "SWC-100", Severity.Warning, mess);
issues.push(issue);
@rocky
rocky / maru-psa-extract.json
Last active November 6, 2018 20:17
Solc AST vs Maru
{
"type": "VariableDeclaration",
"typeName": {
"type": "ArrayTypeName",
"baseTypeName": {
"type": "ElementaryTypeName",
"name": "bytes32",
"loc": {
"start": {
"line": 4,
vmyth -v 1 -x coe.sol
22:07:33 INFO Analyzing contract coe.sol:Target
22:07:33 INFO LASER EVM initialized with dynamic loader: None
22:07:33 INFO - Entering function Target:unknown
22:07:33 INFO - Entering function Target:unknown
22:07:40 INFO - Entering function Target:unknown
22:07:41 INFO - Entering function Target:unknown
22:07:41 INFO - Entering function Target:unknown
22:07:41 INFO - Entering function Target:unknown
22:07:41 INFO - Entering function Target:unknown