mirror of
https://github.com/Print3M/epic
synced 2026-06-06 16:34:33 +00:00
Pedantic improvements
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# Project powered by EPIC
|
||||
|
||||
This project was built using **EPIC (Extensible Position Independent Code)** — a shellcode development and building toolkit designed for developer experience, predictability, and modularity. _Write code, EPIC will take care of the rest!_
|
||||
|
||||
- Repository & Docs: [github.com/Print3M/epic](https://github.com/Print3M/epic)
|
||||
|
||||
EPIC is a standalone binary toolkit:
|
||||
|
||||
- Latest EPIC Release: [github.com/Print3M/epic/releases/](https://github.com/Print3M/epic/releases/latest)
|
||||
|
||||
## Quick Start
|
||||
|
||||
Compile your project:
|
||||
|
||||
```bash
|
||||
epic pic-compile project/ -o output/
|
||||
```
|
||||
|
||||
Link and build the payload:
|
||||
|
||||
```bash
|
||||
epic pic-link output/ -o output/ -m hello
|
||||
```
|
||||
|
||||
That's it! You can now take the generated `payload.bin` and inject it into your custom shellcode loader, or simply:
|
||||
|
||||
```bash
|
||||
# Inject PIC payload and compile a simple loader template
|
||||
epic loader payload.bin -o output/
|
||||
```
|
||||
|
||||
The compiled `loader.exe` is ready to execute.
|
||||
|
||||
---
|
||||
|
||||
By [Print3M](https://x.com/Print3M_)
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
|
||||
extern void main_pic();
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
const char __attribute__((section(".start_addr"))) __pic_start[0] = {};
|
||||
const char __attribute__((section(".end_addr"))) __pic_end[0] = {};
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// This is the entry function of the payload
|
||||
EPIC_START void __main_pic() {
|
||||
@@ -29,7 +32,7 @@ EPIC_START void __main_pic() {
|
||||
|
||||
// Initializing CPU-based global context
|
||||
GlobalCtx ctx;
|
||||
SAVE_GLOBAL(ctx);
|
||||
SAVE_GLOBAL(&ctx);
|
||||
|
||||
// Getting context values
|
||||
ctx.pic_start = (void*)&__pic_start;
|
||||
|
||||
@@ -27,11 +27,13 @@
|
||||
// CPU-based global variable mechanism. Memory address is stored in a fixed CPU register.
|
||||
// Usage of this CPU register must be disabled at the compilation level so that our
|
||||
// "global" pointer is not overwritten.
|
||||
#define SAVE_GLOBAL(var) __asm__ volatile("mov %0, %%rbx" ::"r"(&var))
|
||||
#define GET_GLOBAL() \
|
||||
({ \
|
||||
void *__ret; \
|
||||
__asm__ volatile("mov %%rbx, %0" : "=r"(__ret)); \
|
||||
__ret; \
|
||||
})
|
||||
static inline void SAVE_GLOBAL(void *var) {
|
||||
__asm__ volatile("mov %0, %%rbx" ::"r"(var));
|
||||
}
|
||||
|
||||
static inline void *GET_GLOBAL() {
|
||||
void *__ret;
|
||||
__asm__ volatile("mov %%rbx, %0" : "=r"(__ret));
|
||||
|
||||
return __ret;
|
||||
}
|
||||
Reference in New Issue
Block a user