##`Night Coder`题解
题目地址:**https://ctf.bugku.com/challenges/detail/id/441.html**
题目大意:
-给了随机排列后的flag
-random种子是时间,提示当时是在2022年某个周四凌晨
```
import random
import datetime
from secret import flag
#Im a night coder, i coded this at night (thursday morning)
def seed_shuffler(my_list, seed):
random.seed(seed)
random.shuffle(my_list)
return my_list
seed=int(datetime.datetime.now().strftime('%Y%m%d%H%M'))
flag = [f for f in flag]
enc = seed_shuffler(flag,seed)
print("".join(enc))
#result at that time: "N_gs{aesD_he_3AtrsOLlh3ROT1sECRl0m}s"
```
做题思路:
-遍历2022年所有周四的凌晨0:00-6:00,求解flag
### 解题脚本:
```python
fromdatetimeimportdatetime, timedelta
importrandom
defseed_shuffler(my_list,seed):
random.seed(seed)
random.shuffle(my_list)
returnmy_list
definverse_seed_shuffler(shuffled,seed):
n=len(shuffled)
id=list(range(n))
id=seed_shuffler(id, seed)
m={id[i]: iforiinrange(n)}
return[shuffled[m[i]]foriinrange(n)]
c="N_gs{aesD_he_3AtrsOLlh3ROT1sECRl0m}s"
c=[chforchinc]
start=datetime(2022,1,1)
cur=start+timedelta(days=(3-start.weekday()+7)%7)
whilecur.year==2022:
forhourinrange(0,6):
forminuteinrange(0,60):
t=cur.replace(hour=hour,minute=minute).strftime('%Y%m%d%H%M')
f=inverse_seed_shuffler(c,int(t))
f="".join(f)
if"shellmates"inf:
print(cur)
print(f)
cur+=timedelta(weeks=1)
# 2022-05-26 00:00:00
# shellmates{N1ghT_C0D3Rs_ArE_LOOs3Rs}
```