-
-
Save invokethreatguy/6712cb8080d7fb1a5d63fa57aaa5c020 to your computer and use it in GitHub Desktop.
x86 Relative String Addressing Hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define DECLARE_STRING(var, str) __attribute__((section(".text"))) char var[] = "\xe8\x00\x00\x00\x00\x58\x83\xc0\x05\xc3" str; | |
#define REF_STRING(var) ((char*(*)())var)() | |
DECLARE_STRING(data1, "Hello, World!\n"); | |
DECLARE_STRING(data2, "Goodbye, World!\n"); | |
int main(int , char** ) | |
{ | |
printf("%s", REF_STRING(data1)); | |
printf("%s", REF_STRING(data2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment