{"id":13578134,"url":"https://github.com/dronavallipranav/rust-obfuscator","last_synced_at":"2025-04-05T16:31:56.998Z","repository":{"id":216422950,"uuid":"736769317","full_name":"dronavallipranav/rust-obfuscator","owner":"dronavallipranav","description":"Automatic Rust Obfuscator and Macro Library","archived":false,"fork":false,"pushed_at":"2024-03-12T04:03:05.000Z","size":77,"stargazers_count":189,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T10:06:46.433Z","etag":null,"topics":["automatic","compile-time","control-flow","encryption","macros","obfuscator","renaming","runtime","rust","source","string"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dronavallipranav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-12-28T20:31:20.000Z","updated_at":"2025-04-02T02:17:01.000Z","dependencies_parsed_at":"2024-03-12T05:24:06.309Z","dependency_job_id":"307436b3-dd25-485d-938c-a700d7c47a00","html_url":"https://github.com/dronavallipranav/rust-obfuscator","commit_stats":null,"previous_names":["dronavallipranav/rust-obfuscator"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dronavallipranav%2Frust-obfuscator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dronavallipranav%2Frust-obfuscator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dronavallipranav%2Frust-obfuscator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dronavallipranav%2Frust-obfuscator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dronavallipranav","download_url":"https://codeload.github.com/dronavallipranav/rust-obfuscator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247366364,"owners_count":20927499,"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":["automatic","compile-time","control-flow","encryption","macros","obfuscator","renaming","runtime","rust","source","string"],"created_at":"2024-08-01T15:01:27.784Z","updated_at":"2025-04-05T16:31:56.656Z","avatar_url":"https://github.com/dronavallipranav.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Rust-Obfuscator\n\n`rust-obfuscator` is a set of tools designed to automatically obfuscate Rust source code by inserting procedural macros or by (optionally) providing the obfuscation in the source code directly. For more fine-grained obfuscation a procedural macro library [cryptify](https://crates.io/crates/cryptify) is also provided.\n\n## Currently Supported\n1. string literal encryption\n2. control-flow obfuscation\n3. control-flow obfuscation (source code)\n4. variable renaming (source code)\n\n## Features\n\n- **String Encryption**: Automatically encrypts string literals assigned to local variables at compile time.\n    - Can also be used for formatted strings, but currently requires manual placement\n    ```rs\n        println!(\"{}\", cryptify::encrypt_string!(\"hello!\"));\n    ```\n- **Control Flow Obfuscation**: Introduces compile-dummy dummy loops and random variables.\n- **Customizable Obfuscation**: Offers flexibility to enable or disable specific obfuscation features based on your requirements.\n- **Variable Renaming**: Obfuscation of the source code directly, if you'd like to ship the code or just want to make your code look worse.\n\n## Installation\n\nAdd `cryptify` to your `Cargo.toml` as a dependency:\n\n```toml\n[dependencies]\ncryptify = \"3.1.1\"\n```\n\nTo install `rust-obfuscator`, clone the repository and build the tool using Cargo from the root:\n```\ncargo build --release --bin rust-obfuscator\n```\nThe binary can then be found under /target/release, you can copy it to the root of the project like such\n```\ncp ./target/release/rust-obfuscator .\n```\n\n# Usage\nSet the **CRYPTIFY_KEY** environment variable for custom encryption otherwise it defaults to defined fixed key\n- Add to source code you'd like to modify\n```rs\nuse cryptify;\n```\nThe binary can be used on either a file or a directory. If provided with a directory it will only modify rust source files within that directory not any subdirectories\n```sh\n./rust-obfuscator path/to/your_project \u003cOptions\u003e\n```\n- All Obfuscated code will be under the **obfuscated_code** directory that is created from the directory the tool was run.\n- **Recommended to use a Rust Formatter with the obfuscated code as syn naturally modifies the structure and it will be written to the file as one line**\n\n## Option Flags\n- --no_string: Disables string obfuscation.\n- --no_flow: Disables control flow obfuscation.\n- --disable_macro: Uses direct source manipulation for flow obfuscation instead of procedural macros.\n- --var: Enables variable renaming source code obfuscation.\n\n### Example usage with flag\n```sh\nrust-obfuscator path/to/your_project --no_flow \n```\n(disables flow obfuscation)\n\n# Input\n-running the tool with no config\n```rs\nuse cryptify;\nmod word_counter;\nuse std::env;\nuse std::fs;\nuse word_counter::count_words;\nfn main() {\n    let b = \"Hello World\";\n    println!(\"{}\", b);\n    let args: Vec\u003cString\u003e = env::args().collect();\n    if args.len() \u003c 2 {\n        eprintln!(\"Usage: {} \u003cfilename\u003e\", args[0]);\n        return;\n    }\n    let filename = \u0026args[1];\n    let content = fs::read_to_string(filename).expect(\"Could not read file\");\n    let word_counts = count_words(\u0026content);\n    for (word, count) in word_counts.iter() {\n        println!(\"{}: {}\", word, count);\n    }\n}\n\nfn dummy() {\n    let a = 1;\n    let b = 2;\n    let c = a + b;\n    println!(\"{}\", c);\n}\n\nfn calc_sum(a: i32, b: i32) -\u003e i32 {\n    cryptify::flow_stmt!();\n    let c = a + b;\n    c\n}\n\nfn helloooo(){\n    println!(\"hi\");\n}\n\n```\n# Output\n```rs\nfn main() {\n    cryptify::flow_stmt!();\n    let b = cryptify::encrypt_string!(\"Hello World\");\n    println!(\"{}\", b);\n    let args: Vec\u003cString\u003e = env::args().collect();\n    if args.len() \u003c 2 {\n        eprintln!(\"Usage: {} \u003cfilename\u003e\", args[0]);\n        return;\n    }\n    let filename = \u0026args[1];\n    let content = fs::read_to_string(filename).expect(\"Could not read file\");\n    let word_counts = count_words(\u0026content);\n    for (word, count) in word_counts.iter() {\n        println!(\"{}: {}\", word, count);\n    }\n}\nfn dummy() {\n    cryptify::flow_stmt!();\n    let a = 1;\n    let b = 2;\n    let c = a + b;\n    println!(\"{}\", c);\n}\nfn calc_sum(a: i32, b: i32) -\u003e i32 {\n    cryptify::flow_stmt!();\n    let c = a + b;\n    c\n}\nfn helloooo() {\n    println!(\"hi\");\n}\n```\n## Expanded Output\n```rs\nfn main() {\n    {\n        let _is_dummy_145 = true;\n        let _dummy_upper_bound = 100;\n        let _random_dummy_var = 1;\n        let mut _dummy_counter = 6i32;\n        let _dummy_increment = 2i32;\n        loop {\n            if _dummy_counter \u003e _dummy_upper_bound {\n                break;\n            }\n            unsafe {\n                std::ptr::write_volatile(\n                    \u0026mut _dummy_counter,\n                    _dummy_counter + _dummy_increment,\n                );\n            }\n        }\n    };\n    let b = cryptify::decrypt_string(\"0\\u{b}\\r\\u{1f}\\tFd\\u{18}\\u{11}\\t\\0\");\n    {\n        ::std::io::_print(format_args!(\"{0}\\n\", b));\n    };\n    let args: Vec\u003cString\u003e = env::args().collect();\n    if args.len() \u003c 2 {\n        {\n            ::std::io::_eprint(format_args!(\"Usage: {0} \u003cfilename\u003e\\n\", args[0]));\n        };\n        return;\n    }\n    let filename = \u0026args[1];\n    let content = fs::read_to_string(filename).expect(\"Could not read file\");\n    let word_counts = count_words(\u0026content);\n    for (word, count) in word_counts.iter() {\n        {\n            ::std::io::_print(format_args!(\"{0}: {1}\\n\", word, count));\n        };\n    }\n}\nfn dummy() {\n    {\n        let _is_dummy_145 = true;\n        let mut _dummy_counter = 4i32;\n        let _dummy_upper_bound = 100;\n        let _dummy_increment = 3i32;\n        loop {\n            if _dummy_counter \u003e _dummy_upper_bound {\n                break;\n            }\n            unsafe {\n                std::ptr::write_volatile(\n                    \u0026mut _dummy_counter,\n                    _dummy_counter + _dummy_increment,\n                );\n            }\n        }\n    };\n    let a = 1;\n    let b = 2;\n    let c = a + b;\n    {\n        ::std::io::_print(format_args!(\"{0}\\n\", c));\n    };\n}\nfn calc_sum(a: i32, b: i32) -\u003e i32 {\n    {\n        let _is_dummy_145 = true;\n        let mut _dummy_counter = 8i32;\n        let _dummy_increment = 3i32;\n        let _extra_dummy_var = 4i32;\n        let _dummy_upper_bound = 100;\n        loop {\n            if _dummy_counter \u003e _dummy_upper_bound {\n                break;\n            }\n            unsafe {\n                std::ptr::write_volatile(\n                    \u0026mut _dummy_counter,\n                    _dummy_counter + _dummy_increment,\n                );\n            }\n        }\n    };\n    let c = a + b;\n    c\n}\nfn helloooo() {\n    {\n        ::std::io::_print(format_args!(\"hi\\n\"));\n    };\n}\n```\n# License\nrust-obfuscator is licensed under the MIT License - see the [LICENSE](https://github.com/dronavallipranav/rust-obfuscator/blob/main/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdronavallipranav%2Frust-obfuscator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdronavallipranav%2Frust-obfuscator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdronavallipranav%2Frust-obfuscator/lists"}