Merge branch 'master' of github.com:failedxyz/easyctf

This commit is contained in:
Jacob Magnuson 2017-02-15 17:14:32 +00:00
commit 42d7c6646b
7 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1 @@
Every time I encrypt a flag with [this program](${encrypt}), it gives me [something different](${flag_out}).

BIN
lost-seeds/encrypt Executable file

Binary file not shown.

37
lost-seeds/encrypt.c Normal file
View file

@ -0,0 +1,37 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define RAND_MAX ((1U << 31) - 1)
#define MAXLENGTH 80
int realrand() {
int n;
FILE *fp = fopen("/dev/urandom", "r");
fread(&n, 4, 1, fp);
fclose(fp);
return n % MAXLENGTH;
}
int seed;
int pseudorand() {
return seed = (seed * 19394489 + 132241) & 0xff;
}
int main() {
char input[MAXLENGTH];
FILE *fp = fopen("flag.in", "r");
fread(&input, 1, MAXLENGTH, fp);
fclose(fp);
fp = fopen("flag.out", "wb");
seed = realrand();
int r;
char c;
for (int i = 0, l = strlen(input); i < l; ++i) {
c = ((char) input[i] ^ (r = pseudorand())) & 0xff;
fwrite(&c, 1, 1, fp);
}
fclose(fp);
}

1
lost-seeds/flag.in Normal file
View file

@ -0,0 +1 @@
easyctf{r3ndom_numb3rs_m3an_n0thing_wh3n_y0u_can_brute_force!}

1
lost-seeds/flag.out Normal file
View file

@ -0,0 +1 @@
·2˙ÄEsĆJ<EFBFBD>ZA!÷WNľľ¤ŻlyjęŞđŹěťK±ĎsżĹ˘ä°±ě‰WťˇXbĎÇ…ŮGđ"2

4
lost-seeds/grader.py Normal file
View file

@ -0,0 +1,4 @@
def grade(autogen, answer):
if answer.find("r3ndom_numb3rs_m3an_n0thing_wh3n_y0u_can_brute_force!") != -1:
return True, "Correct!"
return False, "Nope, try again."

10
lost-seeds/problem.yml Normal file
View file

@ -0,0 +1,10 @@
title: Lost Seed
author: mzhang
category: Cryptography
autogen: false
programming: false
value: 150
files:
- encrypt
- flag.out