{"id":16054971,"url":"https://github.com/joaoviictorti/coffeeldr","last_synced_at":"2025-04-05T15:03:21.917Z","repository":{"id":257815329,"uuid":"869572833","full_name":"joaoviictorti/coffeeldr","owner":"joaoviictorti","description":"A COFF Loader written in Rust","archived":false,"fork":false,"pushed_at":"2025-03-29T01:24:03.000Z","size":124,"stargazers_count":63,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T01:35:23.307Z","etag":null,"topics":["coff","loader","redteam","rust","windows"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/coffeeldr","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/joaoviictorti.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}},"created_at":"2024-10-08T14:18:32.000Z","updated_at":"2025-03-29T01:24:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"24bd3c09-074e-4643-b210-585db254eef6","html_url":"https://github.com/joaoviictorti/coffeeldr","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"69788ac8b705483f9b5dbaa0db69fe99570d67d5"},"previous_names":["joaoviictorti/coffeeldr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoviictorti%2Fcoffeeldr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoviictorti%2Fcoffeeldr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoviictorti%2Fcoffeeldr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaoviictorti%2Fcoffeeldr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joaoviictorti","download_url":"https://codeload.github.com/joaoviictorti/coffeeldr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353729,"owners_count":20925329,"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":["coff","loader","redteam","rust","windows"],"created_at":"2024-10-09T02:05:07.404Z","updated_at":"2025-04-05T15:03:21.911Z","avatar_url":"https://github.com/joaoviictorti.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# coffeeldr 🦀 \n\n![Rust](https://img.shields.io/badge/made%20with-Rust-red)\n![crate](https://img.shields.io/crates/v/coffeeldr.svg)\n![docs](https://docs.rs/coffeeldr/badge.svg)\n![Forks](https://img.shields.io/github/forks/joaoviictorti/coffeeldr)\n![Stars](https://img.shields.io/github/stars/joaoviictorti/coffeeldr)\n![License](https://img.shields.io/github/license/joaoviictorti/coffeeldr)\n\n`coffeeldr` is a modern and lightweight COFF (Common Object File Format) loader for Windows written in Rust, designed to run COFF files on Windows. It supports both 32-bit and 64-bit architectures and allows you to load and execute COFF files from files or memory buffers with Rust’s safety and performance guarantees.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Loading from File](#loading-from-file)\n  - [Loading from Buffer](#loading-from-buffer)\n  - [Executing a COFF File](#executing-a-coff-file)\n- [CLI](#cli)\n  - [Input Processing in CLI](#input-processing-in-cli)\n- [Contributing to coffeeldr](#contributing-to-coffeeldr)\n- [References](#references)\n- [License](#license)\n\n## Features\n\n- ✅ Load COFF files from disk or in-memory buffers.\n- ✅ 32-bit and 64-bit support.\n- ✅ Memory management: Automatically adjusts memory protections to ensure execution (read, write, execute permissions).\n- ✅ Dynamic relocation handling.\n- ✅ Fully written in Rust with safety and performance in mind.\n- ✅ Easy CLI integration with flexible input handling.\n\n## Installation\n\nAdd `coffeeldr` to your project by updating your `Cargo.toml`:\n\n```powershell\ncargo add coffeeldr\n```\n\n## Usage\n\n### Loading from File\n\nTo load a COFF file from the filesystem:\n```rust\nuse coffeeldr::CoffeeLdr;\n\nlet mut loader = CoffeeLdr::new(\"path/to/coff_file.o\");\nmatch loader {\n    Ok(ldr) =\u003e {\n        println!(\"COFF successfully loaded from file!\");\n        // Execute the entry point or manipulate the COFF as needed\n    },\n    Err(e) =\u003e println!(\"Error loading COFF: {:?}\", e),\n}\n```\n\n### Loading from Buffer\n\nTo load a COFF from an in-memory buffer:\n```rust\nuse coffeeldr::CoffeeLdr;\n\nlet coff_data = include_bytes!(\"path/to/coff_file.o\");\nlet mut loader = CoffeeLdr::new(coff_data);\nmatch loader {\n    Ok(ldr) =\u003e {\n        println!(\"COFF successfully loaded from buffer!\");\n        // Execute the entry point or manipulate the COFF as needed\n    },\n    Err(e) =\u003e println!(\"Error loading COFF: {:?}\", e),\n}\n```\n\n### Executing a COFF File\n\nOnce the COFF file is loaded, you can execute it by specifying the entry point:\n```rust\nlet mut coffee = CoffeeLdr::new(\"path/to/coff_file.o\").unwrap();\ncoffee.run(\"entry_point_function_name\", None, None).unwrap();\n```\n\nThis method will search for the specified entry point and execute it.\n\n## CLI\n\n`coffeeldr` also provides a convenient CLI tool for interacting with COFF files directly from the command line.\n\nExample Command:\n```cmd\ncoffee.exe --bof path/to/coff_file.o --entrypoint go\n```\n\n### Input Processing in CLI\n\nThese are the types of parameters that the tool accepts for processing:\n\n- `/short:\u003cvalue\u003e`: Adds a short (`i16`) value.\n- `/int:\u003cvalue\u003e`: Adds an integer (`i32`) value.\n- `/str:\u003cvalue\u003e`: Adds a string.\n- `/wstr:\u003cvalue\u003e`: Adds a wide string.\n- `/bin:\u003cbase64-data\u003e`: Adds binary data decoded from `base64`.\n\nExample command using [`ntcreatethread.o`](https://github.com/trustedsec/CS-Remote-OPs-BOF/blob/main/Injection/ntcreatethread/ntcreatethread.x64.o):\n```cmd\ncoffee.exe --bof ntcreatethread.o --entrypoint go /int:4732 /bin:Y29mZmVlbGRy..\n```\n\nAnother example using [`dir.o`](https://github.com/trustedsec/CS-Situational-Awareness-BOF/blob/master/SA/dir/dir.x64.o):\n```cmd\ncoffee.exe --bof dir.o --entrypoint go /str:C:\\\n```\n\n### CLI Help\n\n```\nA COFF (Common Object File Format) loader written in Rust\n\nUsage: coffee.exe [OPTIONS] --bof \u003cBOF\u003e [INPUTS]...\n\nArguments:\n  [INPUTS]...  Multiple arguments in the format `/short:\u003cvalue\u003e`, `/int:\u003cvalue\u003e`, `/str:\u003cvalue\u003e`, `/wstr:\u003cvalue\u003e`, `/bin:\u003cbase64-data\u003e`\n\nOptions:\n  -b, --bof \u003cBOF\u003e                The command to be executed\n  -e, --entrypoint \u003cENTRYPOINT\u003e  Entrypoint to use in the execution [default: go]\n  -v, --verbose...               Verbose mode (-v, -vv, -vvv, etc.)\n  -h, --help                     Print help\n```\n\n## Contributing to coffeeldr\nTo contribute to **coffeeldr**, follow these steps:\n\n1. Fork this repository.\n2. Create a branch: `git checkout -b \u003cbranch_name\u003e`.\n3. Make your changes and commit them: `git commit -m '\u003ccommit_message\u003e'`.\n4. Push your changes to your branch: `git push origin \u003cbranch_name\u003e`.\n5. Create a pull request.\n\nAlternatively, consult the [GitHub documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests) on how to create a pull request.\n\n## References\n\n- \u003chttps://github.com/HavocFramework/Havoc\u003e\n- \u003chttps://otterhacker.github.io/Malware/CoffLoader.html\u003e\n- \u003chttps://github.com/trustedsec/COFFLoader\u003e\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](/LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaoviictorti%2Fcoffeeldr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaoviictorti%2Fcoffeeldr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaoviictorti%2Fcoffeeldr/lists"}