Search is not available for this dataset
repo
stringlengths
2
152
file
stringlengths
15
239
code
stringlengths
0
58.4M
file_length
int64
0
58.4M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
364 values
smartbugs
smartbugs-master/tools/all/config.yaml
alias: - confuzzius - conkas - ethainter - ethor - honeybadger - maian - madmax - manticore - mythril - osiris - oyente - pakala - securify - sfuzz - slither - smartcheck - solhint - teether - vandal
276
12.190476
17
yaml
smartbugs
smartbugs-master/tools/confuzzius/config.yaml
name: ConFuzzius info: A data dependency-aware hybrid fuzzer for Ethereum smart contracts origin: https://github.com/christoftorres/ConFuzzius version: "#4315fb7 v0.0.1" image: smartbugs/confuzzius:4315fb7 solidity: command: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN' '$MAIN'" output: /root/results.json bin: scripts solc: yes
355
28.666667
75
yaml
smartbugs
smartbugs-master/tools/confuzzius/findings.yaml
Arbitrary Memory Access: classification: SWC-124, DASP-2 Assertion Failure: classification: SWC-110, DASP-10 Block Dependency: classification: SWC-120, DASP-6 Integer Overflow: classification: SWC-101, DASP-3 Leaking Ether: classification: SWC-105, DASP-2 Locking Ether: classification: SWC-997, DASP-5 Reentrancy: classification: SWC-107, DASP-1 Transaction Order Dependency: classification: SWC-114, DASP-7 Unhandled Exception: classification: SWC-104, DASP-4 Unprotected Selfdestruct: classification: SWC-106, DASP-2 Unsafe Delegatecall: classification: SWC-112, DASP-10
618
25.913043
36
yaml
smartbugs
smartbugs-master/tools/confuzzius/parser.py
import io import json import tarfile import sb.parse_utils VERSION = "2022/12/31" FINDINGS = { "Arbitrary Memory Access", "Assertion Failure", "Block Dependency", "Integer Overflow", "Leaking Ether", "Locking Ether", "Reentrancy", "Transaction Order Dependency", "Unhandled Exception", "Unprotected Selfdestruct", "Unsafe Delegatecall", } def is_relevant(line): # Remove logo when parsing exceptions return line and not ( line.startswith(" _") or line.startswith(" /") or line.startswith(" /") or line.startswith(" /") or line.startswith(" \\") ) def parse(exit_code, log, output): findings, infos = [], set() cleaned_log = filter(is_relevant, log) errors, fails = sb.parse_utils.errors_fails(exit_code, cleaned_log) for line in sb.parse_utils.discard_ANSI(log): msg = [ field.strip() for field in line.split(" - ") ] if len(msg) >= 4 and msg[2] == "ERROR": e = msg[3] if e.startswith("Validation error") and e.endswith("Sender account balance cannot afford txn (ignoring for now)"): e = "Validation error: Sender account balance cannot afford txn (ignoring for now)" errors.add(e) if output: try: with io.BytesIO(output) as o, tarfile.open(fileobj=o) as tar: file = tar.extractfile("results.json") results = json.load(file) for contract, data in results.items(): for errs in data['errors'].values(): for issue in errs: finding = { "contract": contract, "name": issue["type"], "severity": issue["severity"], "line": issue["line"], "message": f"Classification: SWC-{issue['swc_id']}" } findings.append(finding) except Exception as e: fails.add(f"error parsing results: {e}") return findings, infos, errors, fails
2,165
31.818182
126
py
smartbugs
smartbugs-master/tools/confuzzius/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" BIN="$3" MAIN="$4" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") COUNT=$(echo $CONTRACTS | wc -w) [ "$COUNT" -gt 0 ] || COUNT=1 OPT_CONTRACT="" if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then COUNT=1 OPT_CONTRACT="--contract $CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi # Fuzz each contract at least 10 seconds OPT_TIMEOUT="" TO=$(((TIMEOUT - (10 * COUNT)) / COUNT)) if [ "$TIMEOUT" -gt 0 ] && [ $TO -ge 10 ]; then OPT_TIMEOUT="--timeout $TO" fi touch /root/results.json python3 fuzzer/main.py -s "$FILENAME" --evm byzantium --results results.json --seed 1427655 $OPT_TIMEOUT $OPT_CONTRACT
865
22.405405
118
sh
smartbugs
smartbugs-master/tools/confuzzius/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/conkas/config.yaml
name: Conkas origin: https://github.com/smartbugs/conkas version: "#4e0f256" info: Conkas analyzes Ethereum smart contracts to find potential security issues. It uses Rattle to lift the bytecode to an intermediate representation and then applies symbolic execution. image: smartbugs/conkas:4e0f256 bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$BIN' '$MAIN'" solc: yes runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME'"
462
37.583333
188
yaml
smartbugs
smartbugs-master/tools/conkas/findings.yaml
Integer Overflow: classification: SWC-101, DASP-3 Integer Underflow: classification: SWC-101, DASP-3 Reentrancy: classification: SWC-107, DASP-1 Time Manipulation: classification: SWC-116, DASP-8 Transaction Ordering Dependence: classification: SWC-114, DASP-7 Unchecked Low Level Call: classification: SWC-104, DASP-4
343
25.461538
35
yaml
smartbugs
smartbugs-master/tools/conkas/parser.py
import re import sb.parse_utils VERSION = "2022/11/11" FINDINGS = { "Integer Overflow", "Integer Underflow", "Reentrancy", "Time Manipulation", "Transaction Ordering Dependence", "Unchecked Low Level Call" } ERRORS = ( re.compile("([A-Z0-9]+ instruction needs return value)"), re.compile("([A-Z0-9]+ instruction needs [0-9]+ arguments but [0-9]+ was given)"), re.compile("([A-Z0-9]+ instruction need arguments but [0-9]+ was given)"), re.compile("([A-Z0-9]+ instruction needs a concrete argument)"), re.compile("([A-Z0-9]+ instruction should not be reached)"), re.compile("([A-Z0-9]+ instruction is not implemented)"), re.compile("(Cannot get source map runtime\. Check if solc is in your path environment variable)"), re.compile("(Vulnerability module checker initialized without traces)"), re.compile(".*(solcx.exceptions.SolcError:.*)") ) ANALYSING = re.compile("^Analysing (.*)\.\.\.$") VULNERABILITY = re.compile("^Vulnerability: (.*)\. Maybe in function: (.*)\. PC: 0x(.*)\. Line number: (.*)\.$") def is_relevant(line): return not ANALYSING.match(line) def parse(exit_code, log, output): findings, infos = [], set() cleaned_log = filter(is_relevant, log) errors, fails = sb.parse_utils.errors_fails(exit_code, cleaned_log) for f in list(fails): # iterate over a copy of "fails" such that it can be modified if f.startswith("exception (KeyError: <SSABasicBlock"): fails.remove(f) fails.add("exception (KeyError: <SSABasicBlock ...>)") if f.startswith("exception (RecursionError: maximum recursion depth exceeded while calling a Python object)"): # Normalize two types of recursion errors to the shorter one. fails.remove(f) fails.add("exception (RecursionError: maximum recursion depth exceeded)") filename,contract = None,None for line in log: if sb.parse_utils.add_match(errors, line, ERRORS): fails.discard("exception (Exception)") continue m = ANALYSING.match(line) if m: filename,contract = m[1].split(":") if ":" in m[1] else (m[1],None) m = VULNERABILITY.match(line) if m: finding = { "name": m[1] } if filename: finding["filename"] = filename if contract: finding["contract"] = contract if m[2]: finding["function"] = m[2] if m[3]: finding["address"] = int(m[3],16) if m[4]: finding["line"] = int(m[4]) findings.append(finding) return findings, infos, errors, fails
2,635
37.202899
118
py
smartbugs
smartbugs-master/tools/conkas/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" cd /conkas python3 conkas.py -fav "$FILENAME"
72
9.428571
34
sh
smartbugs
smartbugs-master/tools/conkas/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" BIN="$2" MAIN="$3" export PATH="$BIN:$PATH" chmod +x $BIN/solc CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") OPT_CONTRACT="" if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then OPT_CONTRACT="--contract $CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi cd /conkas python3 conkas.py -fav -s "$FILENAME" $OPT_CONTRACT
509
18.615385
61
sh
smartbugs
smartbugs-master/tools/conkas/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/ethainter/config.yaml
name: Ethainter origin: https://zenodo.org/record/3760403 info: "Ethainter is a smart contract security analyzer for composite vulnerabilities. See the paper (Brent et al.: Ethainter: A Smart Contract Security Analyzer for Composite Vulnerabilities; In 41st ACM SIGPLAN Conference on Programming Language Design and Implementation, 2020)." image: smartbugs/ethainter:latest runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'" bin: scripts output: /home/reviewer/gigahorse-toolchain/logic/results.json
528
57.777778
281
yaml
smartbugs
smartbugs-master/tools/ethainter/findings.yaml
AccessibleSelfdestruct: classification: SWC-106, DASP-2 TaintedDelegatecall: classification: SWC-112, DASP-10 TaintedOwnerVariable: classification: SWC-124, DASP-2 TaintedSelfdestruct: classification: SWC-105, DASP-2 TaintedStoreIndex: classification: SWC-124, DASP-2 TaintedValueSend: classification: SWC-105, DASP-2 UncheckedTaintedStaticcall: classification: SWC-0, DASP-10
405
26.066667
36
yaml
smartbugs
smartbugs-master/tools/ethainter/parser.py
import tools.gigahorse.parser as gigahorse VERSION = gigahorse.VERSION FINDINGS = { "TaintedStoreIndex", "TaintedSelfdestruct", "TaintedValueSend", "UncheckedTaintedStaticcall", "AccessibleSelfdestruct", "TaintedDelegatecall", "TaintedOwnerVariable" } def parse(exit_code, log, output): return gigahorse.parse(exit_code, log, output, FINDINGS)
379
21.352941
60
py
smartbugs
smartbugs-master/tools/ethainter/docker/scripts/run.sh
#!/bin/sh FILENAME="$1" ./analyze.py --reuse_datalog_bin --restart --rerun_clients -d /data -C ../../ethainter-inlined.dl
124
19.833333
97
sh
smartbugs
smartbugs-master/tools/ethainter/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" SB=$(dirname "$FILENAME") OPT_TIMEOUT="" if [ "$TIMEOUT" -ge 170 ]; then # reserve 50s for Ethainter to finish after timeout TO=$((TIMEOUT-50)) OPT_TIMEOUT="-T $TO" fi cd /home/reviewer/gigahorse-toolchain/logic ./analyze.py --reuse_datalog_bin --restart --rerun_clients $OPT_TIMEOUT -d "$SB" -C ../../ethainter-inlined.dl
375
22.5
110
sh
smartbugs
smartbugs-master/tools/ethor/config.yaml
name: eThor origin: https://secpriv.wien/ethor version: "2021 (CCS 2020)" info: eThor is a sound static analyzer for EVM smart contracts based on HoRSt. runtime: image: smartbugs/ethor:rmvi20q command: "ethor-with-reconstruction '$FILENAME' --prune-strategy=aggressive --predicate-inlining-strategy=linear --preanalysis"
329
40.25
131
yaml
smartbugs
smartbugs-master/tools/ethor/findings.yaml
insecure: classification: SWC-107, DASP-1 secure: classification: SWC-0, DASP-10
89
17
35
yaml
smartbugs
smartbugs-master/tools/ethor/parser.py
import re import sb.parse_utils VERSION = "2022/11/11" FINDINGS = ("secure", "insecure") UNKNOWN_BYTECODE = "Encountered an unknown bytecode" FAILS = ( re.compile("OpenJDK.* failed; error='([^']+)'"), re.compile("(Floating-point arithmetic exception) signal in rule"), re.compile(".*(Undefined relation [a-zA-Z0-9]+) in file .*dl at line"), ) UNSUPPORTED_OP = re.compile(".*(java.lang.UnsupportedOperationException: [^)]*)\)") COMPLETED = re.compile("^(.*) (secure|insecure|unknown)$") def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) errors.discard('EXIT_CODE_1') # redundant: exit code 1 is reflected in other errors if 'DOCKER_TIMEOUT' in fails or 'DOCKER_KILL_OOM' in fails: fails.discard('exception (Killed)') # "Unsupported Op" is a regular, checked-for errors, not an unexpected fails for e in list(fails): m = UNSUPPORTED_OP.match(e) if m: fails.remove(e) errors.add(m[1]) analysis_complete = False for line in log: if UNKNOWN_BYTECODE in line: infos.add(UNKNOWN_BYTECODE) continue if sb.parse_utils.add_match(fails, line, FAILS): continue if line.endswith(" unknown"): analysis_complete = True continue m = COMPLETED.match(line) if m: analysis_complete = True if m[2] in FINDINGS: findings.append({"filename": m[1], "name": m[2]}) continue if "DOCKER_SEGV" in fails: fails.discard("exception (Segmentation fault)") if log and not analysis_complete: infos.add('analysis incomplete') if not fails and not errors: fails.add('execution failed') return findings, infos, errors, fails
1,864
31.155172
87
py
smartbugs
smartbugs-master/tools/ethor/docker/README.md
The docker container created by these files bundles the version of eThor used for the experiments published in CCS. ## Build ``` nix-build dockertools.nix ``` (if you know how to use docker but don't have nix-build installed, the easiest way _might be_ to get a NixOS docker image and call `nix-build` within) After `nix-build` returns, there should be a file `result` which is the image. Load it with ``` docker load -i result Loaded image: ethor:ddj39dq9p5x7a3fskva810lzq5sdmv90 # the id might be different ``` ## Run You can run the eThor tool (as described by `--help`) with ``` docker run --rm -ti -v $PWD:/mnt/ ethor:ddj39dq9p5x7a3fskva810lzq5sdmv90 ethor ``` The cfg-reconstruction tool (with a simplified interface) is also contained in the image. This call takes a contract, given as hex-encoding of it's bytecode `contract.hex` and outputs a file `contract.json` which contains the reconstructed jump destinations. ``` docker run --rm -ti -v $PWD:/mnt/ ethor:ddj39dq9p5x7a3fskva810lzq5sdmv90 run-reconstruct contract.hex contract.json ``` Finally, there is also a tool that combines the two former tools. This tool has a slightly different interface than eThor. The first argument is a single contract in hex encoding, the following parameters are passed to eThor. The following parameters may not be passed: `--smt-out-dir` `--no-output-query-result` (both are implied). What the tool does is: reconstruct the control flow for the given contract, generate a smt-file for it and then run z3 (parallely) on these file for each query. If one query return "sat", the contract is labelled insecure, otherwise if one query returns or times out, the contract is labelled unknown, otherwise the contract is labelled safe. If the environment variable `Z3_TIMEOUT` is set (via docker) `z3` will be aborted after the given time runs out. If the `EARLY_EXIT_ON_SAT` is set to `YES`, the experiment will be aborted after the first query is satisfied (as the contract will be labelled insecure in any case). ``` # execute all queries docker run --rm -ti -v $PWD:/mnt/ ethor:yqcrsvbdzhcjc8mnssfjl7fal1gx1wwp ethor-with-reconstruction 0x015a06a433353f8db634df4eddf0c109882a15ab.hex --prune-strategy=aggressive --predicate-inlining-strategy=linear --preanalysis # abort on first sat and abort z3 after 30 seconds docker run --rm -ti -v $PWD:/mnt/ -e TIMEOUT=30s -e EARLY_EXIT_ON_SAT=YES ethor:yqcrsvbdzhcjc8mnssfjl7fal1gx1wwp ethor-with-reconstruction 0x015a06a433353f8db634df4eddf0c109882a15ab.hex --prune-strategy=aggressive --predicate-inlining-strategy=linear --preanalysis ```
2,598
38.378788
264
md
smartbugs
smartbugs-master/tools/gigahorse/parser.py
import io, json, tarfile import sb.parse_utils VERSION = "2022/11/17" def parse(exit_code, log, output, FINDINGS): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) if "Writing results to results.json" not in log: infos.add("analysis incomplete") if not fails and not errors: fails.add("execution failed") try: with io.BytesIO(output) as o, tarfile.open(fileobj=o) as tar: results_json=tar.extractfile("results.json").read() result = json.loads(results_json) for contract in result: filename = contract[0] errors.update(contract[2]) report = contract[3] for name in FINDINGS: if not report.get(name): continue addresses = [] for address in report[name].split(): address = address.lower() i = 2 if address[:2] == "0x" else 0 while i < len(address): if address[i] not in "0123456789abcdef": break i += 1 try: addresses.append(int(address[0:i],16)) except: pass if addresses: for address in addresses: findings.append({ "filename": filename, "name": name, "address": address }) else: findings.append({ "filename": filename, "name": name }) except Exception as e: fails.add(f"problem extracting results.json from docker container: {e}") return findings, infos, errors, fails
1,926
32.807018
80
py
smartbugs
smartbugs-master/tools/honeybadger/config.yaml
name: HoneyBadger version: "#ff30c9a" info: An analysis tool to detect honeypots in Ethereum smart contracts origin: https://github.com/christoftorres/HoneyBadger image: smartbugs/honeybadger:ff30c9a bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN' '$MAIN'" solc: yes runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'"
386
31.25
77
yaml
smartbugs
smartbugs-master/tools/honeybadger/findings.yaml
Balance disorder: classification: SWC-0, DASP-10 Hidden state update: classification: SWC-0, DASP-10 Hidden transfer: classification: SWC-0, DASP-10 Inheritance disorder: classification: SWC-0, DASP-10 Money flow: classification: SWC-0, DASP-10 Skip empty string: classification: SWC-0, DASP-10 Straw man contract: classification: SWC-0, DASP-10 Type overflow: classification: SWC-0, DASP-10 Uninitialised struct: classification: SWC-0, DASP-10
481
24.368421
34
yaml
smartbugs
smartbugs-master/tools/honeybadger/parser.py
import tools.oyente.parser as oyente VERSION = oyente.VERSION FINDINGS = { "Money flow", "Balance disorder", "Hidden transfer", "Inheritance disorder", "Uninitialised struct", "Type overflow", "Skip empty string", "Hidden state update", "Straw man contract" } def parse(exit_code, log, output): return oyente.parse(exit_code, log, output)
418
21.052632
47
py
smartbugs
smartbugs-master/tools/honeybadger/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for honeybadger to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="-glt $TO" fi python honeybadger/honeybadger.py $OPT_TIMEOUT -b -s "$FILENAME"
290
18.4
64
sh
smartbugs
smartbugs-master/tools/honeybadger/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" BIN="$3" MAIN="$4" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") OPT_CONTRACT="" if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then OPT_CONTRACT="--contract $CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for honeybadger to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="-glt $TO" fi python honeybadger/honeybadger.py $OPT_TIMEOUT -s "$FILENAME" $OPT_CONTRACT
723
20.294118
75
sh
smartbugs
smartbugs-master/tools/honeybadger/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/madmax/config.yaml
name: MadMax origin: https://github.com/nevillegrech/MadMax version: "#6e9a6e9" info: Madmax consists of a series of analyses and queries that find gas-focused vulnerabilities in Ethereum smart contracts. image: smartbugs/madmax:6e9a6e9 runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'" bin: scripts output: /MadMax/results.json
358
34.9
124
yaml
smartbugs
smartbugs-master/tools/madmax/findings.yaml
OverflowLoopIterator: classification: SWC-101, DASP-3 UnboundedMassOp: classification: SWC-128, DASP-5 WalletGriefing: classification: SWC-113, DASP-5
163
22.428571
35
yaml
smartbugs
smartbugs-master/tools/madmax/parser.py
import tools.gigahorse.parser as gigahorse VERSION = gigahorse.VERSION FINDINGS = { "OverflowLoopIterator", "UnboundedMassOp", "WalletGriefing" } def parse(exit_code, log, output): return gigahorse.parse(exit_code, log, output, FINDINGS)
257
18.846154
60
py
smartbugs
smartbugs-master/tools/madmax/docker/scripts/run.sh
#!/bin/sh FILENAME=$1 CODE=$(cat ${FILENAME}) python3 gigahorse-toolchain/gigahorse.py --reuse_datalog_bin --rerun_clients --restart -C madmax.dl ${FILENAME}
160
22
111
sh
smartbugs
smartbugs-master/tools/madmax/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -ge 170 ]; then # reserve 50s for MaxMax to finish after timeout TO=$((TIMEOUT-50)) OPT_TIMEOUT="-T $TO" fi cd /MadMax python3 gigahorse-toolchain/gigahorse.py --reuse_datalog_bin --rerun_clients --restart $OPT_TIMEOUT -C madmax.dl "${FILENAME}"
329
21
126
sh
smartbugs
smartbugs-master/tools/maian/config.yaml
name: Maian origin: https://github.com/smartbugs/MAIAN info: Maian is a tool for the automated detection of buggy Ethereum smart contracts of type 'prodigal', 'suicidal', and 'greedy'. image: smartbugs/maian:solc5.10 version: '#4bab09a' bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$BIN' '$MAIN'" solc: yes bytecode: entrypoint: "'$BIN/do_bytecode.sh' '$FILENAME'" runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME'"
463
32.142857
129
yaml
smartbugs
smartbugs-master/tools/maian/findings.yaml
Destructible: classification: SWC-106, DASP-2 Destructible (verified): classification: SWC-106, DASP-2 Ether leak: classification: SWC-105, DASP-2 Ether leak (verified): classification: SWC-105, DASP-2 Ether lock: classification: SWC-997, DASP-5 Ether lock (Ether accepted without send): classification: SWC-997, DASP-5 No Ether leak (no send): classification: SWC-0, DASP-10 No Ether lock (Ether refused): classification: SWC-0, DASP-10 Not destructible (no self-destruct): classification: SWC-0, DASP-10
542
27.578947
41
yaml
smartbugs
smartbugs-master/tools/maian/parser.py
import sb.parse_utils import re VERSION = "2022/11/11" FINDINGS = ( "No Ether leak (no send)", "Ether leak", "Ether leak (verified)", # "Accepts Ether", "No Ether lock (Ether refused)", "Ether lock (Ether accepted without send)", "Ether lock", "Not destructible (no self-destruct)", "Destructible", "Destructible (verified)", ) FILENAME = re.compile("\[ \] Compiling Solidity contract from the file (.*/.*) \.\.\.") MISSING_ABI_BIN = re.compile("\[-\] Some of the files is missing or empty: \|(.*)\.abi\|=[0-9]+ \|(.*)\.bin\|=[0-9]+") CONTRACT = re.compile("\[ \] Contract address saved in file: (?:.*/)?(.*)\.address") CANNOT_DEPLOY = "[-] Cannot deploy the contract" # no bincode, e.g. interfaces in the source code NOT_PRODIGAL = "[+] The code does not have CALL/SUICIDE, hence it is not prodigal" LEAK_FOUND = "[-] Leak vulnerability found!" CANNOT_CONFIRM_BUG = "[-] Cannot confirm the bug because the contract is not deployed on the blockchain." CANNOT_CONFIRM_LEAK = "[ ] Confirming leak vulnerability on private chain ... Cannot confirm the leak vulnerability" PRODIGAL_CONFIRMED = " Confirmed ! The contract is prodigal !" PRODIGAL_NOT_FOUND = "[+] No prodigal vulnerability found" CAN_RECEIVE_ETHER = "[+] Contract can receive Ether" CANNOT_RECEIVE_ETHER= "[-] No lock vulnerability found because the contract cannot receive Ether" IS_GREEDY = "[-] The code does not have CALL/SUICIDE/DELEGATECALL/CALLCODE thus is greedy !" NO_LOCKING_FOUND = "[+] No locking vulnerability found" LOCK_FOUND = "[-] Locking vulnerability found!" NO_SELFDESTRUCT = "[-] The code does not contain SUICIDE instructions, hence it is not vulnerable" SD_VULN_FOUND = "[-] Suicidal vulnerability found!" CANNOT_CONFIRM_SDV = "[ ] Confirming suicide vulnerability on private chain ... Cannot confirm the suicide vulnerability" SD_VULN_CONFIRMED = " Confirmed ! The contract is suicidal !" SD_VULN_NOT_FOUND = "[-] No suicidal vulnerability found" TRANSACTION = re.compile(" -Tx\[.+\] :([0-9a-z ]+)") MAP_FINDINGS = ( (NOT_PRODIGAL, "No Ether leak (no send)"), (LEAK_FOUND, "Ether leak"), (PRODIGAL_CONFIRMED, "Ether leak (verified)"), # (CAN_RECEIVE_ETHER, "Accepts Ether"), (CANNOT_RECEIVE_ETHER, "No Ether lock (Ether refused)"), (IS_GREEDY, "Ether lock (Ether accepted without send)"), (LOCK_FOUND, "Ether lock"), (NO_SELFDESTRUCT, "Not destructible (no self-destruct)"), (SD_VULN_FOUND, "Destructible"), (SD_VULN_CONFIRMED, "Destructible (verified)"), ) INFOS = ( # (PRODIGAL_NOT_FOUND , "No Ether leak found"), # nothing detected # (NO_LOCKING_FOUND, "No Ether lock found"), # nothing detected # (SD_VULN_NOT_FOUND, "No destructibility found"), # nothing detected (CANNOT_CONFIRM_BUG, "Cannot confirm vulnerability because contract not deployed on blockchain"), (CANNOT_CONFIRM_LEAK, "Cannot confirm vulnerability because contract not deployed on blockchain"), (CANNOT_CONFIRM_SDV, "Cannot confirm vulnerability because contract not deployed on blockchain"), ) ERRORS = ( re.compile("\[-\] (Cannot compile the contract)"), re.compile(".*(Unknown operation)"), re.compile(".*(Some addresses are larger)"), re.compile(".*(did not process.*)"), re.compile(".*(In SLOAD the list at address)"), re.compile(".*(Incorrect final stack size)"), re.compile(".*(need to set the parameters)"), re.compile("\[-\] (.* does NOT exist)"), re.compile(".*(?<!Z3)Exception: (.{,64})"), ) CHECK = re.compile("\[ \] Check if contract is (PRODIGAL|GREEDY|SUICIDAL)") def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) if fails: errors.discard("EXIT_CODE_1") # redundant analysis_complete = {} finding = {} for line in sb.parse_utils.discard_ANSI(log): if line.startswith("="*100): if finding.get("name"): findings.append(finding) finding = {} continue m = FILENAME.match(line) if m: finding["filename"] = m[1] continue m = CONTRACT.match(line) if m and finding.get("filename"): finding["contract"] = m[1] continue m = MISSING_ABI_BIN.match(line) if m: assert m[1]==m[2] finding["contract"] = m[1] continue found = False for indicator,name in MAP_FINDINGS: if line.startswith(indicator): finding["name"] = name found = True break if found: continue found = False for indicator,info in INFOS: if line.startswith(indicator): infos.add(info) found = True break if found: continue if sb.parse_utils.add_match(errors, line, ERRORS): continue m = CHECK.match(line) if m: k = (finding.get("filename"),finding.get("contract")) if k not in analysis_complete: analysis_complete[k] = set() analysis_complete[k].add(m[1]) continue m = TRANSACTION.match(line) if m: if "exploit" not in finding: finding["exploit"] = [] finding["exploit"].append(m[1]) continue if finding.get("name"): findings.append(finding) for checks in analysis_complete.values(): if len(checks) != 3: infos.add("analysis incomplete") if not fails and not errors: fails.add("execution failed") return findings, infos, errors, fails
5,852
36.76129
126
py
smartbugs
smartbugs-master/tools/maian/docker/scripts/printContractNames.py
import sys import pprint from solidity_parser import parser sourceUnit = parser.parse_file(sys.argv[1]) #pprint.pprint(sourceUnit) sourceUnitObject = parser.objectify(sourceUnit) # access imports, contracts, functions, ... (see outline example in # __main__.py) sourceUnitObject.imports # [] sourceUnitObject.pragmas # [] for contract_name in sourceUnitObject.contracts.keys(): print(contract_name)
410
23.176471
68
py
smartbugs
smartbugs-master/tools/maian/docker/scripts/runMAIANall.sh
#!/bin/sh FILENAME=$1 for c in `python3 printContractNames.py ${FILENAME} | grep -v "ANTLR runtime and generated code versions disagree:"`; do cd /MAIAN/tool; python3 maian.py -c 0 -s ${FILENAME} ${c}; python3 maian.py -c 1 -s ${FILENAME} ${c}; python3 maian.py -c 2 -s ${FILENAME} ${c} done
329
26.5
118
sh
smartbugs
smartbugs-master/tools/maian/docker/scripts/run_maian_bytecode.sh
#!/bin/sh FILENAME=$1 cd /MAIAN/tool python3 maian.py -c 0 -b ${FILENAME} python3 maian.py -c 1 -b ${FILENAME} python3 maian.py -c 2 -b ${FILENAME}
150
15.777778
36
sh
smartbugs
smartbugs-master/tools/maian/docker/scripts/run_maian_solidity.sh
#!/bin/sh FILENAME=$1 for c in `python3 printContractNames.py ${FILENAME} | grep -v "ANTLR runtime and generated code versions disagree:"`; do cd /MAIAN/tool; python3 maian.py -c 0 -s ${FILENAME} ${c}; python3 maian.py -c 1 -s ${FILENAME} ${c}; python3 maian.py -c 2 -s ${FILENAME} ${c} done
329
26.5
118
sh
smartbugs
smartbugs-master/tools/maian/scripts/do_bytecode.sh
#!/bin/sh FILENAME="$1" cd /MAIAN/tool python3 maian.py -c 0 -bs "$FILENAME" python3 maian.py -c 1 -bs "$FILENAME" python3 maian.py -c 2 -bs "$FILENAME"
155
16.333333
37
sh
smartbugs
smartbugs-master/tools/maian/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" cd /MAIAN/tool python3 maian.py -c 0 -b "$FILENAME" python3 maian.py -c 1 -b "$FILENAME" python3 maian.py -c 2 -b "$FILENAME"
152
16
36
sh
smartbugs
smartbugs-master/tools/maian/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" BIN="$2" MAIN="$3" export PATH="$BIN:$PATH" chmod +x $BIN/solc CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then CONTRACTS="$CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi cd /MAIAN/tool; for CONTRACT in $CONTRACTS; do for c in 0 1 2; do python3 maian.py -c "$c" -s "$FILENAME" "$CONTRACT" done done
561
18.37931
61
sh
smartbugs
smartbugs-master/tools/maian/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/manticore-0.3.7/config.yaml
name: Manticore origin: https://github.com/trailofbits/manticore version: 0.3.7 info: Manticore is a symbolic execution tool for analysis of smart contracts and binaries. image: smartbugs/manticore:0.3.7 output: /results solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$BIN'" solc: yes bin: scripts
321
28.272727
90
yaml
smartbugs
smartbugs-master/tools/manticore-0.3.7/parser.py
import io, tarfile, yaml import sb.parse_utils VERSION = "2022/11/17" FINDINGS = set() def parse_file(lines): findings = [] snippet = False for line in lines: if snippet: snippet = False l = line.split() finding["line"] = int(l[0]) finding["code"] = c elif line.startwith(" Solidity snippet:"): snippet = True elif line[0] == "-": finding = { "name": line[1:-2].strip() } findings.append(finding) continue return findings def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) if any("Invalid solc compilation" in line for line in log): errors.add("solc error") try: with io.BytesIO(output) as o, tarfile.open(fileobj=o) as tar: for fn in tar.getnames(): if not fn.endswith("/global.findings"): continue try: contents = tar.extractfile(fn).read() manticore_findings = parse_file(contents.splitlines()) except Exception as e: fails.add(f"problem extracting {fn} from output archive: {e}") continue cmd = None try: fn = fn.replace("/global.findings","/manticore.yml") cmd = yaml.safe_load(tar.extractfile(fn).read()) except Exception as e: infos.add(f"manticore.yml not found") filename, contract = None, None if isinstance(cmd,dict): cli = cmd.get("cli") if isinstance(cli,dict): contract = cli.get("contract") argv = cli.get("argv") if isinstance(argv,list) and len(argv) > 0: filename = argv[0] for mf in manticore_findings: if filename: mf["filename"] = filename if contract: mf["contract"] = contract findings.append(mf) except Exception as e: fails.add(f"error parsing results: {e}") return findings, infos, errors, fails
2,383
31.216216
82
py
smartbugs
smartbugs-master/tools/manticore-0.3.7/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" BIN="$2" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" mkdir /results for c in `python3 "$BIN/printContractNames.py" "${FILENAME}"`; do manticore --no-colors --contract "${c}" "${FILENAME#/}" mv /mcore_* /results done
263
16.6
66
sh
smartbugs
smartbugs-master/tools/manticore-0.3.7/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/manticore/config.yaml
alias: - manticore-0.3.7
29
9
21
yaml
smartbugs
smartbugs-master/tools/mythril-0.23.15/config.yaml
name: Mythril version: 0.23.15 origin: https://github.com/ConsenSys/mythril info: Mythril analyses EVM bytecode using symbolic analysis, taint analysis and control flow checking to detect a variety of security vulnerabilities. image: smartbugs/mythril:0.23.15 bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN' '$MAIN'" solc: yes bytecode: entrypoint: "'$BIN/do_bytecode.sh' '$FILENAME' '$TIMEOUT'" runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'"
519
36.142857
150
yaml
smartbugs
smartbugs-master/tools/mythril-0.23.15/findings.yaml
Delegatecall to user-supplied address (SWC 112): classification: SWC-112, DASP-10 method: Check for invocations of delegatecall to a user-supplied address. descr_short: The contract delegates execution to another contract with a user-supplied address. descr_long: The smart contract delegates execution to a user-supplied address. This could allow an attacker to execute arbitrary code in the context of this contract account and manipulate the state of the contract account or execute actions on its behalf. severity: high Dependence on predictable environment variable (SWC 116): classification: SWC-116, DASP-8 method: Check whether control flow decisions are influenced by block.coinbase, block.gaslimit, block.timestamp or block.number. descr_short: A control flow decision is made based on the block variable coinbase, gaslimit, timestamp or block number. descr_long: One or more of block.coinbase, block.gaslimit, block.timestamp or block.number are used to determine a control flow decision. Note that the values of these variables are predictable and can be manipulated by a malicious miner. Also keep in mind that attackers know hashes of earlier blocks. Don't use any of those environment variables as sources of randomness and be aware that use of these variables introduces a certain level of trust into miners. severity: low Dependence on predictable environment variable (SWC 120): classification: SWC-120, DASP-6 method: Check whether control flow decisions are influenced by block.coinbase, block.gaslimit, block.timestamp or block.number. descr_short: A control flow decision is made based on the block variable coinbase, gaslimit, timestamp or block number. descr_long: One or more of block.coinbase, block.gaslimit, block.timestamp or block.number are used to determine a control flow decision. Note that the values of these variables are predictable and can be manipulated by a malicious miner. Also keep in mind that attackers know hashes of earlier blocks. Don't use any of those environment variables as sources of randomness and be aware that use of these variables introduces a certain level of trust into miners. severity: low Dependence on tx.origin (SWC 115): classification: SWC-115, DASP-2 method: Check whether control flow decisions are influenced by tx.origin descr_long: The tx.origin environment variable has been found to influence a control flow decision. Note that using tx.origin as a security control might cause a situation where a user inadvertently authorizes a smart contract to perform an action on their behalf. It is recommended to use msg.sender instead. severity: low descr_short: Use of tx.origin as a part of authorization control. Exception State (SWC 110): classification: SWC-110, DASP-10 method: Checks whether any exception states are reachable. descr_long: It is possible to trigger an assertion violation. Note that Solidity assert() statements should only be used to check invariants. Review the transaction trace generated for this issue and either make sure your program logic is correct, or use require() instead of assert() if your goal is to constrain user inputs or enforce preconditions. Remember to validate inputs from both callers (for instance, via passed arguments) and callees (for instance, via return values). severity: medium descr_short: An assertion violation was triggered. External Call To User-Supplied Address (SWC 107): classification: SWC-107, DASP-5 method: Search for external calls with unrestricted gas to a user-specified address. descr_short: A call to a user-supplied address is executed. descr_long: An external message call to an address specified by the caller is executed. Note that the callee account might contain arbitrary code and could re-enter any function within this contract. Reentering the contract in an intermediate state may lead to unexpected behaviour. Make sure that no state modifications are executed after this call and/or reentrancy guards are in place. severity: low Integer Arithmetic Bugs (SWC 101): classification: SWC-101, DASP-3 method: For every SUB instruction, check if there is a possible state where the second operand is larger than the first one. For every ADD, MUL instruction, check if there is a possible state where the result of the operation overflows. descr_short: The arithmetic operator can underflow/overflow descr_long: It is possible to cause an integer overflow or underflow in the arithmetic operation. Prevent this by constraining inputs using the require() statement or use the OpenZeppelin SafeMath library for integer arithmetic operations. Refer to the transaction trace generated for this issue to reproduce the issue. severity: high Jump to an arbitrary instruction (SWC 127): classification: SWC-127, DASP-10 method: Search for jumps to arbitrary locations in the bytecode severity: high descr_short: The caller can redirect execution to arbitrary bytecode locations. descr_long: It is possible to redirect the control flow to arbitrary locations in the code. This may allow an attacker to bypass security controls or manipulate the business logic of the smart contract. Avoid using low-level-operations and assembly to prevent this issue. Multiple Calls in a Single Transaction (SWC 113): classification: SWC-113, DASP-5 method: Check for multiple sends in a single transaction descr_long: This call is executed following another call within the same transaction. It is possible that the call never gets executed if a prior call fails permanently. This might be caused intentionally by a malicious callee. If possible, refactor the code such that each transaction only executes one external call or make sure that all callees can be trusted (i.e. they’re part of your own codebase). severity: low descr_short: Multiple calls are executed in the same transaction. State access after external call (SWC 107): classification: SWC-107, DASP-1 method: Check whether the account state is accesses after the execution of an external call severity: medium if user defined address, low if fixed address descr_short: Read of/Write to persistent state following external call descr_long: The contract account state is accessed after an external call to a user-defined/fixed address. To prevent reentrancy issues, consider accessing the state only before the call, especially if the callee is untrusted. Alternatively, a reentrancy lock can be used to prevent untrusted callees from re-entering the contract in an intermediate state. Unchecked return value from external call. (SWC 104): classification: SWC-104, DASP-4 method: Test whether CALL return value is checked. For direct calls, the Solidity compiler auto-generates this check. For low-level-calls this check is omitted. descr_long: External calls return a boolean value. If the callee halts with an exception, 'false' is returned and execution continues in the caller. The caller should check whether an exception happened and react accordingly to avoid unexpected behavior. For example it is often desirable to wrap external calls in require() so the transaction is reverted if the call fails. severity: medium descr_short: The return value of a message call is not checked. Unprotected Ether Withdrawal (SWC 105): classification: SWC-105, DASP-2 method: Search for cases where Ether can be withdrawn to a user-specified address. An issue is reported if there is a valid end state where the attacker has successfully increased their Ether balance. severity: high descr_short: Any sender can withdraw Ether from the contract account. descr_long: Arbitrary senders other than the contract creator can profitably extract Ether from the contract account. Verify the business logic carefully and make sure that appropriate security controls are in place to prevent unexpected loss of funds. Unprotected Selfdestruct (SWC 106): classification: SWC-106, DASP-2 method: Check if the contact can be 'accidentally' killed by anyone. For kill-able contracts, also check whether it is possible to direct the contract balance to the attacker. descr_short: Any sender can cause the contract to self-destruct. descr_long: Any sender can trigger execution of the SELFDESTRUCT instruction to destroy this contract account. Review the transaction trace generated for this issue and make sure that appropriate security controls are in place to prevent unrestricted access. severity: high Write to an arbitrary storage location (SWC 124): classification: SWC-124, DASP-2 method: Search for any writes to an arbitrary storage slot severity: high descr_short: The caller can write to arbitrary storage locations. descr_long: It is possible to write to arbitrary storage locations. By modifying the values of storage variables, attackers may bypass security controls or manipulate the business logic of the smart contract.
9,095
91.816327
485
yaml
smartbugs
smartbugs-master/tools/mythril-0.23.15/parser.py
import json import sb.parse_utils VERSION = "2023/01/20" FINDINGS = { "Jump to an arbitrary instruction (SWC 127)", "Write to an arbitrary storage location (SWC 124)", "Delegatecall to user-supplied address (SWC 112)", "Dependence on tx.origin (SWC 115)", "Dependence on predictable environment variable (SWC 116)", "Dependence on predictable environment variable (SWC 120)", "Unprotected Ether Withdrawal (SWC 105)", "Exception State (SWC 110)", "External Call To User-Supplied Address (SWC 107)", "Integer Arithmetic Bugs (SWC 101)", "Multiple Calls in a Single Transaction (SWC 113)", "State access after external call (SWC 107)", "Unprotected Selfdestruct (SWC 106)", "Unchecked return value from external call. (SWC 104)", } def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) errors.discard("EXIT_CODE_1") # exit code = 1 just means that a weakness has been found # Mythril catches all exceptions, prints a message "please report", and then prints the traceback. # So we consider all exceptions as fails (= non-intended interruptions) for f in list(fails): # iterate over a copy of 'fails' such that it can be modified if f.startswith("exception (mythril.laser.ethereum.transaction.transaction_models.TransactionEndSignal"): fails.remove(f) fails.add("exception (mythril.laser.ethereum.transaction.transaction_models.TransactionEndSignal)") for line in log: if "Exception occurred, aborting analysis." in line: infos.add("analysis incomplete") if not fails and not errors: fails.add("execution failed") break try: result = json.loads(log[-1]) except: result = None if result: error = result.get("error") if error: errors.add(error.split('.')[0]) for issue in result.get("issues", []): finding = { "name": issue["title"] } for i,f in ( ("filename","filename"), ("contract","contract"), ("function","function"), ("address","address"), ("lineno", "line"), ("tx_sequence","exploit"), ("description","message"), ("severity","severity") ): if i in issue: finding[f] = issue[i] if "swc-id" in issue: finding["name"] += f" (SWC {issue['swc-id']})" classification = f"Classification: SWC-{issue['swc-id']}" if finding.get("message"): finding["message"] += f"\n{classification}" else: finding["message"] = classification findings.append(finding) return findings, infos, errors, fails
2,829
39.428571
113
py
smartbugs
smartbugs-master/tools/mythril-0.23.15/scripts/do_bytecode.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for mythril to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="--execution-timeout $TO" fi /usr/local/bin/myth analyze $OPT_TIMEOUT -o json -f "$FILENAME"
300
19.066667
63
sh
smartbugs
smartbugs-master/tools/mythril-0.23.15/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for mythril to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="--execution-timeout $TO" fi /usr/local/bin/myth analyze $OPT_TIMEOUT -o json --bin-runtime -f "$FILENAME"
314
20
77
sh
smartbugs
smartbugs-master/tools/mythril-0.23.15/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" BIN="$3" MAIN="$4" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") OPT_CONTRACT="" if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then OPT_CONTRACT=":$CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for mythril to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="--execution-timeout $TO" fi /usr/local/bin/myth analyze $OPT_TIMEOUT -o json "$FILENAME$OPT_CONTRACT"
722
20.264706
73
sh
smartbugs
smartbugs-master/tools/mythril-0.23.15/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/mythril-0.23.5/config.yaml
name: Mythril version: 0.23.5 origin: https://github.com/ConsenSys/mythril info: Mythril analyses EVM bytecode using symbolic analysis, taint analysis and control flow checking to detect a variety of security vulnerabilities. image: smartbugs/mythril:0.23.5 bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN' '$MAIN'" solc: yes bytecode: entrypoint: "'$BIN/do_bytecode.sh' '$FILENAME' '$TIMEOUT'" runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'"
517
36
150
yaml
smartbugs
smartbugs-master/tools/mythril-0.23.5/findings.yaml
Delegatecall to user-supplied address (SWC 112): classification: SWC-112, DASP-10 method: Check for invocations of delegatecall to a user-supplied address. descr_short: The contract delegates execution to another contract with a user-supplied address. descr_long: The smart contract delegates execution to a user-supplied address. This could allow an attacker to execute arbitrary code in the context of this contract account and manipulate the state of the contract account or execute actions on its behalf. severity: high Dependence on predictable environment variable (SWC 116): classification: SWC-116, DASP-8 method: Check whether control flow decisions are influenced by block.coinbase, block.gaslimit, block.timestamp or block.number. descr_short: A control flow decision is made based on the block variable coinbase, gaslimit, timestamp or block number. descr_long: One or more of block.coinbase, block.gaslimit, block.timestamp or block.number are used to determine a control flow decision. Note that the values of these variables are predictable and can be manipulated by a malicious miner. Also keep in mind that attackers know hashes of earlier blocks. Don't use any of those environment variables as sources of randomness and be aware that use of these variables introduces a certain level of trust into miners. severity: low Dependence on predictable environment variable (SWC 120): classification: SWC-120, DASP-6 method: Check whether control flow decisions are influenced by block.coinbase, block.gaslimit, block.timestamp or block.number. descr_short: A control flow decision is made based on the block variable coinbase, gaslimit, timestamp or block number. descr_long: One or more of block.coinbase, block.gaslimit, block.timestamp or block.number are used to determine a control flow decision. Note that the values of these variables are predictable and can be manipulated by a malicious miner. Also keep in mind that attackers know hashes of earlier blocks. Don't use any of those environment variables as sources of randomness and be aware that use of these variables introduces a certain level of trust into miners. severity: low Dependence on tx.origin (SWC 115): classification: SWC-115, DASP-2 method: Check whether control flow decisions are influenced by tx.origin descr_long: The tx.origin environment variable has been found to influence a control flow decision. Note that using tx.origin as a security control might cause a situation where a user inadvertently authorizes a smart contract to perform an action on their behalf. It is recommended to use msg.sender instead. severity: low descr_short: Use of tx.origin as a part of authorization control. Exception State (SWC 110): classification: SWC-110, DASP-10 method: Checks whether any exception states are reachable. descr_long: It is possible to trigger an assertion violation. Note that Solidity assert() statements should only be used to check invariants. Review the transaction trace generated for this issue and either make sure your program logic is correct, or use require() instead of assert() if your goal is to constrain user inputs or enforce preconditions. Remember to validate inputs from both callers (for instance, via passed arguments) and callees (for instance, via return values). severity: medium descr_short: An assertion violation was triggered. External Call To User-Supplied Address (SWC 107): classification: SWC-107, DASP-5 method: Search for external calls with unrestricted gas to a user-specified address. descr_short: A call to a user-supplied address is executed. descr_long: An external message call to an address specified by the caller is executed. Note that the callee account might contain arbitrary code and could re-enter any function within this contract. Reentering the contract in an intermediate state may lead to unexpected behaviour. Make sure that no state modifications are executed after this call and/or reentrancy guards are in place. severity: low Integer Arithmetic Bugs (SWC 101): classification: SWC-101, DASP-3 method: For every SUB instruction, check if there is a possible state where the second operand is larger than the first one. For every ADD, MUL instruction, check if there is a possible state where the result of the operation overflows. descr_short: The arithmetic operator can underflow/overflow descr_long: It is possible to cause an integer overflow or underflow in the arithmetic operation. Prevent this by constraining inputs using the require() statement or use the OpenZeppelin SafeMath library for integer arithmetic operations. Refer to the transaction trace generated for this issue to reproduce the issue. severity: high Jump to an arbitrary instruction (SWC 127): classification: SWC-127, DASP-10 method: Search for jumps to arbitrary locations in the bytecode severity: high descr_short: The caller can redirect execution to arbitrary bytecode locations. descr_long: It is possible to redirect the control flow to arbitrary locations in the code. This may allow an attacker to bypass security controls or manipulate the business logic of the smart contract. Avoid using low-level-operations and assembly to prevent this issue. Multiple Calls in a Single Transaction (SWC 113): classification: SWC-113, DASP-5 method: Check for multiple sends in a single transaction descr_long: This call is executed following another call within the same transaction. It is possible that the call never gets executed if a prior call fails permanently. This might be caused intentionally by a malicious callee. If possible, refactor the code such that each transaction only executes one external call or make sure that all callees can be trusted (i.e. they’re part of your own codebase). severity: low descr_short: Multiple calls are executed in the same transaction. State access after external call (SWC 107): classification: SWC-107, DASP-1 method: Check whether the account state is accesses after the execution of an external call severity: medium if user defined address, low if fixed address descr_short: Read of/Write to persistent state following external call descr_long: The contract account state is accessed after an external call to a user-defined/fixed address. To prevent reentrancy issues, consider accessing the state only before the call, especially if the callee is untrusted. Alternatively, a reentrancy lock can be used to prevent untrusted callees from re-entering the contract in an intermediate state. Unchecked return value from external call. (SWC 104): classification: SWC-104, DASP-4 method: Test whether CALL return value is checked. For direct calls, the Solidity compiler auto-generates this check. For low-level-calls this check is omitted. descr_long: External calls return a boolean value. If the callee halts with an exception, 'false' is returned and execution continues in the caller. The caller should check whether an exception happened and react accordingly to avoid unexpected behavior. For example it is often desirable to wrap external calls in require() so the transaction is reverted if the call fails. severity: medium descr_short: The return value of a message call is not checked. Unprotected Ether Withdrawal (SWC 105): classification: SWC-105, DASP-2 method: Search for cases where Ether can be withdrawn to a user-specified address. An issue is reported if there is a valid end state where the attacker has successfully increased their Ether balance. severity: high descr_short: Any sender can withdraw Ether from the contract account. descr_long: Arbitrary senders other than the contract creator can profitably extract Ether from the contract account. Verify the business logic carefully and make sure that appropriate security controls are in place to prevent unexpected loss of funds. Unprotected Selfdestruct (SWC 106): classification: SWC-106, DASP-2 method: Check if the contact can be 'accidentally' killed by anyone. For kill-able contracts, also check whether it is possible to direct the contract balance to the attacker. descr_short: Any sender can cause the contract to self-destruct. descr_long: Any sender can trigger execution of the SELFDESTRUCT instruction to destroy this contract account. Review the transaction trace generated for this issue and make sure that appropriate security controls are in place to prevent unrestricted access. severity: high Write to an arbitrary storage location (SWC 124): classification: SWC-124, DASP-2 method: Search for any writes to an arbitrary storage slot severity: high descr_short: The caller can write to arbitrary storage locations. descr_long: It is possible to write to arbitrary storage locations. By modifying the values of storage variables, attackers may bypass security controls or manipulate the business logic of the smart contract.
9,095
91.816327
485
yaml
smartbugs
smartbugs-master/tools/mythril-0.23.5/parser.py
import json import sb.parse_utils VERSION = "2023/01/20" FINDINGS = { "Jump to an arbitrary instruction (SWC 127)", "Write to an arbitrary storage location (SWC 124)", "Delegatecall to user-supplied address (SWC 112)", "Dependence on tx.origin (SWC 115)", "Dependence on predictable environment variable (SWC 116)", "Dependence on predictable environment variable (SWC 120)", "Unprotected Ether Withdrawal (SWC 105)", "Exception State (SWC 110)", "External Call To User-Supplied Address (SWC 107)", "Integer Arithmetic Bugs (SWC 101)", "Multiple Calls in a Single Transaction (SWC 113)", "State access after external call (SWC 107)", "Unprotected Selfdestruct (SWC 106)", "Unchecked return value from external call. (SWC 104)", } def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) errors.discard("EXIT_CODE_1") # exit code = 1 just means that a weakness has been found # Mythril catches all exceptions, prints a message "please report", and then prints the traceback. # So we consider all exceptions as fails (= non-intended interruptions) for f in list(fails): # iterate over a copy of 'fails' such that it can be modified if f.startswith("exception (mythril.laser.ethereum.transaction.transaction_models.TransactionEndSignal"): fails.remove(f) fails.add("exception (mythril.laser.ethereum.transaction.transaction_models.TransactionEndSignal)") for line in log: if "Exception occurred, aborting analysis." in line: infos.add("analysis incomplete") if not fails and not errors: fails.add("execution failed") break try: result = json.loads(log[-1]) except: result = None if result: error = result.get("error") if error: errors.add(error.split('.')[0]) for issue in result.get("issues", []): finding = { "name": issue["title"] } for i,f in ( ("filename","filename"), ("contract","contract"), ("function","function"), ("address","address"), ("lineno", "line"), ("tx_sequence","exploit"), ("description","message"), ("severity","severity") ): if i in issue: finding[f] = issue[i] if "swc-id" in issue: finding["name"] += f" (SWC {issue['swc-id']})" classification = f"Classification: SWC-{issue['swc-id']}" if finding.get("message"): finding["message"] += f"\n{classification}" else: finding["message"] = classification findings.append(finding) return findings, infos, errors, fails
2,829
39.428571
113
py
smartbugs
smartbugs-master/tools/mythril-0.23.5/scripts/do_bytecode.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for mythril to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="--execution-timeout $TO" fi /usr/local/bin/myth analyze $OPT_TIMEOUT -o json -f "$FILENAME"
300
19.066667
63
sh
smartbugs
smartbugs-master/tools/mythril-0.23.5/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for mythril to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="--execution-timeout $TO" fi /usr/local/bin/myth analyze $OPT_TIMEOUT -o json --bin-runtime -f "$FILENAME"
314
20
77
sh
smartbugs
smartbugs-master/tools/mythril-0.23.5/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" BIN="$3" MAIN="$4" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") OPT_CONTRACT="" if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then OPT_CONTRACT=":$CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for mythril to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="--execution-timeout $TO" fi /usr/local/bin/myth analyze $OPT_TIMEOUT -o json "$FILENAME$OPT_CONTRACT"
722
20.264706
73
sh
smartbugs
smartbugs-master/tools/mythril-0.23.5/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/mythril/config.yaml
alias: - mythril-0.23.15
29
9
21
yaml
smartbugs
smartbugs-master/tools/osiris/config.yaml
name: Osiris version: "#d1ecc37" info: Osiris is an analysis tool to detect integer bugs in Ethereum smart contracts. Osiris is based on Oyente. origin: https://github.com/christoftorres/Osiris image: smartbugs/osiris:d1ecc37 bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN' '$MAIN'" solc: yes runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'"
412
33.416667
111
yaml
smartbugs
smartbugs-master/tools/osiris/findings.yaml
Callstack bug: classification: SWC-998, DASP-5 Concurrency bug: classification: SWC-114, DASP-7 Division bugs: classification: SWC-999, DASP-3 Modulo bugs: classification: SWC-999, DASP-3 Overflow bugs: classification: SWC-101, DASP-3 Reentrancy bug: classification: SWC-107, DASP-1 Signedness bugs: classification: SWC-999, DASP-3 Time dependency bug: classification: SWC-116, DASP-8 Timedependency bug: classification: SWC-116, DASP-8 Truncation bugs: classification: SWC-999, DASP-3 Underflow bugs: classification: SWC-101, DASP-3
578
24.173913
35
yaml
smartbugs
smartbugs-master/tools/osiris/parser.py
import tools.oyente.parser as oyente VERSION = oyente.VERSION FINDINGS = { # "Arithmetic bugs", # redundant, a sub-category will be reported anyway "Overflow bugs", "Underflow bugs", "Division bugs", "Modulo bugs", "Truncation bugs", "Signedness bugs", "Callstack bug", "Concurrency bug", "Timedependency bug", "Time dependency bug", "Reentrancy bug", } def parse(exit_code, log, output): return oyente.parse(exit_code, log, output)
487
21.181818
75
py
smartbugs
smartbugs-master/tools/osiris/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for osiris to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="-glt $TO" fi python osiris/osiris.py $OPT_TIMEOUT -b -s "$FILENAME"
275
17.4
54
sh
smartbugs
smartbugs-master/tools/osiris/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" BIN="$3" MAIN="$4" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") OPT_CONTRACT="" if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then OPT_CONTRACT="--contract $CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for osiris to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="-glt $TO" fi python osiris/osiris.py $OPT_TIMEOUT -s "$FILENAME" $OPT_CONTRACT
709
19.882353
66
sh
smartbugs
smartbugs-master/tools/osiris/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/oyente/config.yaml
name: Oyente version: "#480e725" origin: https://github.com/smartbugs/oyente info: Oyente runs on symbolic execution, determines which inputs cause which program branches to execute, to find potential security vulnerabilities. Oyente works directly with EVM bytecode without access high level representation and does not provide soundness nor completeness. image: smartbugs/oyente:480e725 bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN' '$MAIN'" solc: yes runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'"
575
47
279
yaml
smartbugs
smartbugs-master/tools/oyente/findings.yaml
Callstack Depth Attack Vulnerability: classification: SWC-998, DASP-5 Integer Overflow: classification: SWC-101, DASP-3 Integer Underflow: classification: SWC-101, DASP-3 Parity Multisig Bug 2: {} Re-Entrancy Vulnerability: classification: SWC-107, DASP-1 Timestamp Dependency: classification: SWC-116, DASP-8 Transaction-Ordering Dependence (TOD): classification: SWC-114, DASP-7
405
28
38
yaml
smartbugs
smartbugs-master/tools/oyente/parser.py
import re import sb.parse_utils VERSION = "2023/02/27" FINDINGS = { "Callstack Depth Attack Vulnerability", "Transaction-Ordering Dependence (TOD)", "Timestamp Dependency", "Re-Entrancy Vulnerability", "Integer Overflow", "Integer Underflow", "Parity Multisig Bug 2" } INFOS = ( re.compile("(incomplete push instruction) at [0-9]+"), ) # ERRORS also for Osiris and Honeybadger ERRORS = ( re.compile("!!! (SYMBOLIC EXECUTION TIMEOUT) !!!"), re.compile("(UNKNOWN INSTRUCTION: .*)"), re.compile("CRITICAL:root:(Solidity compilation failed)"), ) FAILS = ( # re.compile("(Unexpected error: .*)"), # Secondary error ) CONTRACT = re.compile("^INFO:root:[Cc]ontract ([^:]*):([^:]*):") WEAKNESS = re.compile("^INFO:symExec:[\s└>]*([^:]*):\s*True") LOCATION1 = re.compile("^INFO:symExec:([^:]*):([0-9]+):([0-9]+):\s*([^:]*):\s*(.*)\.") # Oyente LOCATION2 = re.compile("^([^:]*):([^:]*):([0-9]+):([0-9]+)") # Osiris COMPLETED = re.compile("^INFO:symExec:\s*====== Analysis Completed ======") def is_relevant(line): # Identify lines interfering with exception parsing return not ( line.startswith("888") or line.startswith("`88b") or line.startswith("!!! ") or line.startswith("UNKNOWN INSTRUCTION:") ) def parse(exit_code, log, output): findings, infos = [], set() cleaned_log = filter(is_relevant, log) errors, fails = sb.parse_utils.errors_fails(exit_code, cleaned_log) errors.discard('EXIT_CODE_1') # redundant: indicates error or vulnerability reported below analysis_completed = False filename,contract,weakness = None,None,None weaknesses = set() for line in log: if sb.parse_utils.add_match(infos, line, INFOS): continue if sb.parse_utils.add_match(errors, line, ERRORS): continue if sb.parse_utils.add_match(fails, line, FAILS): continue m = CONTRACT.match(line) if m: filename, contract = m[1], m[2] analysis_completed = False continue m = WEAKNESS.match(line) if m: weakness = m[1] if weakness == "Arithmetic bugs": # Osiris: superfluous, will also report a sub-category continue weaknesses.add((filename,contract,weakness,None,None)) continue m = LOCATION1.match(line) if m: fn, lineno, column, severity, weakness = m[1], m[2], m[3], m[4], m[5] weaknesses.discard((filename,contract,weakness,None,None)) weaknesses.add((filename,contract,weakness,int(lineno),int(column))) continue m = LOCATION2.match(line) if m: fn, ct, lineno, column = m[1], m[2], m[3], m[4] assert fn == filename and ct == contract and weakness is not None weaknesses.discard((filename,contract,weakness,None,None)) weaknesses.add((filename,contract,weakness,int(lineno),int(column))) continue m = COMPLETED.match(line) if m: analysis_completed = True continue for filename,contract,weakness,lineno,column in sorted(weaknesses): finding = { "name": weakness } if filename: finding["filename"] = filename if contract: finding["contract"] = contract if lineno: finding["line"] = lineno if column: finding["column"] = column findings.append(finding) if log and not analysis_completed: infos.add('analysis incomplete') if not fails and not errors: fails.add('execution failed') # Remove errors/fails issued twice, once via exception and once via print statement # Reclassify symbolic execution timeouts, as they are informative rather than an error if "SYMBOLIC EXECUTION TIMEOUT" in errors and "exception (Exception: timeout)" in fails: fails.remove("exception (Exception: timeout)") #if "exception (Exception: timeout)" in fails: # infos.add("exception (Exception: timeout)") for e in list(fails): # list() makes a copy, so we can modify the set in the loop if "UNKNOWN INSTRUCTION" in e: fails.remove(e) if not e[22:-1] in errors: errors.add(e) return findings, infos, errors, fails
4,378
33.480315
95
py
smartbugs
smartbugs-master/tools/oyente/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for Oyente to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="-glt $TO" fi cd /oyente /oyente/oyente/oyente.py $OPT_TIMEOUT -b -s "$FILENAME"
287
17
55
sh
smartbugs
smartbugs-master/tools/oyente/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" BIN="$3" MAIN="$4" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") OPT_CONTRACT="" if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then OPT_CONTRACT="--target-contracts $CONTRACT" else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi OPT_TIMEOUT="" if [ "$TIMEOUT" -gt 0 ]; then # TO = TIMEOUT * 80% # the remaining 20% are for Oyente to finish TO=$(( (TIMEOUT*8+9)/10 )) OPT_TIMEOUT="-glt $TO" fi cd /oyente /oyente/oyente/oyente.py $OPT_TIMEOUT -s "$FILENAME" $OPT_CONTRACT
728
19.828571
66
sh
smartbugs
smartbugs-master/tools/oyente/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/pakala/config.yaml
name: Pakala origin: https://github.com/palkeo/pakala version: "#c84ef38 v1.1.10" info: Pakala is a tool to search for exploitable bugs in Ethereum smart contracts and a symbolic execution engine for the Ethereum Virtual Machine. image: smartbugs/pakala:1.1.10 runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$TIMEOUT'" bin: scripts
349
37.888889
147
yaml
smartbugs
smartbugs-master/tools/pakala/findings.yaml
call bug: classification: SWC-105, DASP-2 delegatecall bug: classification: SWC-112, DASP-10 selfdestruct bug: classification: SWC-105, DASP-2
155
21.285714
36
yaml
smartbugs
smartbugs-master/tools/pakala/parser.py
import re, ast import sb.parse_utils VERSION = "2023/02/27" FINDINGS = { "delegatecall bug", "selfdestruct bug", "call bug" } FINDING = re.compile(".*pakala\.analyzer\[.*\] INFO Found (.* bug)\.") COVERAGE = re.compile("Symbolic execution finished with coverage (.*).") FINISHED = re.compile("Nothing to report.|======> Bug found! Need .* transactions. <======") TRANSACTION = re.compile("Transaction [0-9]+, example solution:") def is_relevant(line): return not ( line.startswith("Analyzing contract at") or line.startswith("Starting symbolic execution step...") or line.startswith("Symbolic execution finished with coverage") or line.startswith("Outcomes: ") ) def parse(exit_code, log, output): findings, infos = [], set() cleaned_log = filter(is_relevant, log) errors, fails = sb.parse_utils.errors_fails(exit_code, cleaned_log) errors.discard("EXIT_CODE_1") # there will be an exception in fails anyway analysis_completed = False in_tx = False for line in log: if in_tx: if line: tx_dict += line else: in_tx = False try: tx = ast.literal_eval(tx_dict) if not "exploit" in finding: finding["exploit"] = [] finding["exploit"].append(tx) except Exception: pass m = TRANSACTION.match(line) if m: in_tx = True tx_dict = "" continue m = FINDING.match(line) if m: finding = { "name": m[1] } findings.append(finding) continue if FINISHED.match(line): analysis_completed = True if log and not analysis_completed: infos.add("analysis incomplete") if not fails and not errors: fails.add("execution failed") return findings, infos, errors, fails
1,993
28.761194
92
py
smartbugs
smartbugs-master/tools/pakala/docker/scripts/runPakala.sh
#!/bin/sh FILENAME="$1" geth --dev --http --http.api eth,web3,personal,net & sleep 2 export WEB3_PROVIDER_URI="http://127.0.0.1:8545" cat "$FILENAME" | pakala - --exec-timeout 1500 --analysis-timeout 300
207
19.8
69
sh
smartbugs
smartbugs-master/tools/pakala/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" geth --dev --http --http.api eth,web3,personal,net & sleep 2 export WEB3_PROVIDER_URI="http://127.0.0.1:8545" if [ "$TIMEOUT" -eq 0 ]; then cat "$FILENAME" | pakala - else # TO1 = TIMEOUT * 80% # TO2 = TIMEOUT * 17% TO1=$(( TIMEOUT*8/10 )) TO2=$(( TIMEOUT*17/100 )) cat "$FILENAME" | pakala - --exec-timeout ${TO1} --analysis-timeout ${TO2} fi
408
20.526316
78
sh
smartbugs
smartbugs-master/tools/securify/config.yaml
name: Securify origin: https://github.com/eth-sri/securify info: Securify uses formal verification, also relying on static analysis checks. Securify's analysis consists of two steps. First, it symbolically analyzes the contract's dependency graph to extract precise semantic information from the code. Then, it checks compliance and violation patterns that capture sufficient conditions for proving if a property holds or not. image: smartbugs/security:usolc # includes solc 0.5.11, but we don't need it #image: smartbugs/securify:0.4.25 # includes solc 0.4.24, but we don't need it output: /results/ bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$BIN'" solc: yes runtime: entrypoint: "'$BIN/do_runtime.sh' '$FILENAME' '$BIN'"
764
57.846154
367
yaml
smartbugs
smartbugs-master/tools/securify/findings.yaml
DAO: classification: SWC-107, DASP-1 DAOConstantGas: classification: SWC-107, DASP-1 MissingInputValidation: classification: SWC-0, DASP-3 TODAmount: classification: SWC-114, DASP-7 TODReceiver: classification: SWC-114, DASP-7 TODTransfer: classification: SWC-114, DASP-7 UnhandledException: classification: SWC-104, DASP-4 UnrestrictedEtherFlow: classification: SWC-105, DASP-2
411
23.235294
35
yaml
smartbugs
smartbugs-master/tools/securify/parser.py
import json, io, tarfile import sb.parse_utils VERSION = "2022/11/17" FINDINGS = { "DAO", "DAOConstantGas", "MissingInputValidation", "TODAmount", "TODReceiver", "TODTransfer", "UnhandledException", "UnrestrictedEtherFlow" } def parse(exit_code, log, output): findings, infos = set(), set() errors, fails = sb.parse_utils.errors_fails(exit_code, log, log_expected=False) if fails: errors.discard("EXIT_CODE_1") # We look for the output in the following places, in that order: # - log (=stdout+stderr) # - output:results/results.json # - output:results/live.json try: try: analysis = json.loads(log) except: with io.BytesIO(output) as o, tarfile.open(fileobj=o) as tar: try: jsn = tar.extractfile("results/results.json").read() analysis = json.loads(jsn) except: jsn = tar.extractfile("results/live.json").read() analysis = json.loads(jsn) except Exception: analysis = {} if not analysis: infos.add("analysis incomplete") elif "patternResults" in analysis: # live.json if "finished" in analysis and not analysis["finished"]: infos.add("analysis incomplete") if "decompiled" in analysis and not analysis["decompiled"]: errors.add("decompilation error") for vuln,check in analysis["patternResults"].items(): if not check["completed"]: infos.add("analysis incomplete") if check["hasViolations"]: findings.add(vuln) else: # log or result.json for contract,analysis in analysis.items(): for vuln,check in analysis["results"].items(): if check["violations"]: findings.add(vuln) if "analysis incomplete" in infos and not fails: fails.add("execution failed") findings = [ { "name": vuln } for vuln in findings ] return findings, infos, errors, fails
2,086
30.621212
83
py
smartbugs
smartbugs-master/tools/securify/scripts/do_runtime.sh
#!/bin/sh FILENAME="$1" BIN="$2" mkdir /results java -Xmx16G -jar /securify_jar/securify.jar --livestatusfile /results/live.json --output /results/results.json -fh "$FILENAME"
178
21.375
127
sh
smartbugs
smartbugs-master/tools/securify/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" BIN="$2" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" mkdir /results java -Xmx16G -jar /securify_jar/securify.jar --livestatusfile /results/live.json --output /results/results.json -fs "$FILENAME"
225
19.545455
127
sh
smartbugs
smartbugs-master/tools/sfuzz/config.yaml
name: sFuzz version: #48934c0 (2019-03-01) info: An Efficient Adaptive Fuzzer for Solidity Smart Contracts origin: https://github.com/duytai/sFuzz image: smartbugs/sfuzz:48934c0 solidity: command: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN' '$MAIN'" output: /home/contracts bin: scripts solc: yes
323
26
74
yaml
smartbugs
smartbugs-master/tools/sfuzz/findings.yaml
Block Number Dependency: classification: SWC-120, DASP-6 severity: Low Dangerous Delegate Call: classification: SWC-106, DASP-2 Exception Disorder: classification: SWC-104, DASP-4 Freezing Ether: classification: SWC-997, DASP-5 Gasless Send: classification: SWC-134, DASP-10 Integer Overflow: classification: SWC-101, DASP-3 severity: High Integer Underflow: classification: SWC-101, DASP-3 severity: High Reentrancy: classification: SWC-107, DASP-1 severity: High Timestamp Dependency: classification: SWC-116, DASP-8
587
17.967742
36
yaml
smartbugs
smartbugs-master/tools/sfuzz/parser.py
import io import json import os import re import tarfile import sb.parse_utils VERSION = "2023/03/02" FINDINGS = { "Block Number Dependency", "Dangerous Delegate Call", "Exception Disorder", "Freezing Ether", "Gasless Send", "Integer Overflow", "Integer Underflow", "Reentrancy", "Timestamp Dependency" } STATS_FILENAME = "stats.csv" def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) if output: try: # file structure: # stats: contracts/<contract_name>.sol:<contract_name>/stats.csv # vulnerabilities: contracts/<contract_name>.sol:<contract_name>/<finding_name>.json with io.BytesIO(output) as o, tarfile.open(fileobj=o) as tar: for member in tar.getmembers(): if member.name.endswith(STATS_FILENAME): stats = tar.extractfile(member) vs = vulnerabilities(stats) for (name, filename) in vs.items(): v_member = tar.getmember(member.name.replace(STATS_FILENAME, filename)) v_json = json.load(tar.extractfile(v_member)) for function in v_json["functions"]: finding = { "contract": member.name.split(os.path.sep)[1].split(":")[0], "name": name, "function": function["name"] } findings.append(finding) except Exception as e: print(e) fails.add(f"error parsing results: {e}") return findings, infos, errors, fails def vulnerabilities(stats): vs = {} # Skip to last line line = "" for line in stats: pass if line == "": return vs last = re.sub('[\'b\\n]', '', line.decode("utf-8")) results = list(map(float, last.split(","))) # Parse found vulnerabilities if len(results) != 53: return vs if results[-1] >= 1: vs["Integer Underflow"] = "integer_underflow.json" if results[-2] >= 1: vs["Integer Overflow"] = "integer_overflow.json" if results[-9] >= 1: vs["Freezing Ether"] = "freezing_ether.json" if results[-10] >= 1: vs["Dangerous Delegate Call"] = "dangerous_delegatecall.json" if results[-11] >= 1: vs["Block Number Dependency"] = "block_number_dependency.json" if results[-12] >= 1: vs["Timestamp Dependency"] = "timestamp_dependency.json" if results[-13] >= 1: vs["Reentrancy"] = "reentrancy.json" if results[-14] >= 1: vs["Exception Disorder"] = "exception_disorder.json" if results[-15] >= 1: vs["Gasless Send"] = "gasless_send.json" return vs
2,940
30.623656
99
py
smartbugs
smartbugs-master/tools/sfuzz/scripts/do_solidity.sh
#!/bin/bash FILENAME="$1" TIMEOUT="$2" BIN="$3" MAIN="$4" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" CONTRACT="${FILENAME%.sol}" CONTRACT="${CONTRACT##*/}" CONTRACTS=$(python3 "$BIN"/printContractNames.py "$FILENAME") COUNT=$(echo $CONTRACTS | wc -w) [ "$COUNT" -gt 0 ] || COUNT=1 if [ "$MAIN" -eq 1 ]; then if (echo "$CONTRACTS" | grep -q "$CONTRACT"); then CONTRACTS="$CONTRACT" COUNT=1 else echo "Contract '$CONTRACT' not found in $FILENAME" exit 127 fi fi mkdir -p /home/contracts for CONTRACT in $CONTRACTS; do echo "Extract contract $CONTRACT from $FILENAME" cp "$FILENAME" "/home/contracts/$CONTRACT.sol" done echo "Extracted $COUNT contract(s) from $FILENAME" # Fuzz each contract at least 10 seconds TO=$(((TIMEOUT - (2 * COUNT)) / COUNT)) if [ "$TIMEOUT" -eq 0 ] || [ $TO -lt 10 ]; then TO=120 fi cd /home/ && ./fuzzer -g -r 1 -d $TO && chmod +x fuzzMe && ./fuzzMe
938
20.837209
67
sh
smartbugs
smartbugs-master/tools/sfuzz/scripts/printContractNames.py
import sys, json from subprocess import PIPE, Popen filename = sys.argv[1] cmd = ["solc", "--standard-json", "--allow-paths", ".,/"] settings = { "optimizer": {"enabled": False}, "outputSelection": { "*": { "*": [ "evm.deployedBytecode" ], } }, } input_json = json.dumps( { "language": "Solidity", "sources": {filename: {"urls": [filename]}}, "settings": settings, } ) p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(bytes(input_json, "utf8")) out = stdout.decode("UTF-8") result = json.loads(out) for error in result.get("errors", []): if error["severity"] == "error": print(error["formattedMessage"]) sys.exit(1) contracts = result["contracts"][filename] for contract in contracts.keys(): if len(contracts[contract]["evm"]["deployedBytecode"]["object"]): print(contract)
915
25.941176
69
py
smartbugs
smartbugs-master/tools/slither/config.yaml
name: Slither origin: https://github.com/crytic/slither info: Slither is a Solidity static analysis framework written in Python 3. It runs a suite of vulnerability detectors and prints visual information about contract details. Slither enables developers to find vulnerabilities, enhance their code comphrehension, and quickly prototype custom analyses. image: smartbugs/slither output: /output.json bin: scripts solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN'" solc: yes
507
49.8
297
yaml
smartbugs
smartbugs-master/tools/slither/findings.yaml
abiencoderv2-array: {} arbitrary-send: classification: SWC-105, DASP-2 arbitrary-send-erc20: {} arbitrary-send-erc20-permit: {} arbitrary-send-eth: {} array-by-reference: {} assembly: classification: SWC-0, DASP-10 assert-state-change: {} backdoor: {} boolean-cst: {} boolean-equal: {} calls-loop: classification: SWC-113, DASP-5 complex-function: {} constable-states: classification: SWC-0, DASP-10 constant-function: classification: SWC-0, DASP-10 constant-function-asm: {} constant-function-state: {} controlled-array-length: {} controlled-delegatecall: classification: SWC-106, DASP-2 costly-loop: {} dead-code: {} delegatecall-loop: {} deprecated-standards: classification: SWC-0, DASP-10 divide-before-multiply: {} domain-separator-collision: {} enum-conversion: {} erc20-indexed: classification: SWC-0, DASP-10 erc20-interface: classification: SWC-0, DASP-10 erc721-interface: {} events-access: {} events-maths: {} external-function: classification: SWC-0, DASP-10 function-init-state: {} incorrect-equality: classification: SWC-0, DASP-10 incorrect-modifier: {} incorrect-shift: {} incorrect-unary: {} locked-ether: classification: SWC-997, DASP-5 low-level-calls: classification: SWC-104, DASP-4 mapping-deletion: {} missing-inheritance: {} missing-zero-check: {} msg-value-loop: {} multiple-constructors: {} name-reused: {} naming-convention: classification: SWC-0, DASP-10 pragma: classification: SWC-103, DASP-10 protected-vars: {} public-mappings-nested: {} redundant-statements: {} reentrancy-benign: classification: SWC-107, DASP-1 reentrancy-eth: classification: SWC-107, DASP-1 reentrancy-events: {} reentrancy-no-eth: classification: SWC-107, DASP-1 reentrancy-unlimited-gas: {} reused-constructor: {} rtlo: {} shadowing-abstract: classification: SWC-119, DASP-10 shadowing-builtin: classification: SWC-0, DASP-10 shadowing-local: classification: SWC-119, DASP-10 shadowing-state: classification: SWC-119, DASP-10 similar-names: {} solc-version: classification: SWC-102, DASP-10 storage-array: {} suicidal: classification: SWC-106, DASP-2 tautology: {} timestamp: classification: SWC-116, DASP-8 token-reentrancy: {} too-many-digits: {} tx-origin: classification: SWC-115, DASP-2 unchecked-lowlevel: {} unchecked-send: {} unchecked-transfer: {} unimplemented-functions: {} uninitialized-fptr-cst: {} uninitialized-local: classification: SWC-0, DASP-10 uninitialized-state: classification: SWC-109, DASP-10 uninitialized-storage: classification: SWC-109, DASP-10 unprotected-upgrade: {} unused-return: classification: SWC-104, DASP-4 unused-state: classification: SWC-131, DASP-10 variable-scope: {} void-cst: {} weak-prng: {} write-after-write: {}
2,790
22.854701
36
yaml
smartbugs
smartbugs-master/tools/slither/parser.py
import io, tarfile, json, re import sb.parse_utils VERSION = "2022/11/14" FINDINGS = { "abiencoderv2-array", "arbitrary-send", "arbitrary-send-erc20", "arbitrary-send-erc20-permit", "arbitrary-send-eth", "array-by-reference", "assembly", "assert-state-change", "backdoor", "boolean-cst", "boolean-equal", "calls-loop", "complex-function", "constable-states", "constant-function", "constant-function-asm", "constant-function-state", "controlled-array-length", "controlled-delegatecall", "costly-loop", "dead-code", "delegatecall-loop", "deprecated-standards", "divide-before-multiply", "domain-separator-collision", "enum-conversion", "erc20-indexed", "erc20-interface", "erc721-interface", "events-access", "events-maths", "external-function", "function-init-state", "incorrect-equality", "incorrect-modifier", "incorrect-shift", "incorrect-unary", "locked-ether", "low-level-calls", "mapping-deletion", "missing-inheritance", "missing-zero-check", "msg-value-loop", "multiple-constructors", "name-reused", "naming-convention", "pragma", "protected-vars", "public-mappings-nested", "redundant-statements", "reentrancy-benign", "reentrancy-eth", "reentrancy-events", "reentrancy-no-eth", "reentrancy-unlimited-gas", "reused-constructor", "rtlo", "shadowing-abstract", "shadowing-builtin", "shadowing-local", "shadowing-state", "similar-names", "solc-version", "storage-array", "suicidal", "tautology", "timestamp", "token-reentrancy", "too-many-digits", "tx-origin", "unchecked-lowlevel", "unchecked-send", "unchecked-transfer", "unimplemented-functions", "uninitialized-fptr-cst", "uninitialized-local", "uninitialized-state", "uninitialized-storage", "unprotected-upgrade", "unused-return", "unused-state", "variable-scope", "void-cst", "weak-prng", "write-after-write", } LOCATION = re.compile("/sb/(.*?)#([0-9-]*)") def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) #for line in log: # pass try: with io.BytesIO(output) as o, tarfile.open(fileobj=o) as tar: output_json = tar.extractfile("output.json").read() issues = json.loads(output_json) except Exception as e: fails.add(f"error parsing results: {e}") issues = {} for issue in issues: finding = {} for i,f in ( ("check", "name"), ("impact", "impact" ), ("confidence", "confidence"), ("description", "message")): finding[f] = issue[i] elements = issue.get("elements",[]) m = LOCATION.search(finding["message"]) finding["message"] = finding["message"].replace("/sb/","") if m: finding["filename"] = m[1] if "-" in m[2]: start,end = m[2].split("-") finding["line"] = int(start) finding["line_end"] = int(end) else: finding["line"] = int(m[2]) elif len(elements) > 0 and "source_mapping" in elements[0]: source_mapping = elements[0]["source_mapping"] lines = sorted(source_mapping["lines"]) if len(lines) > 0: finding["line"] = lines[0] if len(lines) > 1: finding["line_end"] = lines[-1] finding["filename"] = source_mapping["filename"] for element in elements: if element.get("type") == "function": finding["function"] = element["name"] finding["contract"] = element["contract"]["name"] break findings.append(finding) return findings, infos, errors, fails
3,971
26.776224
70
py
smartbugs
smartbugs-master/tools/slither/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" TIMEOUT="$2" BIN="$3" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" slither "$FILENAME" --json /output.json
135
11.363636
39
sh
smartbugs
smartbugs-master/tools/smartcheck/config.yaml
name: Smartcheck origin: https://github.com/smartdec/smartcheck info: Securify automatically checks for vulnerabilities and bad coding practices. It runs lexical and syntactical analysis on Solidity source code. solidity: image: smartbugs/smartcheck entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$BIN'" solc: yes bin: scripts
344
37.333333
147
yaml
smartbugs
smartbugs-master/tools/smartcheck/findings.yaml
SOLIDITY_ADDRESS_HARDCODED: classification: SWC-0, DASP-10 SOLIDITY_ARRAY_LENGTH_MANIPULATION: classification: SWC-0, DASP-10 SOLIDITY_BALANCE_EQUALITY: classification: SWC-132, DASP-10 SOLIDITY_BYTE_ARRAY_INSTEAD_BYTES: {} SOLIDITY_CALL_WITHOUT_DATA: classification: SWC-0, DASP-10 SOLIDITY_CONSTRUCTOR_RETURN: classification: SWC-0, DASP-10 SOLIDITY_DELETE_ON_DYNAMIC_ARRAYS: {} SOLIDITY_DEPRECATED_CONSTRUCTIONS: classification: SWC-111, DASP-10 SOLIDITY_DIV_MUL: classification: SWC-0, DASP-10 SOLIDITY_DOS_WITH_THROW: {} SOLIDITY_DO_WHILE_CONTINUE: classification: SWC-0, DASP-10 SOLIDITY_ERC20_APPROVE: classification: SWC-0, DASP-10 SOLIDITY_ERC20_FUNCTIONS_ALWAYS_RETURN_FALSE: classification: SWC-0, DASP-10 SOLIDITY_ERC20_INDEXED: {} SOLIDITY_ERC20_TRANSFER_SHOULD_THROW: classification: SWC-0, DASP-10 SOLIDITY_EXACT_TIME: classification: SWC-116, DASP-8 SOLIDITY_EXTRA_GAS_IN_LOOPS: classification: SWC-0, DASP-10 SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN: classification: SWC-0, DASP-10 SOLIDITY_FUNCTION_RETURNS_TYPE_AND_NO_RETURN: {} SOLIDITY_GAS_LIMIT_IN_LOOPS: classification: SWC-132, DASP-10 SOLIDITY_INCORRECT_BLOCKHASH: classification: SWC-0, DASP-10 SOLIDITY_LOCKED_MONEY: classification: SWC-997, DASP-5 SOLIDITY_MSGVALUE_EQUALS_ZERO: classification: SWC-0, DASP-10 SOLIDITY_OVERPOWERED_ROLE: classification: SWC-0, DASP-10 SOLIDITY_PRAGMAS_VERSION: classification: SWC-103, DASP-10 SOLIDITY_PRIVATE_MODIFIER_DOES_NOT_HIDE_DATA: {} SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA: classification: SWC-0, DASP-10 SOLIDITY_REDUNDANT_FALLBACK_REJECT: classification: SWC-0, DASP-10 SOLIDITY_REVERT_REQUIRE: classification: SWC-0, DASP-10 SOLIDITY_REWRITE_ON_ASSEMBLY_CALL: {} SOLIDITY_SAFEMATH: classification: SWC-0, DASP-10 SOLIDITY_SEND: classification: SWC-0, DASP-10 SOLIDITY_SHOULD_NOT_BE_PURE: classification: SWC-0, DASP-10 SOLIDITY_SHOULD_NOT_BE_VIEW: classification: SWC-0, DASP-10 SOLIDITY_SHOULD_RETURN_STRUCT: classification: SWC-0, DASP-10 SOLIDITY_TRANSFER_IN_LOOP: classification: SWC-113, DASP-5 SOLIDITY_TX_ORIGIN: classification: SWC-115, DASP-2 SOLIDITY_UINT_CANT_BE_NEGATIVE: classification: SWC-0, DASP-10 SOLIDITY_UNCHECKED_CALL: classification: SWC-104, DASP-4 SOLIDITY_UNUSED_FUNCTION_SHOULD_BE_EXTERNAL: {} SOLIDITY_UPGRADE_TO_050: classification: SWC-0, DASP-10 SOLIDITY_USING_INLINE_ASSEMBLY: classification: SWC-0, DASP-10 SOLIDITY_VAR: classification: SWC-101, DASP-3 SOLIDITY_VAR_IN_LOOP_FOR: {} SOLIDITY_VISIBILITY: classification: SWC-100, DASP-10 SOLIDITY_WRONG_SIGNATURE: {}
2,671
31.192771
48
yaml
smartbugs
smartbugs-master/tools/smartcheck/parser.py
import sb.parse_utils VERSION = "2022/11/14" FINDINGS = { "SOLIDITY_ADDRESS_HARDCODED", "SOLIDITY_ARRAY_LENGTH_MANIPULATION", "SOLIDITY_BALANCE_EQUALITY", "SOLIDITY_BYTE_ARRAY_INSTEAD_BYTES", "SOLIDITY_CONSTRUCTOR_RETURN", "SOLIDITY_CALL_WITHOUT_DATA", "SOLIDITY_DELETE_ON_DYNAMIC_ARRAYS", "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "SOLIDITY_DIV_MUL", "SOLIDITY_DO_WHILE_CONTINUE", "SOLIDITY_DOS_WITH_THROW", "SOLIDITY_ERC20_APPROVE", "SOLIDITY_ERC20_FUNCTIONS_ALWAYS_RETURN_FALSE", "SOLIDITY_ERC20_INDEXED", "SOLIDITY_ERC20_TRANSFER_SHOULD_THROW", "SOLIDITY_EXACT_TIME", "SOLIDITY_EXTRA_GAS_IN_LOOPS", "SOLIDITY_FUNCTION_RETURNS_TYPE_AND_NO_RETURN", "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "SOLIDITY_GAS_LIMIT_IN_LOOPS", "SOLIDITY_INCORRECT_BLOCKHASH", "SOLIDITY_LOCKED_MONEY", "SOLIDITY_MSGVALUE_EQUALS_ZERO", "SOLIDITY_OVERPOWERED_ROLE", "SOLIDITY_PRAGMAS_VERSION", "SOLIDITY_PRIVATE_MODIFIER_DOES_NOT_HIDE_DATA", "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "SOLIDITY_REVERT_REQUIRE", "SOLIDITY_REWRITE_ON_ASSEMBLY_CALL", "SOLIDITY_SAFEMATH", "SOLIDITY_SEND", "SOLIDITY_SHOULD_NOT_BE_PURE", "SOLIDITY_SHOULD_NOT_BE_VIEW", "SOLIDITY_SHOULD_RETURN_STRUCT", "SOLIDITY_TRANSFER_IN_LOOP", "SOLIDITY_TX_ORIGIN", "SOLIDITY_UINT_CANT_BE_NEGATIVE", "SOLIDITY_UNCHECKED_CALL", "SOLIDITY_UNUSED_FUNCTION_SHOULD_BE_EXTERNAL", "SOLIDITY_UPGRADE_TO_050", "SOLIDITY_USING_INLINE_ASSEMBLY", "SOLIDITY_VAR", "SOLIDITY_VAR_IN_LOOP_FOR", "SOLIDITY_VISIBILITY", "SOLIDITY_WRONG_SIGNATURE", } def parse(exit_code, log, output): findings, infos = [], set() errors, fails = sb.parse_utils.errors_fails(exit_code, log) for line in log: i = line.find(": ") if i >= 0: k = line[0:i].strip() v = line[i+2:].strip() if v.isdigit(): v = int(v) if k.endswith("ruleId"): finding = { "name": v } findings.append(finding) elif k in ("severity", "line", "column"): finding[k] = v return findings, infos, errors, fails
2,274
30.597222
63
py
smartbugs
smartbugs-master/tools/smartcheck/scripts/do_solidity.sh
#!/bin/sh FILENAME="$1" BIN="$2" export PATH="$BIN:$PATH" chmod +x "$BIN/solc" smartcheck -p "$FILENAME"
108
9.9
25
sh
smartbugs
smartbugs-master/tools/solhint-2.1.0/config.yaml
name: Solhint version: "2.1.0" origin: https://github.com/protofire/solhint info: Open source project for linting solidity code. This project provide both security and style guide validations. image: smartbugs/solhint solidity: entrypoint: "'$BIN/do_solidity.sh' '$FILENAME' '$TIMEOUT' '$BIN'" solc: yes bin: scripts
329
32
116
yaml