Last active
July 3, 2017 21:29
-
-
Save cedriczirtacic/a58a224408e4e2fbf9593e3680a546e2 to your computer and use it in GitHub Desktop.
getting canaries https://medium.com/@cedriczirtacic/peque%C3%B1o-texto-canarios-en-el-stack-3ce23f6c033b
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
// gcc -O1 -fstack-protector-all -o main main.c | |
#include <stdio.h> | |
#include <linux/types.h> | |
#ifndef uint64_t | |
typedef unsigned long uint64_t; | |
#endif | |
uint64_t get_canary() { | |
uint64_t a; | |
__asm__( | |
"leaq 0x8(%%rsp), %0\n\t" | |
: "=r" (a) | |
); | |
printf("canary_address: %p\n", a); | |
return(a); | |
} | |
int main(int argc, char *argv[]) { | |
uint64_t *v = get_canary(); | |
return printf("canary_value: %p\n", *v); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment