This shows you the differences between two versions of the page.
isc:labs:02 [2023/10/17 18:41] david.gherghita |
isc:labs:02 [2024/03/03 13:03] (current) vlad_iulius.nastase [05 [20p] We want Jokes instead of Nukes] |
||
---|---|---|---|
Line 153: | Line 153: | ||
{{:isc:labs:isc-lab02-secret.zip|This file (compressed as .zip)}} was encrypted using the following code. Can you decrypt it? | {{:isc:labs:isc-lab02-secret.zip|This file (compressed as .zip)}} was encrypted using the following code. Can you decrypt it? | ||
- | <code> | + | <code python> |
from Crypto.Cipher import AES | from Crypto.Cipher import AES | ||
from Crypto import Random | from Crypto import Random | ||
Line 190: | Line 190: | ||
<solution -hidden> | <solution -hidden> | ||
- | <code> | + | <code python> |
from Crypto.Cipher import AES | from Crypto.Cipher import AES | ||
Line 230: | Line 230: | ||
</code> | </code> | ||
* **Note**: the result is a decimal number, you need to convert it to an ASCII text using the snippet below: | * **Note**: the result is a decimal number, you need to convert it to an ASCII text using the snippet below: | ||
- | <code> | + | <code python> |
print(hex(message)[2:].decode("hex")) # python 2 | print(hex(message)[2:].decode("hex")) # python 2 | ||
print(bytearray.fromhex(hex(message)[2:])) # python 3 | print(bytearray.fromhex(hex(message)[2:])) # python 3 | ||
Line 239: | Line 239: | ||
<solution -hidden> | <solution -hidden> | ||
- | <code> | + | <code python> |
import gmpy2 | import gmpy2 | ||
Line 265: | Line 265: | ||
<solution -hidden> | <solution -hidden> | ||
- | <code> | + | <code python> |
+ | |||
+ | # Key = 1e: i_guess_it_kinda_is_otp | ||
+ | |||
+ | from itertools import cycle | ||
+ | |||
+ | c = 'wAyk{mmAwjAuwpzAwmAqjn' | ||
- | Key = 1e: i_guess_it_kinda_is_otp | + | for i in range(0,256): |
+ | print("".join([chr(x[0] ^ ord(x[1])) for x in zip(cycle([i]), c)])) | ||
</code> | </code> | ||
Line 298: | Line 305: | ||
If you find this cringe, just wait until you see the assignments! ;) | If you find this cringe, just wait until you see the assignments! ;) | ||
</note> | </note> | ||
+ | |||
+ | <solution -hidden> | ||
+ | <code python> | ||
+ | |||
+ | original_iv = bytes.fromhex('7ec00bc6fd663984c1b6c6fd95ceeef1') | ||
+ | original_plaintext = b'FIRE_NUKES_MELA!' | ||
+ | new_plaintext = b'SEND_NUDES_MELA!' | ||
+ | |||
+ | xor_result = bytes(a ^ b for a, b in zip(original_plaintext, new_plaintext)) | ||
+ | new_iv_bytes = bytes(a ^ b for a, b in zip(original_iv, xor_result)) | ||
+ | |||
+ | print("New IV in hexadecimal:", new_iv_bytes.hex()) | ||
+ | |||
+ | </code> | ||
+ | </solution> | ||
+ | |||
==== 6. [10p] Feedback ==== | ==== 6. [10p] Feedback ==== |