1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pycryptodome , RSA

Last updated at Posted at 2023-11-01

[picoCTF][Cryptography][Mind your Ps and Qs]

Writeup

  • 素因数分解してくれるサイトがある。すげー。とりあえずnを素因数分解。

  • 素因数分解の結果
    p = 1899107986527483535344517113948531328331
    q = 674357869540600933870145899564746495319033

  • 必要なライブラリをインストール
    pip install pycryptodome

  • ググって、ほとんどコピペしました。
    pycryptodomeは初めて使いましたな。
dec.py
from Crypto.Util.number import *

c = 62324783949134119159408816513334912534343517300880137691662780895409992760262021
n = 1280678415822214057864524798453297819181910621573945477544758171055968245116423923
e = 65537
p = 1899107986527483535344517113948531328331
q = 674357869540600933870145899564746495319033

phi = (p-1)*(q-1)
# eを-1乗して、phiのmod(余り)を計算
d = pow(e, -1, phi)
# 暗号文をd乗して、nのmod(余り)を計算
P = pow(c, d, n)

print(long_to_bytes(P).decode())

answer.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?