- Category: Crypto
- Score: 284/500
- Solves: 20
A secure, cryptographically signed echo-as-a-service.
The server generates a 512-bits RSA key pair on connection, but it doesn't give you the public key.
There are two operations available:
- Sign the command
echo <message>
and return the RSA signature. (The message is properly escaped.) - Execute and given command if the signature is valid.
The target is to execute ./give me flag please
to get the flag.
To recover echo <message>
such that
Then the corresponding signature
So if we can find two differents
The same idea has been used in HITCON CTF 2022 - Secret, btw.
But the problem is, how can we find such echo <message>
that can be fully factored by
For each message
So finding
Note that we need to do exponentiation in
To keep
In my reference solution, I pick
See do_precompute.sage for more details.
The idea of this comes from Index Calculus, but after some searching about this I found it is actually pretty similar to A chosen text attack on the RSA cryptosystem and some discrete logarithm schemes (as expected of course).
One of the way to do signature forgery is to find a command ./give me flag please # ...
that can be fully factored by
If you insist in using this, you can try to use the trick from BabyFirst Revenge v2, but this would need a writable directory and it would be a web/misc challenge instead :P
The intended way is to use that fact that a signature pair ./give me flag please # ...
There is a restriction that ...
must be a valid UTF-8 string. If you remeber SEETF 2023 - 🤪onelinecrypto, you know this can be done by using lattice reduction.
In practice, LLL appear to be not enough for this, but BKZ can do the job. See solve.sage for more details.