Skip to content

Instantly share code, notes, and snippets.

@lionaneesh
Created May 15, 2019 09:23
Show Gist options
  • Save lionaneesh/765b4e0ede17502a2a195d8a56527210 to your computer and use it in GitHub Desktop.
Save lionaneesh/765b4e0ede17502a2a195d8a56527210 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv){
FILE *fp = fopen("level10.pass", "r");
struct {char pass[20], msg_err[20];} pwfile = {{0}};
char ptr[0];
if(!fp || argc != 2)
return -1;
fread(pwfile.pass, 1, 20, fp);
pwfile.pass[19] = 0;
ptr[atoi(argv[1])] = 0;
fread(pwfile.msg_err, 1, 19, fp);
fclose(fp);
if(!strcmp(pwfile.pass, argv[1]))
execl("/bin/sh", "sh", 0);
else
puts(pwfile.msg_err);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment