W3AF身份認證


title: W3AF身份認證
date: 2016-09-05 11:16
tags: Kali滲透測試 Web滲透測試


0x00 W3AF簡介

無論是Httrack,Nikto,Vega還是skipfish都是比較輕量級的tools。Web Application Attack and Audit Framework,基于Python編寫的Web滲透測試框架,此框架的目標是用來發現利用所有WEB應用程序bug。

不同于,nikto,vega,這些都是個別的大牛一時興起而寫出來的,畢竟個人的能力是有限的,所以很有可能這些工具也只是停留在一個版本就絕跡了,而w3af是基于開源的,所以它的生命周期會更長。

現在w3af一共覆蓋了9個大類近150個plugin:

  • audit:審計,在該組件下,集成了大量的web掃描工具。

  • infrastructure:基礎架構,主要用來掃描服務器的banner等基本信息。

  • grep:被動掃描類型。

  • evasion:逃避,主要是用來逃避目標的IDS,IBS的檢測。

  • mangle:主要是基于正則表達式的信息替換,比如注入,代碼修改。

  • auth:基于表單的身份認證。

  • brutefoece:暴力破解。

  • output:對掃描出來的結果輸出為特定的文件。

  • crawl:爬網,比如web spider,爬網爬得越全,那么發現漏洞的可能行越大。


attack

其實attack算是w3af中的第十類,但是不同與前九個,attck模塊不能人為的進行配置的,所有的攻擊的方法都是固定的,使用者無法修改。


0x01 原生安裝 w3af

測試Kali自帶w3af

在Kali Rolling上測試自帶w3af失敗。

殺死所有有關w3af的進程:

root@kali:~# ps -aux | grep -n w3af
root@kali:~# kill -9 8362 8437 9943 9945 9946 9949 10086

安裝步驟

在主目錄里實現源碼下載和安裝等相關步驟:

$ cd ~

更新update源:

apt-get update

安裝pip以及w3af

apt-get install -y python-pip w3af

升級pip:

pip install --upgrade pip

通過 github clone w3af 源代碼 :

git clone https://github.com/andresriancho/w3af.git

等待w3af源代碼下載完成,然后進入w3af目錄:

$ cd w3af
./w3af_console (./w3af.gui)

提示,需要安裝相關依賴:

$ apt-get install python-dev libxml2-dev libxslt1-dev zlib1g-dev

$ apt-get build-dep python-lxml

然后,可以使用pip或者運行替換腳本安裝w3af的相關依賴:

$ ./tmp/w3af_dependency_install.sh
#$ pip install pyClamd==0.3.15 PyGithub==1.21.0 GitPython==0.3.2.RC1 nltk==3.0.1 chardet==2.1.1 tblib==0.2.0 futures==2.1.5 ndg-httpsclient==0.3.3 pyasn1==0.1.8 lxml==3.4.4 scapy-real==2.2.0-dev guess-language==0.2 msgpack-python==0.4.4 python-ntlm==1.0.1 Jinja2==2.7.3 markdown==2.6.1 psutil==2.2.1 mitmproxy==0.13 ruamel.ordereddict==0.4.8

升級w3af

 root  ~  cd w3af 
 root  ~  w3af  git pull     

創建w3af快捷方式

Linux下的快捷方式文件都是已 .desktop 結尾的。

首先將 Kali 自帶的 w3af 的快捷方式 copy 到桌面

$: cp /usr/share/applications/w3af.desktop /root/Desktop 

然后打開 w3af.desktop 文件

 root  ~  cd Desktop          
 root  ~  Desktop  vim w3af.desktop 
[Desktop Entry]
Name=w3af
Encoding=UTF-8
Exec=sh -c "/root/w3af/w3af_gui"  <---修改為最新安裝的 w3af_gui 啟動路徑
Icon=kali-w3af.png
StartupNotify=false
Terminal=false
Type=Application
Categories=03-webapp-analysis;
X-Kali-Package=w3af

保存退出 vim,回到 desktop 為w3af.desktop 添加運行權限

 root  ~  Desktop  chmod u+x w3af.desktop 

w3af有兩種啟動方式,console和GUI啟動.


0x02 w3af_console 使用簡介


help命令

