Tags: xor crypto
Rating:
we're given the cipher code (in php) and the output, we begun with xor the output (as a key) with the flag format "gigem{" which gave us : to\`be\`, from here we deduce that the key is the well-known shakespeare quote :
> to be or not to be that is the question
but the space are replaced with a \` (back quote) .
```
def secure_crypt(str, key):
if (not key):
return str
if (len(key) < 8):
return "key error"
n = len(key) if(len(key) < 32) else 32
res = []
for i in range(len(str)):
res.append(chr(ord(str[i]) ^ (ord(key[i % n]) & 0x1F)))
return "".join(res)
print(secure_crypt("to`be`or`not`to`be`that`is`the`question", "sf'gh;k}.zqf/xc>{j5fvnc.wp2mxq/lrltqdtj/y|{fgi~>mff2p`ub{q2p~4{ub)jlc${a4mgijil9{}w>|{gpda9qzk=f{ujzh$`h4qg{~my|``a>ix|jv||0{}=sf'qlpa/ofsa/mkpaff>n7}{b2vv4{oh|eihh$n`p>pv,cni`f{ph7kpg2mxqb"))
#output :gigem{dont~roll~your~own~crypto}fctsate
```