diff --git a/budapest/README.md b/budapest/README.md new file mode 100644 index 0000000..8549dda --- /dev/null +++ b/budapest/README.md @@ -0,0 +1,7 @@ +# BudaPest +## Text +Find the flag in this nice picture of BudaPest. +## Files +[budapest.jpg](budapest.jpg) +## How to Deploy +n/a \ No newline at end of file diff --git a/budapest/SOLUTION.md b/budapest/SOLUTION.md new file mode 100644 index 0000000..b21d97e --- /dev/null +++ b/budapest/SOLUTION.md @@ -0,0 +1,14 @@ +## Difficulty +Easy +## Category +Steganography +## How To Solve +The only thing you get is an image `budapest.jpg`. There is a zip hidden in this image, which you can extract using `binwalk -e budapest.jpg`. You can then see 3 files: +```bash +budapest_encrypted.jpg +encrypt_image.py +key.txt +``` +You can not open the image just yet. When you explore the `encrypt_image.py` file, you can see that the original image has been encrypted with some key. That key has been stored in `key.txt`, after being hashed using SHA-1. SHA-1 is not safe. You can in this case use some hash lookup website to discover that the key is `TheBlueDanube`. The only thing you now need to do is to write a [decryption script](decrypt_image.py). Or actually you don't. Just change the input and output paths of the encryption script and you will be able to decrypt the encrypted image. Open the decrypted image and you will see the flag floating in the Blue Danube. +## Flag +`IGCTF{Bud4p3st_1s_c00l}` \ No newline at end of file diff --git a/budapest/budapest.jpg b/budapest/budapest.jpg new file mode 100644 index 0000000..4d4e42b Binary files /dev/null and b/budapest/budapest.jpg differ diff --git a/budapest/budapest.zip b/budapest/budapest.zip new file mode 100644 index 0000000..9b4d413 Binary files /dev/null and b/budapest/budapest.zip differ diff --git a/budapest/decrypt_image.py b/budapest/decrypt_image.py new file mode 100644 index 0000000..59dd9de --- /dev/null +++ b/budapest/decrypt_image.py @@ -0,0 +1,18 @@ +def decrypt_image(): + print("Decrypting image...") + + in_path = "budapest_encrypted.jpg" + out_path = "budapest_decrypted.jpg" + key = [str(ord(c)) for c in input("Enter the key to decrypt the image: ")] + file = open(in_path, 'rb') + img = file.read() + file.close() + img_bytes = bytearray(img) + for index, values in enumerate(img_bytes): + img_bytes[index] = values ^ int(key[index % len(key)]) + img = open(out_path, 'wb') + img.write(bytes(img_bytes)) + img.close() + print("Image decrypted successfully") + +decrypt_image() \ No newline at end of file diff --git a/budapest/encrypt_image.py b/budapest/encrypt_image.py new file mode 100644 index 0000000..ba021b2 --- /dev/null +++ b/budapest/encrypt_image.py @@ -0,0 +1,26 @@ +import hashlib + +def encrypt_image(): + print("Encrypting image...") + + + in_path = "budapest_flag.jpg" + out_path = "budapest_encrypted.jpg" + key_input = input("Enter the key to encrypt the image: ") + key_hash = hashlib.sha1(key_input.encode()).hexdigest() + key_file = open("key.txt", "wb") + key_file.write(key_hash.encode()) + key = [(ord(c)) for c in key_input] + file = open(in_path, 'rb') + img = file.read() + file.close() + img_bytes = bytearray(img) + for index, values in enumerate(img_bytes): + img_bytes[index] = values ^ key[index % len(key)] + img = open(out_path, 'wb') + img.write(bytes(img_bytes)) + img.close() + print("Image encrypted successfully") + +encrypt_image() + diff --git a/budapest/key.txt b/budapest/key.txt new file mode 100644 index 0000000..854e466 --- /dev/null +++ b/budapest/key.txt @@ -0,0 +1 @@ +26d3b8d47d48ed7fa4273deb62e713baa858685c \ No newline at end of file