RsaCtfTool

Finally got it!! A nice challenge, with a “touch” different. Thanks to @m4nu for help :slight_smile:

Type your comment> @hyperreality said:

If anyone ought to be slapped across the face it is you and your stupid comment. All the formats used in this challenge are standard and made sense, except perhaps the encrypted flag could also have been encoded in base64 or hex. But that’s easy to work around. Nice challenge @R4J

Where’s the like button, when you need one :smiley:

I think it is best crypto challange I solved if you know how RSA works and generated it wont take 15 minutes from your time
hint : picoctf will help you understand RSA

The best crypto challenge that I solved, thanks!

Type your comment> @debugasm said:

With this: “openssl rsa -inform PEM -text -noout -pubin -in pubkey.pem”

RSA Public-Key: (1535 bit)
Modulus:
77:d1:e3:2b:fe:41:fb:07:61:2b:cb:95:2e:8b:19:
6d:9c:30:39:41:dd:19:47:d4:fb:5e:0f:b8:0d:ea:
75:38:2a:1c:8c:95:1c:e7:39:44:08:ed:c8:01:d3:
cd:9b:b4:c5:ac:d6:eb:0f:61:f5:12:ae:a9:03:b3:
ed:44:0e:bc:f3:c3:8d:8c:1b:af:37:62:f2:e5:25:
17:dc:3b:6b:32:73:e6:0d:25:30:ea:b5:51:d6:e5:
5d:d2:34:9d:89:f9:62:82:c3:40:39:f9:a6:f6:a8:
0f:ac:7e:14:45:86:f3:c9:ee:0b:0b:bd:48:fe:6e:
5b:79:ab:07:b2:19:58:5e:30:e4:2f:cb:e5:97:23:
e5:62:fe:3c:2d:95:6d:e2:b7:6e:64:04:b6:54:a0:
44:83:06:0f:87:64:a9:f1:cf:73:20:70:9e:97:ae:
83:1d:8c:f3:f0:4c:7d:9f:f2:c3:ab:09:32:35:8c:
9c:cd:51:8c:49:f4:94:34:40:f4:eb:c7
Exponent: 65537 (0x10001)

How can a RSA public key have a lenght of 1535 bit?!

Type your comment> @0xmuhammed said:

hint : picoctf will help you understand RSA

Best hint on here, taught me what I needed to know to solve it. And lots of fun. Feel free to PM for nudges.

Finally pass the challenge with the help of @JumpingLlama . Thanks to him!

A got no issue with openssl and the orignal .aes file.

Type your comment> @m4nu said:

i think my decrypt is correct because i can read the "key file: se****** ", but i can’t decrypt with openssl (i get bad magic number) and the online tools… if someone can help me, a small detail that i forget… thank’s

same here,which online tool did you use… cant find one works for me

@negusnegasht said:
Type your comment> @m4nu said:

i think my decrypt is correct because i can read the "key file: se****** ", but i can’t decrypt with openssl (i get bad magic number) and the online tools… if someone can help me, a small detail that i forget… thank’s

same here,which online tool did you use… cant find one works for me

Never mind. solved it with pycrypto

Hmm, I didn’t like this challenge. I knew exactly what to do after a few minutes looking at the files but it took me several hours to get things working with those high numbers. The only “challenge” was to find that one website, that basically gave me the solution I was looking for and the rest was some pain in the ■■■ coding stuff

hello guys any one could help me here with some hint im really struggling i tried to generate the private key using some mathematics but the calculation of the two prime numbers p and q are really hard im not even know if im at the right path or not

if someone needs help, feel free to pm me

edit with the help of @m4nu much thanks I finally solve it, its an interesting challenge that u can use ur knowledge of math on it as well

I think I’ve found the N “strangeness” and I believe I’ve accommodated for it, but Is the private key supposed to be 1535 bits long? Just want to make sure I’m on the right track.

Did anyone try to read information with asn1parse? I’m little confused by the output. I could need a nudge I think I know what to do but either my math is falling(very high probability) or my script doing something that it shouldn’t(very high probability) anyone will to help me with nudge?

@SovietBeast said:
Did anyone try to read information with asn1parse? I’m little confused by the output. I could need a nudge I think I know what to do but either my math is falling(very high probability) or my script doing something that it shouldn’t(very high probability) anyone will to help me with nudge?

I use this to parse my certs: Online Certificate Decoder, decode crl,crt,csr,pem,privatekey,publickey,rsa,dsa,rasa publickey,ec
Not my page so at your own risk, but looks legit.

Type your comment> @drn0b0dy said:

@SovietBeast said:
Did anyone try to read information with asn1parse? I’m little confused by the output. I could need a nudge I think I know what to do but either my math is falling(very high probability) or my script doing something that it shouldn’t(very high probability) anyone will to help me with nudge?

I use this to parse my certs: Online Certificate Decoder, decode crl,crt,csr,pem,privatekey,publickey,rsa,dsa,rasa publickey,ec
Not my page so at your own risk, but looks legit.

Thanks for answer I blamed it on my not-to-great understanding of asn1parse and just used python Crypto now my math falling and I don’t know why but I have some assumptions but can’t really fit it right

EDIT:
Got it finally I had it almost from the beginning but just missing obvious thing that was on the screen for like 4h straight the drn0b0dy opend my eyes and I could adjust the inputs and solved. Not gonna lied bang my head for whole day. Learn that math is as complicated as I remember but now I know that this particular function don’t look like I thought

Whoa been banging on this challenge for a while.

Because the flag file name suggest or hints at AES Cipher, and since AES uses passpharses I thought encrypting the ‘key’ file

with the public key would give me the valid key.

But after doing some research and using common sense(in terms of aysmmetric cryptography).I realized that the challenge provides a public key and that probably means we can derive a private key from it or the ‘key’ file.

However I have check the modulus

of the public key and tried Math Magic but got nothing from it.

I am woried that I might be going into a dissapointing rabit hole.

Can someone let me know if Iam on the right track and also give a hint.

Been a while since I did this one, but if I recall… asymmetric was used to protect a symmetric key. Figure out how to get that private key and bob’s your uncle.

hi everyone, I’m new here, I think I factorized the modulus and get the private key, but still cannot firure out how to use it, I’m trying decrypting the key file but I had no success, can someone help me?