Monday, June 9, 2025

Mind Your Ps and Qs PicoCTF Walkthrough – RSA Crypto Challenge

 

Cryptography

Mind your Ps and Qs

CTF Author: Sara

Description

In RSA, a small e value can be problematic, but what about N? Can you decrypt this?

Hints-Bits are expensive, I used only a little bit over 100 to save money


For this challenge I searched about this challenge on gpt and got the important information about RSA.

The hint given is that the RSA modulus N is small, and indeed this can be a problem for security. For RSA, the modulus N is a product of two large primes, and the size of N will generally be large to achieve security. If N is small, then it is going to be much easier to break the encryption, as factors of N will be small and easy to compute.

The declaration "Bits are expensive, I only spent a bit more than 100 to save money" simply means that the number of bits used for N is a bit more than 100, i.e., N would probably be around 100 bits in size, which is very small compared to the typical size of RSA moduli, which is usually at least 2048 bits for secure usage.

To decrypt this, we need more specific information such as the ciphertext or the public key components (e.g., e and N), or we could try factoring N if it's small enough to be practical. Given the hint, it's likely that the problem can be solved by factoring N or using small values for e to break the encryption, which would be feasible with a small modulus.

Values given are the following:

c:421345306292040663864066688931456845278496274597031632020995583473619804626233684 n:631371953793368771804570727896887140714495090919073481680274581226742748040342637

e: 65537

I just used the website for finding the factors of n and then gave that values to gpt for solving c.

https://factordb.com/index.php?

The decrypted message is:

130163825294491060659272914253425354379962221353529052566396478892411027000659171301638252944910606592729142534253543799622213535290525663964788924110270006591713016382529449106065927291425342535437996222135352905256639647889241102700065917

With the help of python script for converting decimal to ASCII I got the flag.


# Decrypted large number

decrypted_number = 13016382529449106065927291425342535437996222135352905256639647889241102700065917

# Convert the large number to bytes

decrypted_bytes = decrypted_number.to_bytes((decrypted_number.bit_length() + 7) // 8, byteorder='big')

# Attempt to decode the byte string into a readable text (assuming ASCII encoding)

try:

    decrypted_text = decrypted_bytes.decode('ascii')

    print("Decrypted text:", decrypted_text)

except UnicodeDecodeError:

    print("Unable to decode into ASCII")

Flag:picoCTF{sma11_N_n0_g0od_55304594}

No comments:

Post a Comment

HashCrack Challenge Writeup

  HashCrack Challenge Writeup Challenge Overview Challenge Name: hashcrack Difficulty: Beginner/Intermediate Category: Cryptography ...