Skip to main content

Cryptography

Glad that I attempted to solve some cryptographic challenges in this CTF.

Bee Sixty Four (Common)#

description
Cipher Text: ZmxhZ3tSaWdodDBmZl90aGVfQjR0fQ==

At first glance and from the title, we can tell that this is a Base64 encoded string. Running this on Cyberchef, and we get the flag.

Flag: flag{Right0ff_the_B4t}

Toujours (Rare)#

description
Check out this poem I made in class:
Dans la béatitude pour toujoursDans la félicité en une infinitéDans la gloire irrévocablementéternellement à perpétuitéDans la divinité pour toujoursà perpétuité dans la lumiÚre

By putting this on Google, I got the following search result:

search_result

There's even a cipher for the poem. I ran the cipher on the online decoder and got the following flag:

partial_flag

I tried inputting the flag, but it was invalid. Looking up further, I realised that the Latin alphabet does not different between the alphabets, U, V or W. Tweaking the flag up by a bit, I managed to get the intended flag.

Flag: flag{wordlikepoem}

Stick Bug (Rare)#

description
Deep within the forest lies the ".4(:35*6);(65 -46*8*)6)".

Using an online decoder, I managed to solve the cryptographic message. It was encoded using the Gold-Bug cipher.

flag

Flag: flag{phryganistria chinensis}

Fun fact: The hint given was a video of a stick bug, and the flag, phryganistria chinensis, is the scientific name of stick bug.

IAISC (Common)#

description
Cipher Text:  &,!';!s#)q3v)xyqrsr0,xwu=

Using an online decoder, I managed to solve the cryptographic message. It was encoded using the ASCII Shift cipher (quite epic, considering the title of the challenge is also an anagram of ASCII).

flag

RSA-ONE#

description
Look at the file :)

We are given the following file for this challenge - question.txt

Here's a look at the file:

question.txt
p: 13096400414421552156969028937353174744908047161155295408964887163262826826036521470217012894200517287339110399380688376522626855275687133288684619779082547
q: 12840054857178763772230365613402198055084749343413307404027010001945719437978924658864009419366334955476170242725335489155132647907960715147801905246920609
e: 65537
ct: 32305409026163713222859212354020077015304928685327842744369445191616303537762118069639355953458045773045005993195097944549512923751703719047488817344339599720835627540521189095721269570852022720021666021201899667129233207585472537514546031754665930962489472140040978466147507216004529382189503453518588974947

This is really simple. Hope you can solve it.

Using the textbook method to solve for RSA, we can solve the challenge using the following script:

script
from Crypto.Util.number import *
p=13096400414421552156969028937353174744908047161155295408964887163262826826036521470217012894200517287339110399380688376522626855275687133288684619779082547
q=12840054857178763772230365613402198055084749343413307404027010001945719437978924658864009419366334955476170242725335489155132647907960715147801905246920609
e=65537
ct=32305409026163713222859212354020077015304928685327842744369445191616303537762118069639355953458045773045005993195097944549512923751703719047488817344339599720835627540521189095721269570852022720021666021201899667129233207585472537514546031754665930962489472140040978466147507216004529382189503453518588974947
n = p * q
phi = (p-1) * (q-1)
d = inverse(e, phi)
m = pow(ct, d, n)
print(hex(m)[2:])

Decoding the hex in Cyberchef, we get the flag.

Flag: flag{hellothisisthersaanswer}

My first RSA solve!

CRT0-Q1 (Common)#

description
Ciphertext: l4butzb9`b`oJ`fmef4O

We are given a Java file for this challenge - Encrypt.java

Looking at the file, there are 2 functions which encrypts the flag.

The first function, apjubh, was easy to understand. The function basically reverses the string.

The second function, encr, however, was a little trickier. It is basically a ROT-cipher, but using the Math.Random() function call, it limits the shift to a ROT-1 to ROT-6 method.

With this knowledge, and writing the possible permutations out by hand, I managed to decrypt the flag.

Flag: flag{N3edle_In_a_8aysta3k}

CRT1-Q2 (Rare)#

description
Given the output find the input (in flag format)
Output: 74CEE12EB1C1A00FF30FD37B74EF2477B37C957D

We are given another Java file for this challenge - Main.java

Taking a look at the file, there are 3 functions used to encrypt the flag.

The first function, retArry, basically places all the letters from the string input into a 2D-array sequentially.

The second function, enYBlock, iterates through the 2D-array by the number of rows of the array (in a stride-X pattern, where X in the 2D-array is denoted by arr[X][Y]) passed into the function, before it returns the corresponding string.

The last function, enXBlock, reverses the string input that is passed into the function.

Using this, I managed to decrypt the flag.

Flag: flag{D747F01E732B00BE5BF73AEC97E3F124C74DFC17}

(Many thanks to SMU CS102 module for teaching me the foundations of Java that is required to solve this challenge!)