Last active
July 16, 2018 18:57
-
-
Save noureddin/c70f2a121be1c1da62f41f1a1b815dd0 to your computer and use it in GitHub Desktop.
using buffer overflow to loop
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
// prints the integers from 0 to 10 | |
// compile with zero optimizations (use no `-O` flags, or only `-O0`) | |
// works on ubuntu xenial with gcc 5.4.0 (changed the buffer line from the original to work) | |
// src: https://old.reddit.com/r/ProgrammerHumor/comments/7p9c25/printing_all_integers_from_0_to_10/ | |
#include <stdio.h> | |
int a[3][3][3][3][3] = {0}; | |
void magic() { | |
int buffer[8]; | |
buffer[14]-=72; | |
return; | |
} | |
int main() { | |
if ((*(*(*(*(2 + a)))))[2] > 10) { | |
return 0; | |
} | |
printf("%i\n", (*(*(*(*(2 + a)))))[2]); | |
(*(*(*(*(2 + a)))))[2]++; | |
magic(); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment