defencrypt(payload): obj = AES.new(key, AES.MODE_CBC, iv) for i in xrange(len(payload)): if payload[i] == ";"or payload[i] == "=": payload = payload.replace(payload[i], "?") str1 = "comment1=cooking%20MCs;userdata=" + payload + ";comment2=%20like%20a%20pound%20of%20bacon" str1 = padding(str1) ciphertext = obj.encrypt(str1) return ciphertext
defdecrypt(ciphertext): obj1 = AES.new(key,AES.MODE_CBC,iv) plaintext = obj1.decrypt(ciphertext) if";admin=true;"in plaintext: print"Logged in as admin" else: print"You need to be admin to get the access!"
if __name__ == "__main__": p = ";admin=true;" c = encrypt(p) print c decrypt(c)
defencrypt(payload): obj = AES.new(key, AES.MODE_CBC, iv) for i in xrange(len(payload)): if payload[i] == ";"or payload[i] == "=": payload = payload.replace(payload[i], "?") str1 = "comment1=cooking%20MCs;userdata=" + payload + ";comment2=%20like%20a%20pound%20of%20bacon" str1 = padding(str1) ciphertext = obj.encrypt(str1) return ciphertext
defdecrypt(ciphertext): obj1 = AES.new(key,AES.MODE_CBC,iv) plaintext = obj1.decrypt(ciphertext) if";admin=true;"in plaintext: print"Logged in as admin" else: print"You need to be admin to get the access!"
# Exploit using the Bit Flipping Attack! cipher_list = [] payload = ";admin=true;" ciphertext = encrypt(payload)
i = 0 while i*16 <= len(ciphertext): cipher_list.append(ciphertext[i*16: 16 + (i*16)]) i += 1 cipher_list.remove(cipher_list[6])
defencrypt(payload): obj = AES.new(key, AES.MODE_CBC, iv) for i in xrange(len(payload)): if payload[i] == ";"or payload[i] == "=": payload = payload.replace(payload[i], "?") str1 = "comment1=cooking%20MCs;userdata=" + payload + ";comment2=%20like%20a%20pound%20of%20bacon" str1 = padding(str1) ciphertext = obj.encrypt(str1) return ciphertext
defdecrypt(ciphertext): obj1 = AES.new(key,AES.MODE_CBC,iv) plaintext = obj1.decrypt(ciphertext) print plaintext if";admin=true;"in plaintext: print"Logged in as admin" else: print"You need to be admin to get the access!"
# Exploit using the Bit Flipping Attack! cipher_list = [] payload = ";admin=true;" ciphertext = encrypt(payload) print ciphertext