Differences

This shows you the differences between two versions of the page.

Link to this comparison view

isc:labs:02 [2023/10/17 19:18]
david.gherghita
isc:labs:02 [2025/10/13 14:09] (current)
david.gherghita [6. [10p] Feedback]
Line 125: Line 125:
 ===== Exercises ===== ===== Exercises =====
  
-=== 0. [5p]  AES ECB (Warmup) ===+=== 01. [5p] AES ECB (Warmup) ===
  
  It is recommended NOT to encrypt more than one block with AES in ECB mode, but in order to understand why, an image with the following header was encrypted. The encrypted photo cand be found {{isc:​labs:​isc-lab02-encrypted.zip|here (.zip)}}. Is it possible to figure out what the initial image was?  It is recommended NOT to encrypt more than one block with AES in ECB mode, but in order to understand why, an image with the following header was encrypted. The encrypted photo cand be found {{isc:​labs:​isc-lab02-encrypted.zip|here (.zip)}}. Is it possible to figure out what the initial image was?
Line 150: Line 150:
 </​solution>​ </​solution>​
  
-=== 1. [20p] AES ===+=== 02. [20p] AES ===
  
  ​{{:​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 216: Line 216:
 </​solution>​ </​solution>​
  
-=== 2. [20p] RSA - Known factorisation ===+=== 03. [20p] RSA - Known factorisation ===
  
 In order to decrypt the ciphertext, you need to factorize n into p and q, compute phi and find d.  In order to decrypt the ciphertext, you need to factorize n into p and q, compute phi and find d. 
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 258: Line 258:
 </​solution>​ </​solution>​
  
-==== 03 [15p] Is this even OTP? ====+==== 04. [15p] Is this even OTP? ====
  
   * Someone applied [[https://​en.wikipedia.org/​wiki/​One-time_pad|one time pad]] on {{:​isc:​labs:​isc-lab02-otp.txt|this text}}.   * Someone applied [[https://​en.wikipedia.org/​wiki/​One-time_pad|one time pad]] on {{:​isc:​labs:​isc-lab02-otp.txt|this text}}.
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 = 1ei_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>​
 </​solution>​ </​solution>​
  
-==== 04 [20p] Many Time Pad ====+==== 05. [20p] Many Time Pad ====
  
   * This time, {{:​isc:​labs:​isc-lab02-many_time_pad.zip|he did use a proper key}}. Unfortunately for him, he used it for multiple encryptions.   * This time, {{:​isc:​labs:​isc-lab02-many_time_pad.zip|he did use a proper key}}. Unfortunately for him, he used it for multiple encryptions.
Line 286: Line 293:
 </​solution>​ </​solution>​
  
-==== 05 [20p] We want Jokes instead of Nukes  ====+==== 06. [20p] We want Jokes instead of Nukes  ====
  
   * {{:​isc:​labs:​isc-lab02-oracle.zip|Donald has gone completely crazy}}. To prevent world chaos, you kidnapped him. Right before the kidnapping he tried to send one encrypted message to his wife Melania. Luckily you intercepted the message. Donald admits that he used AES256-CBC encryption - a block cipher operating with a block length of 16 bytes.   * {{:​isc:​labs:​isc-lab02-oracle.zip|Donald has gone completely crazy}}. To prevent world chaos, you kidnapped him. Right before the kidnapping he tried to send one encrypted message to his wife Melania. Luckily you intercepted the message. Donald admits that he used AES256-CBC encryption - a block cipher operating with a block length of 16 bytes.
Line 300: Line 307:
  
 <​solution -hidden> <​solution -hidden>
-<​code>​+<​code ​python>
  
 original_iv = bytes.fromhex('​7ec00bc6fd663984c1b6c6fd95ceeef1'​) original_iv = bytes.fromhex('​7ec00bc6fd663984c1b6c6fd95ceeef1'​)
Line 314: Line 321:
 </​solution>​ </​solution>​
  
- +==== 07. Feedback ====
-==== 6[10p] Feedback ====+
  
 Please take a minute to fill in the [[https://​docs.google.com/​forms/​d/​e/​1FAIpQLSeMrKoWY6UKe1N_BASUARA-HixTuvSfrEnx_FKstT-RW464NQ/​viewform |feedback form]] for this lab. Please take a minute to fill in the [[https://​docs.google.com/​forms/​d/​e/​1FAIpQLSeMrKoWY6UKe1N_BASUARA-HixTuvSfrEnx_FKstT-RW464NQ/​viewform |feedback form]] for this lab.
  
isc/labs/02.1697559481.txt.gz · Last modified: 2023/10/17 19:18 by david.gherghita
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0