Advertisement
raisep0wn

NDH 2k10 public wargame, level1

Apr 24th, 2011
422
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***********************************
  2. |            level1.c              |
  3. |  http://wargame.nuitduhack.com/  |
  4. |  http://www.nuitduhack.com/      |
  5. ***********************************/
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9.  
  10. void dummy()
  11. {
  12.         setresuid(geteuid(),geteuid(),geteuid());
  13.         system("sleep 1; cat /home/level2/passwd;");
  14.     exit(0);
  15. }
  16.  
  17. int *p;
  18. void func(char *arg)
  19. {
  20.         char buf[16];
  21.         p = (int *)&buf[sizeof(buf)];
  22.  
  23.     printf("dummy() is at: 0x%08x\n", dummy);
  24.         printf("before:   SEBP=%p\n\t  SEIP=0x%08x\n", *p, *(p+1));
  25.         strcpy(buf, arg);
  26.         printf("after:    SEBP=%p\n\t  SEIP=0x%08x\n", *p, *(p+1));
  27.  
  28. }
  29. int main(int argc, char *argv[])
  30. {
  31.         if(!argv[1]) {
  32.         printf("No command found...\n");
  33.         return;
  34.     }
  35.         func(argv[1]);
  36. }
Advertisement
RAW Paste Data Copied
Advertisement