Outils pour utilisateurs

Outils du site


ctf:2017:alexctf:cryptographie_150

Cryptographie 150 - What is this encryption?

Enoncé :

Fady assumed this time that you will be so n00b to tell what encryption he is using
he send the following note to his friend in plain sight :

p=0xa6055ec186de51800ddd6fcbf0192384ff42d707a55f57af4fcfb0d1dc7bd97055e8275cd4b78ec63c5d592f567c66393a061324aa2e6a8d8fc2a910cbee1ed9

q=0xfa0f9463ea0a93b929c099320d31c277e0b0dbc65b189ed76124f5a1218f5d91fd0102a4c8de11f28be5e4d0ae91ab319f4537e97ed74bc663e972a4a9119307

e=0x6d1fdab4ce3217b3fc32c9ed480a31d067fd57d93a9ab52b472dc393ab7852fbcb11abbebfd6aaae8032db1316dc22d3f7c3d631e24df13ef23d3b381a1c3e04abcc745d402ee3a031ac2718fae63b240837b4f657f29ca4702da9af22a3a019d68904a969ddb01bcf941df70af042f4fae5cbeb9c2151b324f387e525094c41

c=0x7fe1a4f743675d1987d25d38111fae0f78bbea6852cba5beda47db76d119a3efe24cb04b9449f53becd43b0b46e269826a983f832abb53b7a7e24a43ad15378344ed5c20f51e268186d24c76050c1e73647523bd5f91d9b6ad3e86bbf9126588b1dee21e6997372e36c3e74284734748891829665086e0dc523ed23c386bb520

Avec les éléments donnés nous pensons tout de suite à du rsa.

Nous l'avons résolu avec le logiciel SageMath.

Avant de pouvoir utiliser les valeurs données dans l'énoncé il faut les traduires de l'hexadécimal au décimal. Le site http://www.mobilefish.com/services/big_number/big_number.php le fait très bien.

./sage 
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.4, Release Date: 2016-10-18                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: p=869522411503633555850657111973929603627113478861018113816848433108177797                =>,Facteur 1
....: 25172403087219812801769953926964273413974692321761207006107499653330261138
....: 98553049
sage: q=130967498239956280789309361619267313669550833801075399508616099906714571                => Facteur 2
....: 49850288846976369982960384583841424977220385144435351119887497145134804975
....: 486079751
sage: e=766297813873972426643116709874317578271441392556392807529834168670310153                => Exposant
....: 07352014386648673994217913815581782186636488159185965227449303118783362862
....: 43589948671750445723364982956317635394981714999777327643558191037055959463
....: 95704361205962111489732270775657394676413094269445290065376811474983229889
....: 59979899800641
sage: c=898013894435695699573984069547075984927639234185685360303235460882787583    => Cipher (message chiffré)
....: 62331043119736437910117697032594835902900582040394367480829800897231925233
....: 80774527838935803140427806463331362614933672494585486504143906114941196250
....: 92476244194480036048744062822136093417043390251690152562280292002226433434
....: 30028828063008
sage: phi=(p-1)*(q-1)                                                                => Permet de calculer d
sage: d=inverse_mod(e,phi)                                                           => Calcul de d
sage: d
18936883706566089565183982761163360067838840777445463846869386030950038236998435836714296866300418740544099110893204385625543094093735175505576482105219020550596925375537703816973971295423941261736768673779496969415318449125906497680286964409673665181523565837769494950681114099888754750396643258941215566961


sage: n=p*q                                                                          => Création du modulo
sage: m=pow(c,d,n)                                                                => Déchiffrement du message
sage: m=212822782304456015822177007708562633221755283226671245315534931632445736
....: 2201641068235664016509
sage: hex(m).decode("hex")                             => Passe le message de décimal à hexa puis en ASCII
'ALEXCTF{RS4_I5_E55ENT1AL_T0_D0_BY_H4ND}'
ctf/2017/alexctf/cryptographie_150.txt · Dernière modification: 2017/02/06 15:36 par arkinar