Skip to content

Instantly share code, notes, and snippets.

@saru2017
Created June 16, 2019 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saru2017/deeeb63772260d56a5113d42124f6dde to your computer and use it in GitHub Desktop.
Save saru2017/deeeb63772260d56a5113d42124f6dde to your computer and use it in GitHub Desktop.
CTF: pwn02
#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