Math is used in cryptography, but someone got this wrong. Can you still solve the equations? Hint: You need to encode your answers. Attachment:code70.zip
Exploit
This challenge is different from A numbers game (code 50) with only an additional encode/decode process. The encode function has been provided.
1 2 3 4 5 6 7 8 9 10 11 12 13
defencode(self, eq): out = [] for c in eq: q = bin(self._xor(ord(c),(2<<4))).lstrip("0b") q = "0" * ((2<<2)-len(q)) + q out.append(q) b = ''.join(out) pr = [] for x in range(0,len(b),2): c = chr(int(b[x:x+2],2)+51) pr.append(c) s = '.'.join(pr) return s
Convert every charactors to the binary form with padding 0 (e.g. 88 -> ‘01011000’)
Concatenate the result in 2.
Convert every two digits into integer and plus 51 (e.g. ‘01011000’ -> [52, 52, 53, 51])
Convert the numbers above to charactors and concatenate them with ‘.’ (e.g. [52, 52, 53, 51] -> ‘4.4.5.3’)
To decode, just reverse the process above. With the encode and decode function, we can use the same program shown in A numbers game (code 50) to solve the program and get the flag.
defdecode(cypher): b = '' for c in cypher.split('.'): b += bin(ord(c)-51)[2:].rjust(2, '0')
eq = '' for i in range(0, len(b), 8): eq += chr(int(b[i:i+8], 2)^32)
return eq
defencode(eq): out = [] for c in eq: q = bin(ord(c)^(2<<4)).lstrip("0b") q = "0" * ((2<<2)-len(q)) + q out.append(q) b = ''.join(out) pr = [] for x in range(0,len(b),2): c = chr(int(b[x:x+2],2)+51) pr.append(c) s = '.'.join(pr) return s