IT

John the Ripper를 통해 PDF 암호 찾아내기

Snowyegret 2023. 3. 18. 22:44

PDF에 암호를 걸어서 생성해놓고선 암호를 까먹어 버렸다.

검색을 해보니 pdfcrack이라는 오픈소스 프로그램이 나왔는데, 사용자가 컴파일을 해야 사용할 수 있었다.

컴파일 된 버전도 있었으나, PDF 버전 1-4까지만 지원했기에 내가 만들었던 PDF 버전인 6은 적용이 불가했다.

 

그래서 다른 방법을 찾아보니, 예전에도 자주 써먹었던 프로그램인 john the ripper를 사용한 방법이 나왔다.

다만 perl이 윈도우엔 기본적으로 깔려있지 않아 pdf2john.pl을 열기 위해 추가적인 프로그램을 설치해줘야 했다.

일단 간단하게 순서만 정리하자면...

 

1. John the Ripper다운로드

https://www.openwall.com/john/

 

John the Ripper password cracker

John the Ripper password cracker John the Ripper is an Open Source password security auditing and password recovery tool available for many operating systems. John the Ripper jumbo supports hundreds of hash and cipher types, including for: user passwords o

www.openwall.com

{버전}-jumbo-1 64-bit Windows binaries in 7z을 다운받으면 된다.

 

 

2. Perl 다운로드

https://www.activestate.com/products/perl/

 

Cross-platform, secure Perl by ActiveState - for developers and enterprise

Perl powered by the ActiveState Platform. Designed to meet the security and package management needs of Perl developers.

www.activestate.com

- Download Perl 클릭

- 로그인 창이 뜨면 로그인하지 않고, 아래 "Continue to download Perl without an account" 클릭

- Install via exe or cmd 알아서 선택

 

3. 설치한 Perl을 환경변수에 등록

- 시작 메뉴에 "시스템 환경 변수 편집"을 입력해서 환경 변수 창 오픈, "환경 변수" 버튼 클릭

- 사용자 변수 중 "Path" 더블클릭

- 새로 뜬 창에서 "새로 만들기"버튼 클릭, 이후 깔린 Perl 프로그램 bin폴더 경로 기입

  (기본설치의 경우 C:/Users/{계정\명}/AppData/Local/ActiveState/cache/bin였음)

 

4. 열려있는 모든 cmd창 종료 후, 아까 다운받은 John the Ripper의 run 폴더에서 cmd 오픈

 

5. 마찬가지로, run폴더 안에 복호화할 PDF파일 옮기기

 

6. perl pdf2john.pl {PDF명} > {임의의 Hash명}

  ex) perl pdf2john.pl test.pdf > test.hash

 

7. john.exe {아까 내보낸 임의의 Hash명}

ex) john.exe test.hash

 

7. 시간이 흘러 복호화가 완료되고, Session aborted가 뜨면 john.exe --show --format=PDF {Hash명}을 입력한다.

그러면 "{파일명}:{패스워드} 형식으로 패스워드가 출력된다.

ex) john.exe --show --format=PDF test.hash

      > test.pdf:123456