Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void f() { printf("hello, world\n"); }
  4.  
  5. char prog[6];
  6. typedef void (*callable)();
  7.  
  8. int main() {
  9.         prog[0] = 0xe8;
  10.         *(int *)(prog+1) = ((char *)f)-((char *)(prog+5));
  11.         printf("%d\n", *(prog+1));
  12.         prog[5] = 0xc3;
  13.         ((callable)prog)();
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement