{"id":18964334,"url":"https://github.com/xf97/bian","last_synced_at":"2025-04-19T12:50:22.519Z","repository":{"id":108435606,"uuid":"257159282","full_name":"xf97/BiAn","owner":"xf97","description":"BiAn is a code obfuscation tool for Solidity smart contracts (APSEC 2020).","archived":false,"fork":false,"pushed_at":"2020-09-16T03:22:13.000Z","size":1848,"stargazers_count":76,"open_issues_count":2,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T08:02:59.410Z","etag":null,"topics":["obfus","solidity"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xf97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-20T03:16:10.000Z","updated_at":"2025-03-17T07:13:59.000Z","dependencies_parsed_at":"2023-04-11T17:02:32.733Z","dependency_job_id":null,"html_url":"https://github.com/xf97/BiAn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xf97%2FBiAn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xf97%2FBiAn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xf97%2FBiAn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xf97%2FBiAn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xf97","download_url":"https://codeload.github.com/xf97/BiAn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249201117,"owners_count":21229004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["obfus","solidity"],"created_at":"2024-11-08T14:23:48.832Z","updated_at":"2025-04-19T12:50:22.513Z","avatar_url":"https://github.com/xf97.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BiAn(狴犴)\n![logo](BiAnLogo.png)\n\n**BiAn** is a source code level code obfuscation tool developed for Solidity smart contracts. We will obfuscate the Solidity smart contract from the following three aspects:\n+ **Layout obfuscation**. \n+ **Data flow obfuscation**. \n+ **Control flow obfuscation**. This aspect will be developed by the project collaborator *ZhangMeng*.\n\n## Usage\nEnter the following instructions in the terminal (eg., ubuntu os):\n```\ngit clone https://github.com/xf97/BiAn\ncd BiAn/src\npython main.py yourContract.sol yourContract.sol's_json.ast\n```\nand you're done.\n\n## Feature completion status\nFeature completed:\n+ **Layout obfuscation**:\n    1. *Delete comments*.\n    2. *Disrupt the formatting*.\n    3. *Replace variable's name*.\n+ **Data flow obfuscation**.\n    1. *Convert local variables to state variables*. This feature is turned off by default, because changing local variables to state variables in *Solidity* may cause compile error in the *pure* or *view* function. User can manually modify the configuration file to turn up this feature.\n    2. *Dynamically generate static data*.\n    3. *Convert integer literals to arithmetic expressions*.\n    4. *Split boolean variables*.\n    5. *Scalar to vector*.\n\nThe configuration file (*Configuration.json*) is a json file, and users can turn on or off various features by modifying this file, and can specify the activation probability of each feature (this function is used to balance the degree of confusion and *gas* growth).\n\nThe following features' development has been stopped due to current restrictions. Uncompleted features:\n+ **Data flow obfuscation**.\n    1. *Collapse and merge arrays*.\n    2. *Split functions and contracts*.\n\n## An example\nUse **BiAn** (default configuration) to obfuscate the following contract.\nBefore obfuscation:\n![beforeConfuse](beforeConfuse.png)\n\nAfter confuscation:\n![afterConfuse](afterConfuse.png)\n\nThe obfuscated contract can still be compiled (no errors or warnings).\n\n## Input, output, and limitation\n**BiAn**'s input: solFile(.sol) and its corresponding jsonAstFile(.json_ast). Users can use the *solc* compiler to generate the corresponding *jsonAst* file.\n\n**BiAn**'s output: The contract after code obfuscation(.sol).\n\nLimited by our technical level, the number of currently available tools and test cases, **BiAn** still has the following limitations:\n1. **BiAn** cannot handle the solFile that contains multiple contracts.\n2. **BiAn** cannot handle contracts that generate warnings at compile time. We use the local compiler (*solc*) to compile a contract. If a warning is generated when compiling the contract, the local compiler (*solc*) does not output the compilation result, which leads to errors in the following obfuscation steps.\n3. **BiAn** may run abnormally when it confuses a contract. We welcome users to submit *bug* issues.\n\n## Possible use \nWe hope that **BiAn** can play a role in the following aspects:\n+ Enhance bug smart contracts.\n+ Protect the contract source code.\n\n## Open source code used in **BiAn**\nIn the *Convert Integer Literals to Arithmetic Expressions* and *Split boolean variables* function, I use the code from project *Auto-Generate-Expression* (contributed by @threeworld et al). Since our requirements do not exactly match the project *Auto-Generate-Expression*'s function, I rewrite some code.\n\n## License\nThis program is issued, reproduced or used under the permission of **MIT**. Please indicate the source when using.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxf97%2Fbian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxf97%2Fbian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxf97%2Fbian/lists"}