莲城杯


莲城杯

from random import randint
flag = 'flag{********************************}'
b = [ ord(i) for i in flag ]
a = randint(65, max(b))
encflag=""
for i in range(len(flag)):
    encflag += str(bin((ord(flag[i])^a)<<2)[2:]) + ' '
print (encflag)

#11011000 11110000 11000100 11011100 10101100 11001000 110011000 11001100 110001100 110011100 110001000 11010100 110011100 110100100 11000100 110100100 11001000 110010100 110011100 110011000 110001000 110001000 110001100 11001100 110000100 11010100 110010000 110000100 11010000 110010100 11000100 110100100 110010000 110010000 110000000 11001000 110000000 10110100
import subprocess
import os
import random
import hashlib

subprocess.run(["g++", "random.cpp", "-o", "random", "-std=c++11"],check=True)
proc = subprocess.Popen(["./random"],stdin=subprocess.PIPE,stdout=subprocess.PIPE)

out, err = proc.communicate(str(int(os.urandom(8).hex(),16)).encode() + b"\n")
data = out.strip().split()
flag = random.randint(0,len(data))
print(flag)
FLAG = b'DASCTF{'+hashlib.md5(data.pop(flag)).hexdigest().encode()+b'}'
print(FLAG)
data = list(map(int,data))

with open("outputs_%d.txt"%flag,"w") as f:
    f.write(str(data))

  TOC