Advertisement
raisep0wn

NDH 2k10 public wargame, level4

Apr 24th, 2011
266
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***********************************
  2. |            level4.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. // gcc -o level4 level4.c -fno-stack-protector -z execstack -mpreferred-stack-boundary=2
  11.  
  12. int checkIdent(char *login, char *pwd)
  13. {
  14.     char buffer[8] = {'\0'};
  15.     int i;
  16.  
  17.     strcpy(buffer, login);
  18.     buffer[strlen("guest1")] = '\0';
  19.  
  20.     if(strcmp(buffer, "guest1"))
  21.         return 0;
  22.  
  23.     strcpy(buffer, pwd);
  24.     buffer[strlen("guest1")] = '\0';
  25.  
  26.     if(strcmp(buffer, "guest1"))
  27.         return 0;
  28.  
  29.     return 1;
  30. }
  31.  
  32. int main(int argc, char *argv[])
  33. {
  34.     if(argc != 3) {
  35.         printf("%s <login> <pass>\n", argv[0]);
  36.         exit(-1);
  37.     }
  38.  
  39.     if(checkIdent(argv[1], argv[2])) {
  40.         printf("Logged :)\n");
  41.         exit(1);
  42.     }
  43.  
  44.     printf("Oh noes\n");
  45.     return 0;
  46. }
Advertisement
RAW Paste Data Copied
Advertisement