Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- arp
- RSA Common Modulas Attack
- OverTheWire Bandit Level 1 → Level 2
- dreamhack
- overthewire
- 드림핵
- pycrpytodome
- Franklin-Reiter Related Message Attack
- Cube Root Attack
- spoofing
- Bandit Level 1 → Level 2
- 암호학
- 웹해킹
- dns
- return address overflow
- CSRF
- picoCTF
- Montgomery Reduction
- cryptography
- rao
- weak key
- RSA
- 시스템해킹
- AES
- Hastad
- bandit
- Crypto
- redirect
- XSS
- shellcode
Archives
- Today
- Total
암호(수학) 등.. 공부한 거 잊을거 같아서 만든 블로그
[Cryptography] RSA Common Modulas Attack 본문
RSA Common Modulus Attack
동일한 모듈러 값으로 각기 다른 공개지수 e1, e2 ( gcd(e1, e2) = 1 인 ) 를 사용하여 암호화 한 암호문의 평문을 알아내는 공격이다.
아래와 같이 평문 M이 있을 때, 각기 다른 공개지수 e1, e2로 암호화 한 값을 C1, C2라 하자.
확장 유클리드 알고리즘은 필요하다면 아래 페이지를 참고하자.
구한 s와 t를 각각 e1과 e2를 이용하여 암호화한 값인 c1, c2에 지수승을 하고 둘을 곱하면 평문이 복원된다.
아래의 파이썬 코드는 RSA Common Modulas Attack 의 예시 코드이다.
poc.py
# poc.py
from sage.all import *
from Crypto.Util.number import getPrime
from Crypto.Util.number import long_to_bytes, bytes_to_long
# RSA Key Generation
p = getPrime(256)
q = getPrime(256)
n = p * q
e1, e2 = 3, 5
# Encryption
m = b"I hate cryptography"
print("Plain text:", m.decode())
m = bytes_to_long(m)
c1 = pow(m, e1, n)
c2 = pow(m, e2, n)
print(f"\nn = {n}")
print(f"c1 = {long_to_bytes(c1)}")
print(f"c2 = {long_to_bytes(c2)}")
# RSA Common Modulas Attack
u, s, t = xgcd(e1, e2) # Extended Euclidean Algorithm from sage
decrypted = (pow(c1, s, n) * pow(c2, t, n)) % n
decrypted = int(decrypted)
decrypted = long_to_bytes(decrypted)
print(f"\nAttck Result: {decrypted.decode()}")
poc.py 실행 결과
'Cryptography' 카테고리의 다른 글
[Cryptography] Hastad's Broadcast Attack (0) | 2024.02.13 |
---|---|
[Cryptography] RSA Cube Root Attack (0) | 2024.02.03 |
[Cryptograhpy] AES-ECB (Electronic Code Book) 운영 모드 (0) | 2023.07.07 |
[Cryptograhpy] AES (Advanced Encrytion Standard) (0) | 2023.07.07 |
[Cryptograhpy] CRT를 이용한 빠른 RSA 복호화 (0) | 2022.10.29 |