Upload files to 'tasks/cringe_random'
This commit is contained in:
parent
1561961242
commit
a8959c6760
2 changed files with 28 additions and 0 deletions
26
tasks/cringe_random/cringe_random.py
Normal file
26
tasks/cringe_random/cringe_random.py
Normal file
|
@ -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)
|
2
tasks/cringe_random/output.txt
Normal file
2
tasks/cringe_random/output.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
ctf{********************}
|
||||
[110, 557, 303, 18, 127, 615, 844, 924, 177, 541]
|
Loading…
Reference in a new issue