feat: add budapest challenge

This commit is contained in:
Abel Stuker 2024-11-25 22:28:19 +01:00
parent 85f46f2da4
commit 5fa14f9fb1
7 changed files with 66 additions and 0 deletions

7
budapest/README.md Normal file
View File

@ -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

14
budapest/SOLUTION.md Normal file
View File

@ -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}`

BIN
budapest/budapest.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 MiB

BIN
budapest/budapest.zip Normal file

Binary file not shown.

18
budapest/decrypt_image.py Normal file
View File

@ -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()

26
budapest/encrypt_image.py Normal file
View File

@ -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()

1
budapest/key.txt Normal file
View File

@ -0,0 +1 @@
26d3b8d47d48ed7fa4273deb62e713baa858685c