My friend told me that cryptography is unbreakable if moduli are Carmichael numbers instead of primes. I decided to use this CTF to test out this theory.
ncat --ssl groups.chal.uiuc.tf 1337
Here’s the Python source:
1 | from random import randint |
In short, this is simply solving the discrete log problem with the modulus is a Carmichael number. Essentially, Carmichael numbers are composite numbers that have the same property of the primes of Fermat’s Little Theorem, which states that $$a^{p-1}=1;(mod ;p)$$ for any prime p
, such that a
and p
are coprime. Essentially, $$a^{n-1}=1;(mod;n)$$, such that a
and n
are coprime.
Through a bit of research, I found out how to calculate large Carmichael numbers in this post. Basically, you take an integer k
, and check if $$6k+1$$, $$12k+1$$, and $$18k+1$$ are all prime. If they are, then $$(6k+1)(12k+1)(18k+1)$$ is a Carmichael number.
With this, we can write a pretty quick generation script for a Carmichael number:
1 | from Crypto.Util.number import isPrime |
Now, how do we solve the discrete log problem? Well, since our Carmichael number is actually the product of 3 primes that are each ~171 bits, this problem now becomes much easier to do, since our discrete log using a modulus of 512 bits now becomes equivalent to just doing 3 discrete logs using 3 different moduli of 171 bits. I actually kinda failed implementing it by hand, so I just Alperton to just solve the discrete log problem. Plug it in to get k
, then send it back to the server to get the flag!
uiuctf{c4rm1ch43l_7adb8e2f019bb4e0e8cd54e92bb6e3893}