黑盒自动化WEB安全测试的实施

发表于:2016-3-02 11:10

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:光明矢    来源:51Testing软件测试网采编

  b.使用:wapiti使用比较简单,官网上给出的命令行及参数如下:
Usage
Wapiti-2.2.1 - A web application vulnerability scanner
Usage: python wapiti.py http://server.com/base/url/ [options]
Supported options are:
-s
--start
To specify an url to start with
----------
-x
--exclude
To exclude an url from the scan (for example logout scripts)
You can also use a wildcard (*)
Example : -x "http://server/base/?page=*&module=test"
or -x http://server/base/admin/* to exclude a directory
----------
-p
--proxy
To specify a proxy
Exemple: -p http://proxy:port/
----------
-c
--cookie
To use a cookie
----------
-t
--timeout
To fix the timeout (in seconds)
----------
-a
--auth
Set credentials for HTTP authentication
Doesn't work with Python 2.4
----------
-r
--remove
Remove a parameter from URLs
----------
-n
--nice
Define a limit of urls to read with the same pattern
Use this option to prevent endless loops
Must be greater than 0
----------
-m
--module
Set the modules and HTTP methods to use for attacks.
Example: -m "-all,xss:get,exec:post"
----------
-u
--underline
Use color to highlight vulnerables parameters in output
----------
-v
--verbose
Set the verbosity level
0: quiet (default), 1: print each url, 2: print every attack
----------
-f
--reportType
Set the type of the report
xml: Report in XML format
html: Report in HTML format
----------
-o
--output
Set the name of the report file
If the selected report type is "html", this parameter must be a directory
----------
-i
--continue
This parameter indicates Wapiti to continue with the scan from the specified
file, this file should contain data from a previous scan.
The file is optional, if it is not specified, Wapiti takes the default file
from \"scans\" folder.
----------
-k
--attack
This parameter indicates Wapiti to perform attacks without scanning again the
website and following the data of this file.
The file is optional, if it is not specified, Wapiti takes the default file
from \"scans\" folder.
----------
-h
--help
To print this usage message
------------------------------------------------------------
  说明:
  将wapiti的执行过程写成shell脚本,由计划任务定时去跑该脚本。然后将wapiti执行结果报告以邮件形式发到测试执行者及项目
  负责人的邮箱(非必要)。具体,在Ubuntu中,使用msmtp(邮件传输代理) + mutt(邮件用户代理) 来实现测试执行报告(邮件)自动
  发送。不使用postfix 、sendmail。msmtp支持TLS/SSL加密传输,比较可靠。而mutt在shell中使用较方便。
  思路:
  脚本AutoTest.sh按行读取文本url,由wapiti执行测试。将结果输出到generated-report.txt文件(执行结果报告)。
  脚本Analysis.sh读取generated-report.txt,wc -l命令统计关键字,得到执行用例数(爬过多少url),用例执行成功数,失败数。
  然后重定向到report.txt,将该report做为邮件的content,发送给项目负责人(非必要)。
  期望的执行结果是该页面没有xss、注入点等等问题。所以,发现该 url 存在xss等则认为用例执行失败,否则用例执行成功。
  发邮件的命令格式:mutt  -s   $主题   guangfu@xxx.com  -a  ~/xxtest/report/generated-report.txt      -s 邮件主题,-a 附件
  (关于mutt,具体上官网:http://www.mutt.org/)。
  扩展:
  根据 wapiti 的判断逻辑,增删测试点。提高测试效率。也就是修改wapiti的脚本,增加、删除测试点。
  另一方面,执行测试脚本需要被测网站的所有url列表。可以自己实现爬虫去动态的抓取,也可以使用工具(用开源的爬虫)。
  OWASP ZAP(Zed Attack Proxy)包含了一个蜘蛛程序,可以满足我们的要求,并且可以将被测站点的所有URL保存为一个文本
  文件。经过简单处理,该文本就可以做为测试脚本的输入。
  cat zap-url-guogf.com.txt  | awk  '{print $2}'  > url-guogf.com   #zap保存的url只有两列
  基本上算是一个半自动化的测试过程,要实现完全自动化,需要构建一个自动化的测试平台。通过平台耦合各个测试模块,最终
  实现测试全流程自动化。
  虽然全流程自动化目前还是一个梦想(目前看起来像一个玩具),但是如果你不去想,那永远也实现不了。先看看人家的自动化
  测试平台怎么设计的,再自己试着动手设计一个。画画功能图,试着写几个接口。
  脚本AutoTest.sh具体如下:
#! /bin/bash
count=1
cat url | while read line
do
echo "------$(date)------" >>generated-report.txt
wapiti $line >>generated-report.txt
echo "execute $count complete"
count=$(($count + 1))
done
exit 0
  3.如何评价(How to audit)?
  黑盒安全测试执行一般是在黑盒功能测试、性能测试完成之后进行。项目的安全建模是在需求分析阶段就加入的,具体流程可参考
  微软的SDL(Security Development Lifecycle)。在日常测试工作中加入黑盒安全自动化测试最易实施,效果可能也最好(考虑成本和安全需求)。
  从流程、组织、技术三方面保证测试质量。评审或是评价安全测试的活动,目前没有资格说。
  测试人员学习、了解安全方面的知识有助于提高测试覆盖率,当然也可以测出更多的BUG。但在系统测试中重点还是功能测试,功能测好了,
  才去考虑性能、安全等方面。
  注:本文关于安全测试方面的知识来源于《WEB安全测试》、《OWASP测试指南v3.0》。
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号