RsaCtfTool

for anyone struggling with getting the flag to decrypt - I couldn’t find a working online tool so just used pycrypto instead and it should work first time :slight_smile:

Whoever made this flag aught to be slapped straight across the face. The numbers they chose makes it almost impossible to get the ■■■■ thing into a format that you can use utilities with. And doing it by hand doesn’t work either because the “key” message cannot be decoded using the normal format. The way you’d normally do it doesn’t work so you have to use a different method that does encrypt and decrypt messages but upon attemping it doesn’t work.

No matter what you do. It will no decrypt with openssl “bad magic number”. So you have to either a) use an online tool. b) use some python utility to do aes(or similar library). or c) write your own to do it. Whoever decided to use that prime I hate you.

Type your comment> @133794m3r said:

Whoever made this flag aught to be slapped straight across the face. The numbers they chose makes it almost impossible to get the ■■■■ thing into a format that you can use utilities with. And doing it by hand doesn’t work either because the “key” message cannot be decoded using the normal format. The way you’d normally do it doesn’t work so you have to use a different method that does encrypt and decrypt messages but upon attemping it doesn’t work.

No matter what you do. It will no decrypt with openssl “bad magic number”. So you have to either a) use an online tool. b) use some python utility to do aes(or similar library). or c) write your own to do it. Whoever decided to use that prime I hate you.

■■■■ wut

This was definitely one of the most challenging for me in terms of calculations. However, with the assistance of @kd3n4 and @m4nu, I finally got my head around it.

Here’s some hints to get you moving

  • The modulus is specific type of number, noticeable when factored.
  • The function to determine decryption handles that specific type in a certain way. The wiki page will explain it more.
  • As @socialkas states, the “bad magic number” is a result of a newline character.

Feel free to PM me or catch me on Discord.

Nice challenge! Finally a real cryptography challenge on HackTheBox, similar to CryptoHack.

@133794m3r said:
Whoever made this flag aught to be slapped straight across the face. The numbers they chose makes it almost impossible to get the ■■■■ thing into a format that you can use utilities with. And doing it by hand doesn’t work either because the “key” message cannot be decoded using the normal format. The way you’d normally do it doesn’t work so you have to use a different method that does encrypt and decrypt messages but upon attemping it doesn’t work.

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

1 Like

I am very lost in this challenge. Please, does anyone suggest a hint where to start?
Any PM will be appreciated

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