Added lost-seeds.
This commit is contained in:
parent
4aac4e04df
commit
edd0958a71
7 changed files with 54 additions and 0 deletions
1
lost-seeds/description.md
Normal file
1
lost-seeds/description.md
Normal 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
BIN
lost-seeds/encrypt
Executable file
Binary file not shown.
37
lost-seeds/encrypt.c
Normal file
37
lost-seeds/encrypt.c
Normal 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
1
lost-seeds/flag.in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
easyctf{r3ndom_numb3rs_m3an_n0thing_wh3n_y0u_can_brute_force!}
|
1
lost-seeds/flag.out
Normal file
1
lost-seeds/flag.out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
·2˙ÄEsĆJ<EFBFBD>ZA!‚÷WNľľ¤ŻlyjęŞđŹěťK±ĎsżĹ˘ä°±ě‰WťˇXbĎÇ…ŮGđ"2
|
4
lost-seeds/grader.py
Normal file
4
lost-seeds/grader.py
Normal 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
10
lost-seeds/problem.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
title: Lost Seed
|
||||||
|
author: mzhang
|
||||||
|
category: Cryptography
|
||||||
|
autogen: false
|
||||||
|
programming: false
|
||||||
|
value: 150
|
||||||
|
files:
|
||||||
|
- encrypt
|
||||||
|
- flag.out
|
||||||
|
|
Loading…
Reference in a new issue