help 可以查看w3af當前模塊下可用的命令

 root  ~  w3af  ./w3af_console 
w3af>>> help
|----------------------------------------------------------------------------|
| start         | Start the scan.                                            |
| plugins       | Enable and configure plugins.                              |
| exploit       | Exploit the vulnerability.                                 |
| profiles      | List and use scan profiles.                                |
| cleanup       | Cleanup before starting a new scan.                        |
|----------------------------------------------------------------------------|
| help          | Display help. Issuing: help [command] , prints more        |
|               | specific help about "command"                              |
| version       | Show w3af version information.                             |
| keys          | Display key shortcuts.                                     |
|----------------------------------------------------------------------------|
| http-settings | Configure the HTTP settings of the framework.              |
| misc-settings | Configure w3af misc settings.                              |
| target        | Configure the target URL.                                  |
|----------------------------------------------------------------------------|
| back          | Go to the previous menu.                                   |
| exit          | Exit w3af.                                                 |
|----------------------------------------------------------------------------|
| kb            | Browse the vulnerabilities stored in the Knowledge Base    |
|----------------------------------------------------------------------------|

plugins模塊

plugins 功能下共有九個可供選擇的掃描模塊。

比如:

w3af/plugins>>> audit xss sqli lfi 

代表選擇同時 audit 下的 xsssqlilfi 掃描功能。

當然也可以指定 audit 下的所有功能

w3af/plugins>>> audit all

確定選擇以后,各個 功能 對應的 status 將會啟動。

w3af/plugins>>> crawl spider_man 
w3af/plugins>>> back

選擇完成以后使用 back 返回上一級目錄。

profile

我們可以就將所選的 plugins 下的配置通過 profile 保存,方便下次直接調用。

w3af>>> profiles save_as myScanProfile
Profile saved.

使用 profile

w3af/profiles>>> use fast_scan 

w3af 的全局設置

