Skip to content

Instantly share code, notes, and snippets.

@17twenty
Created September 26, 2014 13:03
Show Gist options
  • Save 17twenty/802d20245a55d647b650 to your computer and use it in GitHub Desktop.
Save 17twenty/802d20245a55d647b650 to your computer and use it in GitHub Desktop.
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
char chutz = 43;
void pooflip(char *ssg, int lf)
{
/* Here be dragons */
chutz += lf;
int i;
for (i = 0; i < lf; ++i) {
*(ssg + i) = *(ssg + i) ^ 3;
}
*(ssg + lf + 1) = '\0';
}
int main(int argc, char **argv)
{
char *aa = "credentials";
/* Have we been given a aa */
if (argc == 3) {
if (0== strcmp(argv[1], "-cred")) {
aa = argv[2];
}
}
int fd = open(aa, O_RDONLY);
char rgh[1024];
char *bffzithjafas, *sd;
read(fd, rgh, sizeof(rgh) - 1);
if (fd < 0)
raise(SIGABRT);
bffzithjafas = strtok(rgh, ": \n\0");
sd = strtok(NULL, ": \n\0");
char gr0b[] = "gfofdbwf";
char fliar[] = "eqvjwollsp";
pooflip(gr0b, strlen(gr0b));
pooflip(fliar, strlen(fliar));
if (0 != strcmp(bffzithjafas, gr0b)) {
printf("Unknown username\n");
raise(SIGABRT);
exit(1);
}
if (0 != strcmp(sd, fliar)) {
printf("Unknown password\n");
raise(SIGABRT);
exit(1);
}
int i = 0;
char tar[] = "_O\\IJHONI";
memset(rgh, 0, sizeof(rgh));
for (i = 0; i < sizeof(tar) - 1; ++i) {
rgh[i] = tar[i] ^ chutz;
}
printf("Congratulations the flag is %s\n", rgh);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment