Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/print3m/c-to-shellcode
From C to binary shellcode converter.
https://github.com/print3m/c-to-shellcode
compiler gcc malware malware-development mingw python shellcode shellcode-development
Last synced: about 2 hours ago
JSON representation
From C to binary shellcode converter.
- Host: GitHub
- URL: https://github.com/print3m/c-to-shellcode
- Owner: Print3M
- Created: 2024-09-15T20:37:50.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-14T10:21:16.000Z (3 days ago)
- Last Synced: 2024-11-14T11:26:05.493Z (3 days ago)
- Topics: compiler, gcc, malware, malware-development, mingw, python, shellcode, shellcode-development
- Language: C
- Homepage:
- Size: 272 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# c-to-shellcode.py
It'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)
Dependencies:
- Python 3.x
- x86_64-w64-mingw32-gcc-win32
- ld![Screenshot: "c-to-shellcode.py" output](_img/img-01.png)
## Usage
1. Write something cool to `payload.c`
2. Execute: `python c-to-shellcode.py`
3. Look at the `bin/` directory:
- `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.
- `loader.exe` - loader with compiled shellcode. It really injects shellcode into memory and executes it just like real malware.
- `payload.bin` - raw standalone shellcode binary file.![Screenshot: "bin/" directory listing](_img/img-02.png)
## Caveats
- 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.
- Global variables are not available.
- Use `ALIGN_STACK()` macro directly before any WinAPI call! The 16-bytes stack alignment is required for WinAPI functions.
- Use `FUNC` macro before function header (except `start`):```c
FUNC int ExampleFunction() { ... }
```- All strings have to be stack based:
```c
int start(void) {
// Stack based string
char string[] = {'t', 'e', 's', 't', '\0'};
}
```