<?xml version="1.0"?> <response> <authenticationFailure>Ticket TGT-29c3ba1f6839ec563a23404b3f67ec205d52423f368c8e01efb75033f12a1514 is invalid for service <scriptxmlns="http://www.w3.org/1999/xhtml">alert(1)</script></authenticationFailure> </response>
<?xml version="1.0"?> <response> <authenticationFailure>Ticket TGT-29c3ba1f6839ec563a23404b3f67ec205d52423f368c8e01efb75033f12a1514 is invalid for service <div>hello</div></authenticationFailure><authenticationSuccess><id>dcfb2fd7-312e-48cf-81c0-ae7eb31ef864</id><username>teacher31211</username></authenticationSuccess><authenticationFailure></authenticationFailure> </response>
defencrypt_otp(cleartext, key = os.urandom(PASS_LENGTH_BYTES)): ciphertext = bytes([key[i % len(key)] ^ x for i,x inenumerate(cleartext.hex().encode())]) return ciphertext, key
if __name__ == '__main__': print('According to Wikipedia:') print('"In cryptography, the one-time pad (OTP) is an encryption technique that cannot be cracked, but requires the use of a single-use pre-shared key that is not smaller than the message being sent."') print('So have fun trying to figure out my password!') password = os.urandom(PASS_LENGTH_BYTES)
enc, _ = encrypt_otp(password) print(f'Here is my password encrypted with a one-time pad: {enc.hex()}') print('Actually, I will give you my password encrypted another time.') print('This time you are allowed to permute the password first') permutation = input('Permutation: ') try: permutation = [int(x) for x in permutation.strip().split(',')] assertset(permutation) == set(range(PASS_LENGTH_BYTES)) enc, _ = encrypt_otp(bytes([password[permutation[i]] for i inrange(PASS_LENGTH_BYTES)])) print(f'Here is the permuted password encrypted with another one-time pad: {enc.hex()}') except: print('Something went wrong!') exit(1) password_guess = input('What is my password: ') try: password_guess = bytes.fromhex(password_guess) except: print('Something went wrong!') exit(1) if password_guess == password: withopen('flag.txt', 'r') as f: flag = f.read() print(f'The flag is {flag}') else: print('Nope.')
from pwn import process, remote import random from z3 import *
defencrypt_otp_z3(pt_hex, key): ciphertext = [key[i % len(key)] ^ x for i, x inenumerate(pt_hex)] return ciphertext, key
defsolve(ct1, ct2): sol = Solver() pt_hex_sym = [BitVec(f"pt_hex_{i}", 8) for i inrange(PASS_LENGTH_BYTES * 2)] for x in pt_hex_sym: sol.add(Or([x == t for t inb"0123456789abcdef"])) pt_sym = [(x, y) for x, y inzip(pt_hex_sym[::2], pt_hex_sym[1::2])] pt2_sym = [pt_sym[perm[i]] for i inrange(PASS_LENGTH_BYTES)] pt2_hex_sym = sum([list(x) for x in pt2_sym], []) key_sym = [BitVec(f"key_{i}", 8) for i inrange(PASS_LENGTH_BYTES)] enc_sym, _ = encrypt_otp_z3(pt_hex_sym, key_sym) for x, y inzip(ct1, enc_sym): sol.add(x == y) enc2_sym, _ = encrypt_otp_z3(pt2_hex_sym, key_sym) for x, y inzip(ct2, enc2_sym): sol.add(x == y) assert sol.check() == sat m = sol.model() pt_hex = [m[x].as_long() for x in pt_hex_sym] pwd = bytes.fromhex("".join([f"{x:02x}"for x in pt_hex])).decode() return pwd
from pwn import process, remote import random from z3 import *
defencrypt_otp_z3(pt_hex, key): ciphertext = [key[i % len(key)] ^ x for i, x inenumerate(pt_hex)] return ciphertext, key
defsolve(ct1, ct2): sol = Solver() pt_hex_sym = [BitVec(f"pt_hex_{i}", 8) for i inrange(PASS_LENGTH_BYTES * 2)] for x in pt_hex_sym: sol.add(Or([x == t for t inb"0123456789abcdef"])) pt_sym = [(x, y) for x, y inzip(pt_hex_sym[::2], pt_hex_sym[1::2])] pt2_sym = [pt_sym[perm[i]] for i inrange(PASS_LENGTH_BYTES)] pt2_hex_sym = sum([list(x) for x in pt2_sym], []) key_sym = [BitVec(f"key_{i}", 8) for i inrange(PASS_LENGTH_BYTES)] key2_sym = [BitVec(f"key2_{i}", 8) for i inrange(PASS_LENGTH_BYTES)] enc_sym, _ = encrypt_otp_z3(pt_hex_sym, key_sym) for x, y inzip(ct1, enc_sym): sol.add(x == y) enc2_sym, _ = encrypt_otp_z3(pt2_hex_sym, key2_sym) for x, y inzip(ct2, enc2_sym): sol.add(x == y) assert sol.check() == sat m = sol.model() pt_hex = [m[x].as_long() for x in pt_hex_sym] pwd = bytes.fromhex("".join([f"{x:02x}"for x in pt_hex])).decode() return pwd
withopen("output.txt") as f: vals = [int(l.strip()) for l in f]
n, k = 1000, 112 C = codes.GeneralizedReedSolomonCode([F(i) for i inrange(n)], k) D = codes.decoders.GRSGuruswamiSudanDecoder(C, num_parties - num_compromised) print("Start decode to code") c = D.decode_to_code(vector(F, vals)) print("Start decode to message") msg = C.decode_to_message(c[0]) print("Done", msg[-1]) # 4489067692978501633227145646993390603391687375740992390950503291222699941250770320347716168654384649757035