Package: karl
KarlA monitor for smart contracts that checks for security vulnerabilities.InstallGet latest version of Karl.$pipinstall--userkarlInstallGanachewithnpmif you want Karl to test the found vulnerabilities in a sandbox (--sandbox=true, disabled by default), to reduce false positives.$npmi-gganache-cliDescriptionKarl will allow you to monitor a blockchain for vulnerable smart contracts that are being deployed.It connects to the blockchain, monitors for new blocks and runsmythrilfor every new smart contract deployed.The output can be displayed in the console, saved in files in a folder or POSTed to a URL.Output can be:stdoutjust posting the results to standard outputfoldercreate a file for each vulnerable contract in a folderposturlPOST the results to an http endpointHelp message$karl--helpusage: karl [-h] [--rpc https://mainnet.infura.io/v3/12312312312312312312312312312312] [--rpc-tls RPC_TLS] [--block NUMBER] [--output Can be one of: stdout, posturl, folder][--posturl POSTURL] [--folder-output FOLDER_OUTPUT] [--sandbox SANDBOX] [--timeout SECONDS] [--loop-bound LOOP_BOUND] [--tx-count NUMBER][--modules [MODULES [MODULES ...]]] [--onchain-storage ONCHAIN_STORAGE] [--verbose] [--version]Smart contract monitor using Mythril to find exploitsoptional arguments:-h, --help            show this help message and exit--version             show program's version number and exitRPC options:--rpc https://mainnet.infura.io/v3/12312312312312312312312312312312Custom RPC settings (default: None)--rpc-tls RPC_TLS     RPC connection over TLS (default: False)--block NUMBER        Start from this block, otherwise start from latest (default: None)Output:--output Can be one of: stdout, posturl, folderWhere to send results (default: stdout)--posturl POSTURL     Send results to a RESTful url [when using `--output posturl`] (default: None)--folder-output FOLDER_OUTPUTSave files to this folder [when using `--output folder`] (default: None)Sandbox:--sandbox SANDBOX     Test found transactions in a Ganache sandbox (default: False)Scan options:--timeout SECONDS     Scan timeout per contract (default: 600)--loop-bound LOOP_BOUNDMaximum number of loop iterations (default: 3)--tx-count NUMBER     Maximum number of transactions (default: 3)--modules [MODULES [MODULES ...]]Modules to use for scanning (default: ['ether_thief', 'suicide'])--onchain-storage ONCHAIN_STORAGEWhether onchain access should be done or not (default: True)Verbosity:--verbose, -v         Set verbose (default: 4)ExamplesRunning against themainnet$karl--rpchttps://mainnet.infura.io/Stdout initializedRunningScraping block 6745471Scraping block 6745472Scraping block 6745473Analyzing 0xf8c065bB1DafC99eE5476a2b675FAC4a036a4B07Scraping block 6745474Analyzing 0xC9e044D76f211E84bA651b30BBA86758ca8017c7Scraping block 6745475Scraping block 6745476Scraping block 6745477Analyzing 0x19427b8FD32dfEc78393517Da416bC5C583E6065Running againstganachewithstdoutenabled$karl--rpchttp://localhost:8545--output=stdoutINFO:mythril.mythril:Using RPC settings: ('localhost', 8545, False)INFO:mythril.analysis.modules.suicide:Suicide module: Analyzing suicide instructionPOSSIBLE VULNERABILITY!Initial balance = 100000000000000000000, final balance = 100999999999999985722Type = VulnerabilityType.KILL_AND_WITHDRAWDescription = Looks line anyone can kill this contract and steal its balance.Transactions = [{'from': '0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e', 'to': '0x2F2B2FE9C08d39b1F1C22940a9850e2851F40f99', 'data': '0xcbf0b0c0bebebebebebebebebebebebe1dF62f291b2E969fB0849d99D9Ce41e2F137006e', 'value': 0}]Running againstganachewithposturlenabled$karl--rpc[ganache](http://localhost:8545)--output=posturl--posturl=http://localhost:8080Posturl initializedRunningScraping block 5Analyzing 0x4b8e80acaE3F0db32e5d35925EfaA97D477dBb70And it will send this to the listening service$nc-l8080POST / HTTP/1.1Accept-Encoding: identityContent-Type: application/x-www-form-urlencodedContent-Length: 725Host: localhost:8080User-Agent: Python-urllib/3.7Connection: close{"error": null,"issues": [{"address": 722,"contract": "0x4b8e80acaE3F0db32e5d35925EfaA97D477dBb70","debug": "Transaction Sequence: {'1': {'calldata': '0x56885cd8', 'call_value': '0x0', 'caller': '0xaaaaaaaabbbbbbbbbcccccccddddddddeeeeeeee'}, '4': {'calldata': '0x6c343ffe', 'call_value': '0x0', 'caller': '0xaaaaaaaabbbbbbbbbcccccccddddddddeeeeeeee'}}","description": "Arbitrary senders other than the contract creator can withdraw ETH from the contract account without previously having sent an equivalent amount of ETH to it. This is likely to be a vulnerability.","function": "withdrawfunds()","max_gas_used": 1749,"min_gas_used": 1138,"swc-id": "105","title": "Ether thief","type": "Warning"}],"success": true}Running against themainnetwithfolderoutput enabled$karl--rpckarl--rpchttps://mainnet.infura.io/--outputfolderDemoRunning locally with a specially crafted vulnerable contract:Running on the main net usingInfura:TroubleshootingOpenSSLIf you get this error#include <openssl/aes.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1You must install the openssl source code librariesUbuntu$sudoapt-getinstalllibssl-devCreditsThis tool is inspired byBernhard'sinitial prototyping and it heavily uses his projectMyth.