diff --git a/shunyaCTF-2024/crypto/RivestSaltedAdelman/README.md b/shunyaCTF-2024/crypto/RivestSaltedAdelman/README.md new file mode 100644 index 0000000..5106e2d --- /dev/null +++ b/shunyaCTF-2024/crypto/RivestSaltedAdelman/README.md @@ -0,0 +1,58 @@ +# Rivest Salted Adleman + +### Domain: Crypto + +### Points: 100 + +### Solves: 24 + +## Given information + +``` +"Bob told me original q was eksored with some secret value 1 2 9 or 1 thru 9 something like that.... ughhh I am so confused...." +``` + +## Solution + +Since it was mentioned that q was XORed with the number 123456789, so we XORed the salted_q with 123456789 since XORing any number twice gives the same number. Saved the number obtained as q. +To find n, we multiplied p with q. +Since p,q and e are given, we found d using the formula `e.d ≡ 1 mod (p-1)(q-1)`. +Since c,d and n are given, we found m using the formul `m = c^d mod n`. +We get the message m which we convert to bytes. + +``` +from sympy import * +from Crypto.Util.number import * +p = 95224848836921243754124073456831190902097637702298493988505946669357481749059 + +salted_q = 62480590829144807189161429469255353976579455660965599518063804867866301233320 + +# q = salted_q ^ 123456789 + +q = 62480590829144807189161429469255353976579455660965599518063804867866211464637 + +salted_n = 5949704816946842021797594696485093255706996345339732550774644373410311670577880550185915164563052783086742129032939489765553432953432924892778486382904377417840 + +# n =p*q + +n = 5949704816946842021797594696485093255706996345339732550774644373410310233934264553505213393677159246237065515948410918285615690359863993103739392886526583 + +e = 65537 + +c = 332390996033761218977578960091058900061139210257883065481008023465866203213646838419152404854307189904898248026722555965488045307811040811040694129009535565921 + +# phi =(p-1)*(q-1) + +# d= inverse(e,phi) + +d = 546700679122539674615333556040606551808406426776261797469595929271661629747336488381383432365916543563803464361628868524035950851824227587881066617058001 + +# m = pow (c,d,n) + +m = 16423049470388721486924294439704034947965 + +flag = long_to_bytes(m) + +print (flag) +``` +