{"id":15045919,"url":"https://github.com/denoland/sui","last_synced_at":"2025-05-16T15:06:30.800Z","repository":{"id":237032256,"uuid":"793666606","full_name":"denoland/sui","owner":"denoland","description":"Embed custom RO data into precompiled executables","archived":false,"fork":false,"pushed_at":"2025-04-23T09:55:51.000Z","size":43790,"stargazers_count":104,"open_issues_count":5,"forks_count":7,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-11T04:27:24.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://littledivy.com/sui.html","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/denoland.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-29T16:36:13.000Z","updated_at":"2025-05-03T03:06:30.000Z","dependencies_parsed_at":"2024-09-22T21:04:22.507Z","dependency_job_id":"ce456eeb-524b-4a8a-8933-faffb956605c","html_url":"https://github.com/denoland/sui","commit_stats":{"total_commits":105,"total_committers":2,"mean_commits":52.5,"dds":0.00952380952380949,"last_synced_commit":"b827f5e639bf51bc26855512a8b4399076521aec"},"previous_names":["littledivy/sui","denoland/sui"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fsui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fsui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fsui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fsui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denoland","download_url":"https://codeload.github.com/denoland/sui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553960,"owners_count":22090417,"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":[],"created_at":"2024-09-24T20:52:27.874Z","updated_at":"2025-05-16T15:06:30.763Z","avatar_url":"https://github.com/denoland.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# `libsui`\n\n[![Crates.io](https://img.shields.io/crates/v/libsui.svg)](https://crates.io/crates/libsui)\n\n_Sui (सुई)_ is a injection tool for executable formats (ELF, PE, Mach-O) that\nallows you to embed files into existing binary and extract them at runtime.\n\nIt produces valid executables that can be code signed on macOS and Windows.\n\n[Documentation](https://docs.rs/libsui) | [Usage](cli.rs)\n\n## Usage\n\n```\ncargo add libsui\n```\n\nEmbedding data into binaries:\n\n```rust\nuse libsui::{Macho, PortableExecutable};\n\nlet exe = std::fs::read(\"tests/exec_mach64\")?;\nlet mut out = std::fs::File::create(\"out\")?;\n\nMacho::from(exe)?\n    .write_section(\"__hello\", b\"Hello, World!\".to_vec())?\n    .build(\u0026mut out)?;\n\nlet exe = std::fs::read(\"tests/exec_pe64\")?;\nlet mut out = std::fs::File::create(\"out.exe\")?;\n\nPortableExecutable::from(exe)?\n    .write_resource(\"hello.txt\", b\"Hello, World!\".to_vec())?\n    .build(\u0026mut out)?;\n```\n\nExtracting from self:\n\n```rust\nuse libsui::find_section;\n\nlet data = find_section(\"hello.txt\")?;\n```\n\n## Design\n\n### Mach-O\n\nResource is added as section in a new segment, load commands are updated and\noffsets are adjusted. `__LINKEDIT` is kept at the end of the file.\n\nIt is similar to linker's `-sectcreate,__FOO,__foo,hello.txt` option.\n\nNote that `Macho::build` will invalidate existing code signature. on Apple\nsillicon, kernel refuses to run executables with bad signatures.\n\nUse `Macho::build_and_sign` to re-sign the binary with ad-hoc signature. See\n[`apple_codesign.rs`](./apple_codesign.rs) for details. This is similar to\n`codesign -s - ./out` command.\n\n```rust\nMacho::from(exe)?\n    .write_section(\"__sect\", data)?\n    .build_and_sign(\u0026mut out)?;\n```\n\n```\n$ codesign -d -vvv ./out\n\nExecutable=/Users/divy/gh/sui/out\nIdentifier=a.out\nFormat=Mach-O thin (arm64)\nCodeDirectory v=20400 size=10238 flags=0x20002(adhoc,linker-signed) hashes=317+0 location=embedded\nHash type=sha256 size=32\nCandidateCDHash sha256=6b1abb20f2291dd9b0dbcd0659a918cb2d0e6b18\nCandidateCDHashFull sha256=6b1abb20f2291dd9b0dbcd0659a918cb2d0e6b1876153efa17f90dc8b3a8f177\nHash choices=sha256\nCMSDigest=6b1abb20f2291dd9b0dbcd0659a918cb2d0e6b1876153efa17f90dc8b3a8f177\nCMSDigestType=2\nCDHash=6b1abb20f2291dd9b0dbcd0659a918cb2d0e6b18\nSignature=adhoc\nInfo.plist=not bound\nTeamIdentifier=not set\nSealed Resources=none\nInternal requirements=none\n```\n\n### PE\n\nResource is added into a new PE resource directory as `RT_RCDATA` type and\nextracted using `FindResource` and `LoadResource` at run-time.\n\n### ELF\n\nData is simply appended to the end of the file and extracted from\n`current_exe()` at run-time.\n\nThis is subject to change and may use ELF linker notes (`PT_NOTE`) in the\nfuture.\n\n## Testing\n\nThis crate is fuzzed with LLVM's libFuzzer. See [fuzz/](fuzz/).\n\n`exec_*` executables in `tests/` are compiled from `tests/exec.rs`:\n```\nrustc exec.rs -o exec_elf64 --target x86_64-unknown-linux-gnu\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Fsui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenoland%2Fsui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Fsui/lists"}