{ "info": { "author": "ccyanxyz", "author_email": "ccyanxyz@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "## Ethct: Ethereum contract tool (command line)\n\n### 1. Now support:\n\n* Contract compiliation\n* Contract deployment\n* Contract function calls\n* Retrieve infomation from chain\n\n### 2. Install\n\nInstall solc on MacOS:\n\n```\nbrew tap ethereum/ethereum\nbrew install solidity\n```\n\nFor Linux/Windows, please refer to the [Solidity documentation](https://solidity.readthedocs.io/en/latest/installing-solidity.html#binary-packages).\n\nInstall ethct:\n\n```\npip install ethct\n```\n\n### 3. Usage\n\n1. Config the tool first:\n\n ```\n ethct --config --privkey --infurakey --network \n ```\n\n2. Compile a contract and save the output files:\n\n ```\n ethct --compile --save\n ```\n\n3. Deploy a contract on ropsten testnet:\n\n ```\n ethct --deploy --network --contract --args ' ...' --value \n ```\n\n4. Call contract function:\n\n ```\n ethct --address
--abi --call ' ...'\n ```\n\n If it's a payable function:\n\n ```\n ethct --address
--abi --call ' ... value:'\n ```\n\n If the ABI file can be found in the current 'build' directory, just give the contract name:\n\n ```\n ethct --address
--contract --call ' ...'\n ```\n\n5. Send raw transaction:\n\n ```\n ethct --sendtx --to
--value --data --nonce \n ```\n\n6. Get contract storage:\n\n ```\n ethct --getstorage
--position \n ```\n\n7. Get block:\n\n ```\n ethct --getblock /latest/earliest/pending/\n ```\n\n8. Get transaction:\n\n ```\n ethct --gettx \n ```\n\n9. Get balance:\n\n ```\n ethct --getbalance
\n ```\n\n10. Get nonce:\n\n ```\n ethct --getnonce
\n ```\n\n#### Example\n\nHere is an example on how to use ethct, the contract is from [Fuzzy Identity Challenge](https://capturetheether.com/challenges/accounts/fuzzy-identity/).\n\nHere is the challenge contract, your task is to set `isComplete` to `true`:\n\n```js\npragma solidity ^0.4.21;\n\ninterface IName {\n function name() external view returns (bytes32);\n}\n\ncontract FuzzyIdentityChallenge {\n bool public isComplete;\n\n function authenticate() public {\n require(isSmarx(msg.sender));\n require(isBadCode(msg.sender));\n\n isComplete = true;\n }\n\n function isSmarx(address addr) internal view returns (bool) {\n return IName(addr).name() == bytes32(\"smarx\");\n }\n\n function isBadCode(address _addr) internal pure returns (bool) {\n bytes20 addr = bytes20(_addr);\n bytes20 id = hex\"000000000000000000000000000000000badc0de\";\n bytes20 mask = hex\"000000000000000000000000000000000fffffff\";\n\n for (uint256 i = 0; i < 34; i++) {\n if (addr & mask == id) {\n return true;\n }\n mask <<= 4;\n id <<= 4;\n }\n\n return false;\n }\n}\n```\n\nThe only way to set `isComplete` to `true` is call the `authenticate` function, but with 2 restrictions:\n\n* The caller has to implement the `IName` interface, which means the caller has to be a contract.\n* The address of the caller must contains `badc0de`, we know that contract addresses are generated deterministically in Ethereum with the rightmost 160 bits of the keccak256 result of the sender address and nonce in RLP encoding. After a while of brute forcing, we can get a right private key and nonce. [Code](https://github.com/ccyanxyz/capturetheether/blob/master/fuzzy_identity.js).\n\nHere is our exploit contract:\n\n```js\npragma solidity ^0.4.21;\n\nimport \"./fuzzy_identity.sol\";\n\n/*\ninterface IName {\n\tfunction name() external view returns (string) {}\n}\n*/\n\ncontract returnSmarx is IName {\n\tfunction name() public view returns (bytes32) {\n\t\treturn bytes32(\"smarx\");\n\t}\n\n\tfunction exploit(address _addr) public {\n\t\tFuzzyIdentityChallenge c = FuzzyIdentityChallenge(_addr);\n\t\tc.authenticate();\n\t}\n}\n\ncontract returnAddress {\n\tfunction keccakHash(address _addr, uint8 nonce) public returns (address) {\n\t\treturn address(keccak256(0xd6, 0x94, _addr, nonce));\n\t}\n}\n```\n\nWe now have a private key `ca96819b848883b0694c8b284d55f1259849339e477e7d606f07ce0656fbe357` and a nonce value `6`, the associate address is `0xe09FBEFc7FfE44FB5E825Edd797dE0160e1d7B3B`, we need to use this account to deploy the exploit contract and call the `exploit` funtion.\n\nFirst, configure ethct with one of your own private keys:\n\n```\nethct --config --privkey \n```\n\nTransfer some ether to `0xe09FBEFc7FfE44FB5E825Edd797dE0160e1d7B3B`\n\n```\nethct --sendtx --to 0xe09FBEFc7FfE44FB5E825Edd797dE0160e1d7B3B --value 0.1\n```\n\nNow switch account:\n\n```\nethct --config --privkey ca96819b848883b0694c8b284d55f1259849339e477e7d606f07ce0656fbe357\n```\n\nDeploy `returnSmarx` contract:\n\n```\nethct --deploy ./fuzzy_identity_solver.sol --contract returnSmarx\n```\n\nNote that the nonce should be `6` to generate the correct contract address, you can just deploy the contract 6 times, and you can check the nonce of the address use the following command:\n\n```\nethct --getnonce 0xe09FBEFc7FfE44FB5E825Edd797dE0160e1d7B3B\n```\n\nNow we have successfully deployed the `returnSmarx` contract to address `0x433F86192F11A521261BAdC0dec67bf812360442` which contains `badc0de`.\n\nCall the `exploit` function of `returnSmarx` contract at `0x433F86192F11A521261BAdC0dec67bf812360442`:\n\n```\nethct --address 0x433F86192F11A521261BAdC0dec67bf812360442 --contract returnSmarx --call 'exploit 0xC56B60E8e91Dc1Bdf6231fb942cdbf5EAE74033C'\n```\n\nOr you can do it like this:\n\n```\nethct --address 0x433F86192F11A521261BAdC0dec67bf812360442 --abi ./build/returnSmarx.abi --call 'exploit 0xC56B60E8e91Dc1Bdf6231fb942cdbf5EAE74033C'\n```\n\nNow we can check if `isComplete` is set to `true` in the challenge contract at `0xC56B60E8e91Dc1Bdf6231fb942cdbf5EAE74033C`:\n\n```\nethct --getstorage 0xC56B60E8e91Dc1Bdf6231fb942cdbf5EAE74033C --position 0\n# result: 0x0000000000000000000000000000000000000000000000000000000000000001\n```\n\nAnd that's it, we just completed the Fuzzy Identity Challenge!\n\n### 4. Why build this\n\nTo make my life easier completing the [CaptureTheEther](https://capturetheether.com) challenges.\n\n![leaderboard](./imgs/leaderboard.png)\n\n
\n\n
", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ccyanxyz/ethct", "keywords": "ethereum contract command-line-tool", "license": "", "maintainer": "", "maintainer_email": "", "name": "ethct", "package_url": "https://pypi.org/project/ethct/", "platform": "", "project_url": "https://pypi.org/project/ethct/", "project_urls": { "Homepage": "https://github.com/ccyanxyz/ethct" }, "release_url": "https://pypi.org/project/ethct/19.11.3/", "requires_dist": null, "requires_python": "", "summary": "Ethereum contract tool(command line)", "version": "19.11.3", "yanked": false, "yanked_reason": null }, "last_serial": 6068476, "releases": { "19.10.25": [ { "comment_text": "", "digests": { "md5": "267e7056026a253ba5ca25e44dbf9b06", "sha256": "4f7aae8d7bee75628462d21e525b4faf5eccddf401b264354cd08174d016c681" }, "downloads": -1, "filename": "ethct-19.10.25-py3.6.egg", "has_sig": false, "md5_digest": "267e7056026a253ba5ca25e44dbf9b06", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 9220, "upload_time": "2019-10-25T12:06:45", "upload_time_iso_8601": "2019-10-25T12:06:45.435946Z", "url": "https://files.pythonhosted.org/packages/5a/a6/2f9df2c7fc360010ce94233723b00e4ce2da247c429e6ecf276879522dce/ethct-19.10.25-py3.6.egg", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "e620bbfdc93de40337170955fca12cf0", "sha256": "f1ad142a2e5b604bf7f8f93417d19d74d257d2e59a03466bea0e833ca5e86c1f" }, "downloads": -1, "filename": "ethct-19.10.25-py3-none-any.whl", "has_sig": false, "md5_digest": "e620bbfdc93de40337170955fca12cf0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4660, "upload_time": "2019-10-25T12:06:43", "upload_time_iso_8601": "2019-10-25T12:06:43.126473Z", "url": "https://files.pythonhosted.org/packages/09/e0/3975bf3eb0e31e1a4cebfe39cdc142650724a03395ce79c0003c9f49ddf6/ethct-19.10.25-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3f4b4e38ee54b6dd78b039d7def3df2d", "sha256": "cb371847c2a93c13298f3a9a91d66dd6cbeb1ec7806d33b78dcefd22f657af66" }, "downloads": -1, "filename": "ethct-19.10.25.tar.gz", "has_sig": false, "md5_digest": "3f4b4e38ee54b6dd78b039d7def3df2d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3539, "upload_time": "2019-10-25T12:06:46", "upload_time_iso_8601": "2019-10-25T12:06:46.853065Z", "url": "https://files.pythonhosted.org/packages/dc/c2/90246914f788724a8da9e70f173a65b42f167373f4331ae6df9df8934f53/ethct-19.10.25.tar.gz", "yanked": false, "yanked_reason": null } ], "19.10.31": [ { "comment_text": "", "digests": { "md5": "d71f381d24c55229a4a7de3f52154569", "sha256": "c6bf39a3340d57698ed545806a60b6802f930d1acc8f83893f1a602c78ed378e" }, "downloads": -1, "filename": "ethct-19.10.31-py3-none-any.whl", "has_sig": false, "md5_digest": "d71f381d24c55229a4a7de3f52154569", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4674, "upload_time": "2019-10-31T02:06:35", "upload_time_iso_8601": "2019-10-31T02:06:35.824739Z", "url": "https://files.pythonhosted.org/packages/fe/8f/f6a72b447335c127ac1de90778f3f75b50d6928097cf74d15751ee636a05/ethct-19.10.31-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3b222a5a267b529e88c33eb0e6fd4ac9", "sha256": "dbfdf3fb3b21cabc63b0b49c9b078c5f0f960e9ec8ad33616059c7b4a04af21f" }, "downloads": -1, "filename": "ethct-19.10.31.tar.gz", "has_sig": false, "md5_digest": "3b222a5a267b529e88c33eb0e6fd4ac9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3542, "upload_time": "2019-10-31T02:06:37", "upload_time_iso_8601": "2019-10-31T02:06:37.724184Z", "url": "https://files.pythonhosted.org/packages/82/21/26c68e63b817d46d7196ea723f6301487462f097fa9b4e76ae16bba8b440/ethct-19.10.31.tar.gz", "yanked": false, "yanked_reason": null } ], "19.10.31.2": [ { "comment_text": "", "digests": { "md5": "9b24e4146fb0052ef237fed2b682dcf4", "sha256": "b75563af5183e49ca61652ada515416bfc60574d6cc9a3f7dd0152558ced2c61" }, "downloads": -1, "filename": "ethct-19.10.31.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9b24e4146fb0052ef237fed2b682dcf4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4944, "upload_time": "2019-10-31T02:40:25", "upload_time_iso_8601": "2019-10-31T02:40:25.997170Z", "url": "https://files.pythonhosted.org/packages/96/db/0b40351c938e0757284df5f4c1199c791e566b8d9f2fbcfb72256bcc6c42/ethct-19.10.31.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "196b45c425d360f37130b7df85ee297e", "sha256": "c1e4bb6ff982c65fa2ccd133e90f5199b1b05c598bbdaaae593a1a9151bbbba9" }, "downloads": -1, "filename": "ethct-19.10.31.2.tar.gz", "has_sig": false, "md5_digest": "196b45c425d360f37130b7df85ee297e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3744, "upload_time": "2019-10-31T02:40:27", "upload_time_iso_8601": "2019-10-31T02:40:27.419719Z", "url": "https://files.pythonhosted.org/packages/ee/73/ba8d618113f497061abf340477712fb8505e5ae9876fb235feb61977f4b5/ethct-19.10.31.2.tar.gz", "yanked": false, "yanked_reason": null } ], "19.10.31.3": [ { "comment_text": "", "digests": { "md5": "686c7718f21c14baf4eed3776c7f02a5", "sha256": "c9a38b0e162b6b7f4811ed6807dcf59100036d57641f1e616b957f9008efa405" }, "downloads": -1, "filename": "ethct-19.10.31.3-py3-none-any.whl", "has_sig": false, "md5_digest": "686c7718f21c14baf4eed3776c7f02a5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4981, "upload_time": "2019-10-31T03:04:40", "upload_time_iso_8601": "2019-10-31T03:04:40.105008Z", "url": "https://files.pythonhosted.org/packages/57/b0/ebc38b16ee31d8c43d2777c61e628890a594d62e9e3a67f970d3fdfed294/ethct-19.10.31.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "8482c26274022ff48eac83865a925503", "sha256": "ba788d3088546e886350e668830a94b6997bf19dc9b2b3534c5ce6a8183d4499" }, "downloads": -1, "filename": "ethct-19.10.31.3.tar.gz", "has_sig": false, "md5_digest": "8482c26274022ff48eac83865a925503", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3782, "upload_time": "2019-10-31T03:04:43", "upload_time_iso_8601": "2019-10-31T03:04:43.099403Z", "url": "https://files.pythonhosted.org/packages/8a/b0/861275e15b8bc1113477ea1a2489fd4adf3bba43470b46d50008990e3726/ethct-19.10.31.3.tar.gz", "yanked": false, "yanked_reason": null } ], "19.10.31.4": [ { "comment_text": "", "digests": { "md5": "2c09a02ff56f2980104822de850b9d8e", "sha256": "1e65da7558bcaa6a6025f97c06d0f771b2470149788f982c05dc4525f6cdca9f" }, "downloads": -1, "filename": "ethct-19.10.31.4.tar.gz", "has_sig": false, "md5_digest": "2c09a02ff56f2980104822de850b9d8e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4598, "upload_time": "2019-10-31T03:31:43", "upload_time_iso_8601": "2019-10-31T03:31:43.673636Z", "url": "https://files.pythonhosted.org/packages/09/49/2fab0b3346663239365b0c2fed33f4d8a395576a31b07c71ee96160b1b9f/ethct-19.10.31.4.tar.gz", "yanked": false, "yanked_reason": null } ], "19.10.31.5": [ { "comment_text": "", "digests": { "md5": "6c9f5c392105c00af76f207e7c4f4a2f", "sha256": "8414cbbf757bf2d552071f99fc7916d0ff305194a8b2defaa01c680afd9eeb12" }, "downloads": -1, "filename": "ethct-19.10.31.5-py3-none-any.whl", "has_sig": false, "md5_digest": "6c9f5c392105c00af76f207e7c4f4a2f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5774, "upload_time": "2019-10-31T04:02:26", "upload_time_iso_8601": "2019-10-31T04:02:26.410090Z", "url": "https://files.pythonhosted.org/packages/f5/6b/5cb5cef0f1f19feb044010cce4bfcc2a5619d513fbfbc697217d564389ee/ethct-19.10.31.5-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a85234bf17e0692255de9354554d10f6", "sha256": "ba8c3e955131412859c1a339894a6486df617be27fbde23684d389a16f5ae07e" }, "downloads": -1, "filename": "ethct-19.10.31.5.tar.gz", "has_sig": false, "md5_digest": "a85234bf17e0692255de9354554d10f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4625, "upload_time": "2019-10-31T04:02:28", "upload_time_iso_8601": "2019-10-31T04:02:28.135007Z", "url": "https://files.pythonhosted.org/packages/1d/06/046018c69de648c1c3bd97a483cdfd7c446fbed4f0040539398dd44178f8/ethct-19.10.31.5.tar.gz", "yanked": false, "yanked_reason": null } ], "19.10.31.6": [ { "comment_text": "", "digests": { "md5": "25c8fcf2efea1adf0c251db3608cdcfb", "sha256": "c1e6b9ec4e52a833d12186a02a1a775672cfb164695efb4a8ed091e6548145a5" }, "downloads": -1, "filename": "ethct-19.10.31.6.tar.gz", "has_sig": false, "md5_digest": "25c8fcf2efea1adf0c251db3608cdcfb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5043, "upload_time": "2019-10-31T05:53:38", "upload_time_iso_8601": "2019-10-31T05:53:38.775509Z", "url": "https://files.pythonhosted.org/packages/41/57/6901810c937b78e2e0f107d204fea458e394c6629338c0f6d9fe96760299/ethct-19.10.31.6.tar.gz", "yanked": false, "yanked_reason": null } ], "19.11.1": [ { "comment_text": "", "digests": { "md5": "22208e11d9560d9fab354d34bdc5a26e", "sha256": "59d9fcf5dca52b1535943bb71573a2eaa6fc1e52a2e7edd630c081961f5c35a3" }, "downloads": -1, "filename": "ethct-19.11.1-py3-none-any.whl", "has_sig": false, "md5_digest": "22208e11d9560d9fab354d34bdc5a26e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6428, "upload_time": "2019-11-01T03:17:22", "upload_time_iso_8601": "2019-11-01T03:17:22.035712Z", "url": "https://files.pythonhosted.org/packages/a5/19/305255a2cb05c1481cfcf8ab35f9dc2730dbb4195a07e1ec76341baeaeb8/ethct-19.11.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "0969e0f5672732ecf102d0717e9e22f2", "sha256": "2d78e3924c6b8edc72b5c65f8b65d7059d73e319c17654ac70bc98e4d44f889e" }, "downloads": -1, "filename": "ethct-19.11.1.tar.gz", "has_sig": false, "md5_digest": "0969e0f5672732ecf102d0717e9e22f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5285, "upload_time": "2019-11-01T03:17:23", "upload_time_iso_8601": "2019-11-01T03:17:23.814073Z", "url": "https://files.pythonhosted.org/packages/c5/1d/830ccd17aea599200fa639bf1a649a0f6817a130db8315820df0a0002abc/ethct-19.11.1.tar.gz", "yanked": false, "yanked_reason": null } ], "19.11.3": [ { "comment_text": "", "digests": { "md5": "7115a3ed56dd947d8f1f868eb8fc145d", "sha256": "fdc974b0c72bd33cd214670adaadaf850109e49218c717bc577d332c764cf129" }, "downloads": -1, "filename": "ethct-19.11.3.tar.gz", "has_sig": false, "md5_digest": "7115a3ed56dd947d8f1f868eb8fc145d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7745, "upload_time": "2019-11-02T16:30:36", "upload_time_iso_8601": "2019-11-02T16:30:36.789336Z", "url": "https://files.pythonhosted.org/packages/e1/3e/f2a8969f16054064bb60584feccb6b605f07df9c5342419dc741591e52c9/ethct-19.11.3.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7115a3ed56dd947d8f1f868eb8fc145d", "sha256": "fdc974b0c72bd33cd214670adaadaf850109e49218c717bc577d332c764cf129" }, "downloads": -1, "filename": "ethct-19.11.3.tar.gz", "has_sig": false, "md5_digest": "7115a3ed56dd947d8f1f868eb8fc145d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7745, "upload_time": "2019-11-02T16:30:36", "upload_time_iso_8601": "2019-11-02T16:30:36.789336Z", "url": "https://files.pythonhosted.org/packages/e1/3e/f2a8969f16054064bb60584feccb6b605f07df9c5342419dc741591e52c9/ethct-19.11.3.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }