Skip to content

Instantly share code, notes, and snippets.

@anandology
Last active August 29, 2015 14:02
Show Gist options
  • Save anandology/cdbb843b16404260e0b0 to your computer and use it in GitHub Desktop.
Save anandology/cdbb843b16404260e0b0 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void hack() {
int start = 0;
int *p=&start;
/* start moving up the stack until we find the marker. */
while (*p != 0x12345678)
p++;
/* set x to 3 */
p[-1] = 3;
}
int main() {
int marker = 0x12345678;
int x = 2;
int y = 2;
hack();
printf("%d\n", x+y);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment