{"id":20760452,"url":"https://github.com/print3m/c-to-shellcode","last_synced_at":"2025-04-30T05:48:11.366Z","repository":{"id":262800481,"uuid":"857875636","full_name":"Print3M/c-to-shellcode","owner":"Print3M","description":"From C to binary shellcode converter.","archived":false,"fork":false,"pushed_at":"2024-11-14T10:21:16.000Z","size":279,"stargazers_count":19,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T05:48:06.362Z","etag":null,"topics":["compiler","gcc","malware","malware-development","mingw","python","shellcode","shellcode-development"],"latest_commit_sha":null,"homepage":"","language":"C","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/Print3M.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":"2024-09-15T20:37:50.000Z","updated_at":"2025-04-27T02:24:18.000Z","dependencies_parsed_at":"2024-11-14T11:26:19.186Z","dependency_job_id":"68a7147c-3487-4f13-8a05-0409f796a488","html_url":"https://github.com/Print3M/c-to-shellcode","commit_stats":null,"previous_names":["print3m/c-to-shellcode"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Print3M%2Fc-to-shellcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Print3M%2Fc-to-shellcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Print3M%2Fc-to-shellcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Print3M%2Fc-to-shellcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Print3M","download_url":"https://codeload.github.com/Print3M/c-to-shellcode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251651220,"owners_count":21621702,"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":["compiler","gcc","malware","malware-development","mingw","python","shellcode","shellcode-development"],"created_at":"2024-11-17T10:13:40.932Z","updated_at":"2025-04-30T05:48:11.333Z","avatar_url":"https://github.com/Print3M.png","language":"C","readme":"# c-to-shellcode.py\n\nIt's a simple Python script to easily convert C code to shellcode (standalone binary machine code) with one command 👾🐚 Read more: [From C to shellcode](https://print3m.github.io/blog/from-c-to-shellcode)\n\nDependencies:\n\n- Python 3.x\n- x86_64-w64-mingw32-gcc-win32\n- ld\n\n![Screenshot: \"c-to-shellcode.py\" output](_img/img-01.png)\n\n## Usage\n\n1. Write something cool to `payload.c`\n2. Execute: `python c-to-shellcode.py`\n3. Look at the `bin/` directory:\n   - `payload.exe` - compiled C program (without shellcode conversion), so you can use libc and WinAPI functions directly, e.g. `printf()`. Great for debugging and fast development.\n   - `loader.exe` - loader with compiled shellcode. It really injects shellcode into memory and executes it just like real malware.\n   - `payload.bin` - raw standalone shellcode binary file.\n\n![Screenshot: \"bin/\" directory listing](_img/img-02.png)\n\n## Caveats\n\n- There's no external functions! No linkage to libc or win32. However, you are still able to include header files and use **macros** and **types** only. If you see linker errors during compilation then you are probably using some external functions. You have to implement everything on your own here.\n- Global variables are not available.\n- Use `ALIGN_STACK()` macro directly before any WinAPI call! The 16-bytes stack alignment is required for WinAPI functions.\n- Use `FUNC` macro before function header (except `start`):\n\n```c\nFUNC int ExampleFunction() { ... } \n```\n\n- All strings have to be stack based:\n\n```c\nint start(void) {\n    // Stack based string\n    char string[] = {'t', 'e', 's', 't', '\\0'};\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprint3m%2Fc-to-shellcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprint3m%2Fc-to-shellcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprint3m%2Fc-to-shellcode/lists"}