- Ethereum-Contract similarity-measure evaluation framework.
- Includes test-data, similarity-measures and tools for exploration and evaluation.
For usage see ./runs/solcOptions/ and ./runs/wallets/, they contain sample test runs.
hash.ncd and hash.jumpHash pre-filtered with opfilter.highFStatPred appear to perform the best.
ncd is Normalized Compression Distance, it works best on unfiltered Codes.
opfilter.highFStatPred is based on the solc-version-testset
- OP-Codes with high f-statistic are selected.
- Same contracts compiled with different solc options and versions form the groups.
jumpHash is a chunk hash:
- Split by
JUMPIinto chunks. - Hash each chunk with
sha1. - Map the first byte to a unicode character.
- Concatenate the unicode characters to a hash-string.
- Compare the hash-strings via levenshtein.
- install python3
- This tool uses python venv.
- Basically the venv needs to be active before running code and not active when working with other python code.
- Install the modules listed in
requirements.txtinto thevenvviapip install -r requirements.txt.- pyLZJD is not available via pypi.org and needs to be installed separately
pip install git+https://github.com/EdwardRaff/pyLZJD#egg=pyLZJD - Alternatively run the commands in
./setup.batfrom windows cmd,./setup.ps1from powershell orsetup.shfrom bash to initialize the venv and install the required python modules.
- pyLZJD is not available via pypi.org and needs to be installed separately
- The runs are at
./runs/*/run.py - Simply run python3 with active
venvlike$ python3 runs/solcOptions/run.py - The results are stored at
./runs/*/out/*.
./data/Test data../runs/Individual test runs../src/The evaluation framework code.
./src/contract/: gsalzer/ethutils - EVM-Code definitions and decomposition../src/contract/fourbytes.py: Extract fourbyte signature../src/contract/fourbytes_tbl.py: Function Jump-table../src/contract/opcodes.py: EVM-OP-Codes definitions../src/contract/structure.py: Code decomposition and skeletonization.
./src/datasets/: Import datasets../src/datasets/proxies.py: Import proxies dataset from./data/proxies/../src/datasets/solcOptions.py: Import solcOptions dataset from./data/many-solc-versions/../src/datasets/wallets.py: Import wallets dataset from./data/wallets/.
./src/hashes/: Hash implementations../src/hashes/bz.py: BZ-Hash./src/hashes/jump.py: JUMP-Hash./src/hashes/ncd.py: Normalized Compression Distance./src/hashes/ppdeep.py: ssdeep in pure python../src/hashes/ppdeep_mod.py: Modified ssdeep.
./src/common.py: Type definitions../src/db.py: Read codes from DB as types defined incommon.py../src/hash.py: Exports all hashes implemented inhashes/../src/opfilter.py: OP-Code filter predicates../src/plot.py: Plot functions (scatter)../src/pre.py: Code pre-processing (skeleton,firstSection)./src/similarity.py: Exports all similarity-measures../src/test.py: Common test-run code (separationstatistic)../src/util.py: Common static functions (concurrentlist-precessing,allPairs)../src/vis.py: Code visualization (hex)../src/write.py: Save text files (saveCsv,saveGml).
./data/wallets/: Categorized wallet contracts../data/proxies/: Categorized proxy contracts../data/many-solc-versions/: solc-versions-testset - Ethereum contracts compiled with different solc versions and options
./runs/byteDistribution/: Calculates f-stat value for every OP-Code../runs/byteFiltersOnSolcVersions/: Evaluate OP-Codes filters../runs/bzHash/: Evaluate bzHash options../runs/fStatFilter/:opfilter.highFStatPredon two contracts../runs/lzjdParams/: Evaluatelzjdoptions../runs/many-solc-versions/: Compare many similarity measures using solc-versions-testset../runs/proxies/: Compare many similarity measures using./data/proxies/../runs/solcOptions/: Compare many similarity measures using solc-versions-testset../runs/wallets/: Compare many similarity measures using./data/wallets/.