From a8959c67600a081f34279e8d70f61a1242dbbb50 Mon Sep 17 00:00:00 2001 From: dragonmuffin Date: Fri, 25 Aug 2023 14:51:08 +0000 Subject: [PATCH] Upload files to 'tasks/cringe_random' --- tasks/cringe_random/cringe_random.py | 26 ++++++++++++++++++++++++++ tasks/cringe_random/output.txt | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 tasks/cringe_random/cringe_random.py create mode 100644 tasks/cringe_random/output.txt diff --git a/tasks/cringe_random/cringe_random.py b/tasks/cringe_random/cringe_random.py new file mode 100644 index 0000000..bfda23c --- /dev/null +++ b/tasks/cringe_random/cringe_random.py @@ -0,0 +1,26 @@ +import random + +n = 10 +flag_len = 20 +state = [random.randint(0, (1 << n) - 1) for i in range(n)] +k = 0 + +def update_state(): + for i in range(n): + state.append(state[0]) + for j in range(1, n): + state[j] ^= ((state[0] >> j) & 1) << i + state.pop(0) + +def get_random(): + global k + if(k == n): + k = 0 + update_state() + k += 1 + return state[k - 1] + +flag='ctf{' + (''.join([chr(get_random() % 26 + ord('a')) for i in range(flag_len)])) + '}' +print(flag) +update_state() +print(state) diff --git a/tasks/cringe_random/output.txt b/tasks/cringe_random/output.txt new file mode 100644 index 0000000..ab30750 --- /dev/null +++ b/tasks/cringe_random/output.txt @@ -0,0 +1,2 @@ +ctf{********************} +[110, 557, 303, 18, 127, 615, 844, 924, 177, 541]