ISITDTU CTF 2024
This is my write-up for 3 challenges in crypto category I solved in ISITDTU CTF 2024. 2 unsolved challenges may be updated in the future 🤔. Thanks to all authors for very nice challenges 😁
ShareMixer1
- This challenge, we are asked to give a "query" containing a list of integers
xs
, which its length must be less or equal than 256 and it doesn't contain 0 (mod p) element. Then the server will calculate with random coefficients (one of them is flag) with in xs
. The output is shuffled before giving to us.
- Because the output is shuffled, we can not differentiate which value of belongs to . So we have to do a trick: Sending a sequence of value like , then we based on the frequency of occurrence of elements to determine which value of belongs to . Then solve a system of equations to find flag.
- To be able to solve the system of equations, we have to have enough 32 value of , which means we need 32 value of . But we can recognize that with this method of building the query, its length is too large. So we have another option to build this:
- With i from 1 to 15:
payload += [xs[i]] * i
- With i from 16 to 30:
payload += [xs[i]]*(i-15)
payload += [xs[31]]
payload += 2*[xs[32]]
- After having the outputs, we have to brute all case of permutations (totally ), it's feasible to brute-force.
- Solve script:
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
ShareMixer2
- This challenge, the author limits the length of query to 32, exactly equal to the number of values we need.
- After thinking a while, I realize that if we send -1 and 1 to get and , we can calculate Note that and are the 2nd roots of unity in
GF(p)
. If we send 4th-roots of unity, we can see that
- Therefore, my idea is sending 32nd-roots of unity in
GF(p)
, with the condition that must devide to 32. Then we calculate the value of and "hope" that the flag is .
- Solve script:
Because the author doesn't put PoW on server, we can easily "gacha" this.
Sign
- In this challenge, the server allows us to sign a random message or sign flag with unlimited times. It uses the
PKCS1_v1_5
algorithm to sign. Its python implementation in pycryptodome module is here
- Before RSA decryption, the hashed message is encoded by
_EMSA_PKCS1_V1_5_ENCODE
function, which will add a fixed padding for a type of hash algorithm. With SHA256
hash algorithm, we can see this padding is:
This padding can be easily found with this code
- We can see that:
prefix + msg + k*n = sig^e
with e=11
, so small :v. Note that we can submit to server unlimited time, we can request more random signatures to construct more functions, then use AGCD (Approximate gcd) to find n
, then we can easily recover flag.
- Solve script:
attack
function is from here
