Advertisement
parkdream1

level1.c

Apr 19th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. //gcc -o level1 level1.c -fno-stack-protector -z execstack -mpreferred-stack-boundary=2
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. void dummy()
  7. {
  8.         setresuid(geteuid(),geteuid(),geteuid());
  9.         system("sleep 1; cat /etc/shadow;");
  10.     exit(0);
  11. }
  12.  
  13. int *p;
  14. void func(char *arg)
  15. {
  16.         char buf[16];
  17.         p = (int *)&buf[sizeof(buf)];
  18.  
  19.     printf("dummy() is at: 0x%08x\n", dummy);
  20.         printf("before:   SEBP=%p\n\t  SEIP=0x%08x\n", *p, *(p+1));
  21.         strcpy(buf, arg);
  22.         printf("after:    SEBP=%p\n\t  SEIP=0x%08x\n", *p, *(p+1));
  23.  
  24. }
  25. int main(int argc, char *argv[])
  26. {
  27.         if(!argv[1]) {
  28.         printf("No command found...\n");
  29.         return;
  30.     }
  31.         func(argv[1]);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement