Created
January 26, 2024 20:34
-
-
Save Sigmanificient/8f4c4f5547b15906fd958ab50e91b95f to your computer and use it in GitHub Desktop.
Stack 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> | |
static char *S[] = { "Hello ", "world!\n" }; | |
static | |
void print_me(int kek, const char p[static sizeof printf]) | |
{ | |
(void)p; | |
(**((void (**)(char *, char *)) | |
((&kek - sizeof kek) + 1))) | |
("%s", S[kek]); | |
} | |
__attribute__((constructor)) | |
int main(void) | |
{ | |
static int i = 0; | |
((int (*)(int, char *))(&print_me)) | |
(i++, (void *)&printf); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment