본문 바로가기

Dreamhack/CryptoPS

[Dreamhack][CryptoPS] [KCTF] RSA-wiener

728x90

1.문제 분석

  • RSA Wiener-Attack을 활용하는 문제
  • e가 매우 클 때를 가정한 문제

2. 기본 아이디어

  1. RSHack 툴을 사용한다. (매우 좋다.)
  2. 구한 d값으로 복호화를 진행한다.

3.문제 풀이

 

이 문제의 경우 public-key.pem.txt와 암호화된 flag.txt를 준다.

 

public-key.pem 파일에서 N과 e를 얻을 수 있을 것이다.

 

우선 openssl을 통해서 열어보면?

 

pem

 

앞선 LINECTF에서는 직접 변환했지만 이번엔 꿀팁을 들고 왔다.

 

https://8gwifi.org/PemParserFunctions.jsp

 

Online Certificate Decoder, decode crl,crt,csr,pem,privatekey,publickey,rsa,dsa,rasa publickey,ec

PEM Parser Thanks for using this software, for Cofee/Beer/Amazon bill and further development of this project please Share. Any private key value that you enter or we generate is not stored on this site, this tool is provided via an HTTPS URL to ensure tha

8gwifi.org

 

바로 온라인 PEM 오프너다.

 

온라인으로 바로 pem파일의 내용을 16진수로 바꿔준다는 장점이 있다!

 

https://www.rapidtables.com/convert/number/hex-to-decimal.html

 

Hexadecimal to Decimal Converter

From Binary Decimal Octal Hexadecimal Text To Binary Decimal Octal Hexadecimal Text

www.rapidtables.com

 

물론 이 사이트를 이용하면 바로 16진수를 10진수로 바꿀 수도 있다.

 

converter

 

매우 만족스럽다.

 

이제 구한 n, e와 flag.txt 속에 있는 16진수 데이터를 모두 10진수로 바꾸자.

 

바로 RSHack.py를 사용해 d값을 구해보면

 

rshack

 

 

get d

 

d를 구했으니 드디어 익스플로잇 코드를 짤 수 있다.

 

exploit

 

실행해보면?

 

flag

 

이렇게 플래그를 구할 수 있다.

728x90