Ejemplo n.º 1
0
    "VW50aWwgaGVyIHZvaWNlIGdyZXcgc2hyaWxsLg==",
    "V2hhdCB2b2ljZSBtb3JlIHN3ZWV0IHRoYW4gaGVycw==",
    "V2hlbiB5b3VuZyBhbmQgYmVhdXRpZnVsLA==",
    "U2hlIHJvZGUgdG8gaGFycmllcnM/",
    "VGhpcyBtYW4gaGFkIGtlcHQgYSBzY2hvb2w=",
    "QW5kIHJvZGUgb3VyIHdpbmdlZCBob3JzZS4=",
    "VGhpcyBvdGhlciBoaXMgaGVscGVyIGFuZCBmcmllbmQ=",
    "V2FzIGNvbWluZyBpbnRvIGhpcyBmb3JjZTs=",
    "SGUgbWlnaHQgaGF2ZSB3b24gZmFtZSBpbiB0aGUgZW5kLA==",
    "U28gc2Vuc2l0aXZlIGhpcyBuYXR1cmUgc2VlbWVkLA==",
    "U28gZGFyaW5nIGFuZCBzd2VldCBoaXMgdGhvdWdodC4=",
    "VGhpcyBvdGhlciBtYW4gSSBoYWQgZHJlYW1lZA==",
    "QSBkcnVua2VuLCB2YWluLWdsb3Jpb3VzIGxvdXQu",
    "SGUgaGFkIGRvbmUgbW9zdCBiaXR0ZXIgd3Jvbmc=",
    "VG8gc29tZSB3aG8gYXJlIG5lYXIgbXkgaGVhcnQs",
    "WWV0IEkgbnVtYmVyIGhpbSBpbiB0aGUgc29uZzs=",
    "SGUsIHRvbywgaGFzIHJlc2lnbmVkIGhpcyBwYXJ0",
    "SW4gdGhlIGNhc3VhbCBjb21lZHk7",
    "SGUsIHRvbywgaGFzIGJlZW4gY2hhbmdlZCBpbiBoaXMgdHVybiw=",
    "VHJhbnNmb3JtZWQgdXR0ZXJseTo=",
    "QSB0ZXJyaWJsZSBiZWF1dHkgaXMgYm9ybi4=",
]

plaintexts = [b64decode(s) for s in STRINGS]

key = random_bytes(16)
nonce = random_bytes(16)
ciphertexts = [ctr_crypt(pt, key, nonce) for pt in plaintexts]

# Per instructions, attack this manually.
Ejemplo n.º 2
0
def check_admin(key, nonce, ciphertext):
    plaintext = ctr_crypt(ciphertext, key, nonce)
    # print(plaintext)
    return b";admin=true;" in plaintext
Ejemplo n.º 3
0
def encrypt(plaintext):
    key = token_bytes(16)
    nonce = randint(0, 127).to_bytes(8, "little")
    return key, nonce, ctr_crypt(plaintext, key, nonce)
Ejemplo n.º 4
0
def wrap_string(string):
    key = token_bytes(16)
    nonce = randint(0, 127).to_bytes(8, "little")
    uinfo = prefix + quote(string).encode() + suffix
    ciphertext = ctr_crypt(uinfo, key, nonce)
    return key, nonce, ciphertext