http-settings
w3af>>> http-settings 
w3af/config:http-settings>>> view
|----------------------------------------------------------------------------|
| Setting                 | Value | Modified | Description                        |
|----------------------------------------------------------------------------|
| url_parameter           |      |      | URL parameter                      |
|                         |      |      | (http://host.tld/path;<parameter>) |
| timeout                 | 0    |      | HTTP connection timeout            |
| headers_file            |      |      | HTTP headers filename which        |
|                         |      |      | contains additional headers to be  |
|                         |      |      | added in each request              |
|----------------------------------------------------------------------------|
| cookie_jar_file         |      |      | Cookie Jar file holding HTTP       |
|                         |      |      | cookies-指定一個包含cookies信息的文件                            |
| ignore_session_cookies  | False |      | Ignore session cookies             |
|----------------------------------------------------------------------------|
| ntlm_auth_url           |      |      | NTLM authentication domain (target |
|                         |      |      | domain name)                       |
| ntlm_auth_user          |      |      | NTLM authentication username       |
| ntlm_auth_passwd        |      |      | NTLM authentication password       |
| ntlm_auth_domain        |      |      | NTLM authentication domain         |
|                         |      |      | (windows domain name)              |
|----------------------------------------------------------------------------|
| rand_user_agent         | False |      | Use random User-Agent header 使用能夠隨機的user-agent       |
| max_file_size           | 400000 |      | Maximum file size                  |
| max_http_retries        | 2    |      | Maximum number of HTTP request     |
|                         |      |      | retries                            |
| user_agent  (默認agent為w3f,不建議使用默認值)            | w3af.org |      | User Agent header                  |
| max_requests_per_second | 0    |      | Maximum HTTP requests per second   |
|----------------------------------------------------------------------------|
| string_match_404        |      |      | Tag HTTP response as 404 if the    |
|                         |      |      | string is found in it's body       |
| always_404              |      |      | Comma separated list of URLs which |
|                         |      |      | will always be detected as 404     |
|                         |      |      | pages                              |
| never_404               |      |      | Comma separated list of URLs which |
|                         |      |      | will never be detected as 404      |
|                         |      |      | pages                              |
|----------------------------------------------------------------------------|
| proxy_port (支持外部代理)             | 8080 |      | Proxy TCP port                     |
| proxy_address           |      |      | Proxy IP address                   |
|----------------------------------------------------------------------------|
| basic_auth_user    (w3af的基本認證信息)     |      |      | Basic authentication username      |
| basic_auth_passwd       |      |      | Basic authentication password      |
| basic_auth_domain       |      |      | Basic authentication domain        |
|----------------------------------------------------------------------------|
不使用默認的 user-agent 使用隨機user-agent
w3af/config:http-settings>>> set rand_user_agent True 

設置完畢后 save ,并 back 上一級目錄

w3af/config:http-settings>>> save 
The configuration has been saved.
w3af/config:http-settings>>> back
The configuration has been saved.
w3af>>> 
misc-settings
w3af>>> misc-settings 
w3af/config:misc-settings>>> help
w3af/config:misc-settings>>> view
|----------------------------------------------------------------------------|
| Setting                 | Value                 | Modified | Description   |
|----------------------------------------------------------------------------|
| msf_location            | /opt/metasploit3/bin/ |          | Full path of  |
|                         |                       |          | Metasploit    |
|                         |                       |          | framework     |
|                         |                       |          | binary        |
|                         |                       |          | directory     |
|                         |                       |          | (/opt/metasploit3/bin/ |
|                         |                       |          | in most linux |
|                         |                       |          | installs)     |
|----------------------------------------------------------------------------|
| interface               | wlan0                 |          | Local         |
|                         |                       |          | interface     |
|                         |                       |          | name to use   |
|                         |                       |          | when          |
|                         |                       |          | sniffing,     |
|                         |                       |          | doing reverse |
|                         |                       |          | connections,  |
|                         |                       |          | etc.          |
| local_ip_address        | 192.168.1.6           |          | Local IP      |
|                         |                       |          | address to    |
|                         |                       |          | use when      |
|                         |                       |          | doing reverse |
|                         |                       |          | connections   |
|----------------------------------------------------------------------------|
| max_discovery_time      | 120                   |          | Maximum crawl |
|                         |                       |          | time          |
|                         |                       |          | (minutes)     |
| stop_on_first_exception | False                 |          | Stop scan     |
|                         |                       |          | after first   |
|                         |                       |          | unhandled     |
|                         |                       |          | exception     |
|----------------------------------------------------------------------------|
| non_targets             |                       |          | A comma       |
|                         |                       |          | separated     |
|                         |                       |          | list of URLs  |
|                         |                       |          | that w3af     |
|                         |                       |          | should        |
|                         |                       |          | completely    |
|                         |                       |          | ignore        |
|----------------------------------------------------------------------------|
| fuzz_url_filenames      | False                 |          | Indicates if  |
|                         |                       |          | w3af plugins  |
|                         |                       |          | will send     |
|                         |                       |          | fuzzed file   |
|                         |                       |          | names in      |
|                         |                       |          | order to find |
|                         |                       |          | vulnerabilities |
| fuzz_url_parts          | False                 |          | Indicates if  |
|                         |                       |          | w3af plugins  |
|                         |                       |          | will send     |
|                         |                       |          | fuzzed URL    |
|                         |                       |          | parts in      |
|                         |                       |          | order to find |
|                         |                       |          | vulnerabilities |
| fuzzable_headers        |                       |          | A list with   |
|                         |                       |          | all fuzzable  |
|                         |                       |          | header names  |
| fuzzed_files_extension  | gif                   |          | Indicates the |
|                         |                       |          | extension to  |
|                         |                       |          | use when      |
|                         |                       |          | fuzzing file  |
|                         |                       |          | content       |
| form_fuzzing_mode       | tmb                   |          | Indicates     |
|                         |                       |          | what HTML     |
|                         |                       |          | form combo    |
|                         |                       |          | values w3af   |
|                         |                       |          | plugins will  |
|                         |                       |          | use: all, tb, |
|                         |                       |          | tmb, t, b     |
| fuzz_form_files         | True                  |          | Indicates if  |
|                         |                       |          | w3af plugins  |
|                         |                       |          | will send     |
|                         |                       |          | payloads in   |
|                         |                       |          | the content   |
|                         |                       |          | of            |
|                         |                       |          | multipart/post |
|                         |                       |          | form files.   |
| fuzz_cookies            | False                 |          | Indicates if  |
|                         |                       |          | w3af plugins  |
|                         |                       |          | will use      |
|                         |                       |          | cookies as a  |
|                         |                       |          | fuzzable      |
|                         |                       |          | parameter     |
|----------------------------------------------------------------------------|

target 模塊

target 用于設置需要被掃描的目標地址。

w3af>>> target 
w3af/config:target>>> view 
|---------------------------------------------------------------------------|
| Setting   | Value | Modified | Description                                     |
|---------------------------------------------------------------------------|
| target_framework | unknown |      | Target programming framework                    |
|           |      |      | (unknown/php/asp/asp.net/java/jsp/cfm/ruby/perl) |
| target   (設置要掃描的網站url) |      |      | A comma separated list of URLs                  |
| target_os (設置要掃描的操作體統的主機ip)| unknown |      | Target operating system (unknown/unix/windows)  |
|---------------------------------------------------------------------------|
使用 target 指定目標地址
w3af/config:target>>> set target http://www.sina.com
w3af/config:target>>> view
|---------------------------------------------------------------------------|
| Setting  | Value      | Modified | Description                                |
|---------------------------------------------------------------------------|
| target_framework | unknown    |      | Target programming framework               |
|          |            |      | (unknown/php/asp/asp.net/java/jsp/cfm/ruby/perl) |
| target   | http://www.sina.com | Yes  | A comma separated list of URLs             |
| target_os | unknown    |      | Target operating system                    |
|          |            |      | (unknown/unix/windows)                     |
|---------------------------------------------------------------------------|
使用self-contained 將上述設置另存為
w3af>>> profiles 
w3af/profiles>>> save_as test2 self-contained
Profile saved.

由此,我們可以將 test1 設置與他人共享。


start 啟動掃描

w3af>>> start 

w3af下 script

w3af 也自帶了許多的掃描腳本

 root  ~  w3af  1  cd scripts                                         
 root  ~  w3af  scripts  1  ls                                      
allowed_methods.w3af             login_brute_password_only.w3af
以sqli.w3af 腳本為例

我們只需要修改腳本中的 target 地址便可以很方便的調用這些腳本了

 root  ~  w3af  scripts  1  cat sqli.w3af                              master 
# This is a demo of the attack plugin sql_shell

plugins
output console,text_file
output config text_file
set output_file output-w3af.txt
set verbose True
back
output config console
set verbose False
back

audit sqli

crawl web_spider
crawl config web_spider
set only_forward True
back

grep path_disclosure

back
target
set target http://www.sina.com <---更改為目標ip
back

start

bug-report

details 0

back

exit
./w3af_console -s scripts/scriptname.weaf
 root  ~  w3af  1  ./w3af_console -s scripts/sqli.w3af   

腳本執行完成,并會在w3af根目錄下生成 掃描報告 :

 root  ~  w3af  1  ls                                                   master 
circle.yml  extras           profiles  tools  w3af_api      w3af_gui
doc         output-w3af.txt  scripts   w3af   w3af_console

0x03 w3af 身份認證

w3af 支持四種身份認證: HTTP Basic , NTLM , Form , Cookie 。不同的認證方式對應不同的目標掃描類型。


HTTP Basic

HTTP Basic 并沒有嚴格意義上的加密,只不過是經過了簡單的編碼而已,基于這種認證,使用很簡單的破解工具便可以破解了。

我們以 win7 為例,首先安裝win7 IIS 服務器,選擇默認網站屬性,關閉默認網站的匿名身份認證,從而選擇基本身份認證,并設置登錄的用戶名和密碼。

然后通過Kali去訪問該網站,使用 wireshark 進行抓包,通過 Floow TCP Stream 分析,我們可以得到一個 經過 base64 進行編碼的 Authorization 信息,其中包含了登錄使用的用戶名和密碼,使用 W3af --> tools --> Encode/Uncode 功能對所得到編碼字符進行反向解碼便可以得到用戶名和密碼。


對使用 HTTP basic 認證的網站進行掃描

Configuration --> HTTP Config --> Basic HTTP Authentication 添加基本認證信息:

HTTP settings.png

等待一切配置完畢可以勾選需要掃描的模塊進行掃描,在 Target 中指定要掃描的目標 url。


NTML

NTML 身份認證是微軟一家才有的身份認證方式。

開啟 NTML 的認證功能需要使用到 IIS 的集成身份認證摸塊。NTML 也是windows 下的默認身份認證方式。

然后,回到 Kali 下的 W3af中配置 NTML 認證信息。

NTML Atuentication.png

同樣的,等待一切配置完畢可以勾選需要掃描的模塊進行掃描,在 Target 中指定要掃描的目標 url。


基于From的身份認證

基于From的身份認證便不能使用 W3af的HTTP Configuration了,而是使用 W3af中的 auth 插件,目前 w3af 提供兩種方式的 From 表單提交認證,即是 detailed 和 generic方法,detailed 相比于 generic的信息更加詳細。

detailed

選擇 W3f 下的 auth 插件在的 detailed 選擇,配置要提交的From信息,

Paste_Image.png

username_fieldpassword_field分別表示在表單中要提交的用戶名和密碼控件的 username,如下所示:

Paste_Image.png

auth_url 表示表單所在的url地址。

check_url 表示一旦表單驗證成功以后進入的頁面,主要是為了驗證表單提交是否成功。同樣,check_string 具有同樣的作用,它表示的是表單登錄成功以后可以看到的特征字符串。

ok,配置完成以后,選擇保存,繼續進行 crawl 爬網插件的配置。

crawl 下首先需要要選擇 web_Spider 一項勾選 only_forward指定在該 target url 下要掃描的特定的子目錄。同時還可以配置follow_regex (需要掃描的特定類型的頁面)和 ignore_regex (需要忽略的頁面) 以此進行交叉組合篩選。

Paste_Image.png

Cookie 雙因素身份認證

W3af Cookie認證方法比較嚴格的,直接copy cookies 信息是沒法認證的。所以首先需要導出 cookies 的信息。

比如,使用 firebug 導出 dvwa 站點的 cookies 信息,格式如下

192.168.56.101  FALSE   /   FALSE   PHPSESSID   c04db28f36bf5cd9a7e4ebfed22045bd
192.168.56.101  FALSE   /dvwa/  FALSE   security    high

將其改成 w3af 的專用格式:

# Netscape HTTP Cookie File
192.168.56.101  FALSE   /   FALSE   173151000100    PHPSESSID   c04db28f36bf5cd9a7e4ebfed22045bd
192.168.56.101  FALSE   /dvwa/  FALSE   173151000100    security    high
//domain        flag    path    secure_flag 時間信息,表示cookie有沒有過期  name    name value

根據 W3af 官方的解釋,使用cookie 信息時,每一行之上必需使用特定的數據格式,其各個數據字段之間必需使用 TAB 制表符來進行分隔,而不是空格。

更改完 cookies 格式以后,將其保存為本地文件,回到 w3af --> HTTP Configuration 下選擇 Cookies,導入保存的本地 cookie 文件。

cooki.jre.png

ok,cookies 信息配置完成,接下來可以在 audit 選擇相應的掃描插件然后填寫 target 開始掃描了。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,321評論 6 543
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,559評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,442評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,835評論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,581評論 6 412
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,922評論 1 328
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,931評論 3 447
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 43,096評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,639評論 1 336
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,374評論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,591評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,104評論 5 364
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,789評論 3 349
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,196評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,524評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,322評論 3 400
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,554評論 2 379

推薦閱讀更多精彩內容

  • Spring Cloud為開發人員提供了快速構建分布式系統中一些常見模式的工具(例如配置管理,服務發現,斷路器,智...
    卡卡羅2017閱讀 134,826評論 18 139
  • Spring Boot 參考指南 介紹 轉載自:https://www.gitbook.com/book/qbgb...
    毛宇鵬閱讀 46,922評論 6 342
  • title: vegadate: 2016-07-31 11:16tags: Kali滲透測試 Web滲透測試 0...
    曼路x_x閱讀 3,925評論 0 2
  • 簡介幾乎每個滲透測試項目都需要遵循嚴格的日程,多數由客戶的需求或開發交談日期決定。對于滲透測試者,擁有一種工具,它...
    紅色火苗閱讀 3,320評論 0 6
  • 第五章 自動化掃描 作者:Gilberto Najera-Gutierrez 譯者:飛龍 協議:CC BY-NC-...
    布客飛龍閱讀 3,397評論 0 39