Created
June 16, 2019 14:17
-
-
Save saru2017/deeeb63772260d56a5113d42124f6dde to your computer and use it in GitHub Desktop.
CTF: pwn02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
FILE *fp; | |
char pass_stdin[32]; | |
char pass_file[32]; | |
int ret; | |
setvbuf(stdout, NULL, _IONBF, 0); | |
setvbuf(stdin, NULL, _IONBF, 0); | |
fp = fopen("flag.txt", "r"); | |
fgets(pass_file, 32, fp); | |
ret = strlen(pass_file); | |
pass_file[ret - 1] = 0; | |
fclose(fp); | |
puts("Welcome to Pwn02!!!"); | |
puts("password: "); | |
gets(pass_stdin); | |
if(strcmp(pass_file, pass_stdin) == 0){ | |
puts("login success!!!"); | |
system("/bin/sh"); | |
}else{ | |
puts("login failed\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment