51Testing软件测试论坛

标题: Web安全测试经验 [打印本页]

作者: 感悟时分    时间: 2018-3-7 14:00
标题: Web安全测试经验
前言:

一个偶然的机会,有幸邀请到了一家国外专门做web安全的公司来对自己的web系统做安全测试。4
周下来,我与几位安全专家多次沟通,完成了对自己系统的威胁建模,渗透测试,白盒测试,一共发
现了28个漏洞。经验宝贵,因此有必要好好总结下。


Web应用程序是一个生态系统,从上至下包括Web Applications,Third-party Components,Web Server
Configuration,Web Server,Database,Applications,Operating System,Network。任何一个部件的问题,
都有可能引起整个web应用程序的安全问题。



安全测试的主要步骤,方法和工具:

作为一个安全顾问,在短时间内需要对一个不熟悉的web系统做安全测试,通常按照以下步骤来完成
1.威胁建模(Threat model)
2.侦查(Reconnaissance):Application , Network , Host
3.测试(Testing),包括手工和自动,方法分为白盒,黑盒,灰盒
4.报告(Reporting),列出方法,风险,以及推荐措施


威胁建模主要是为了识别出当前系统主要的风险点,想象以下一个攻击者入侵系统主要是为了什么,
一般包括:
Assets
   Data
   Functionality
Entities/processes
Interfaces and entry points
Control and data flows
Trust zones and boundaries
Threat agents
Security controls
一般会使用Viso画组件图,标明数据流和资产,识别风险点
此外还会用脑图工具画Attack Trees,列出每个风险点,以及达成风险的条件和对应应该采用的措施


举例:
Summary of Threats by Risk
Critical
T#1: Exhaust resources on the Docker host from the workspace container
T#2: Execute arbitrary code on the Docker host

High
T#5: Gain unauthorized access to sensitive CloudIDE functionality and data
T#6: Gain unauthorized access to source code

Medium
T#10: Run malicious docker images
T#11: Abuse insufficient logging and log monitoring




应用程序侦查主要是理解应用程序的攻击面,包括
URLs/pages
Parameters
Headers
Cookies
Etc…
可以使用Burp Spider,Skipfish等工具来侦查。顾问尤其推荐BurpSuite,它里面包括了很多小工具(
部分功能商业版


才有),包括了Scanner,Proxy,Sequencer,Intruder,Repeater,Spider等
功能。


网络侦查是为了理解系统网络的限制,包括
From external network to internal network
From internal network to external network
From network segments to other network segments
经常用的工具有Nmap,Zenmap,Vulnerability scanners
比如Demo nmap:
nmap -v -P0 -sSV -O 100.100.17.0/24 -oN cloudide-subnet.txt 可以输出这个网段所有的主机和IP


接下来的测试,主要是根据威胁建模识别的风险,攻击面(包括web应用程序自身,第三方组件漏洞,
网络架构)来进行。


漏洞分类,参考OWASP Top Ten (2013)

1.Injection
2.Broken Authentication and Session Management
3.Cross-Site Scripting (XSS)
4.Insecure Direct Object References
5.Security Misconfiguration
6.Sensitive Data Exposure
7.Missing Function Level Access Control
8.Cross-Site Request Forgery (CSRF)
9.Using Components with Known Vulnerabilities
10.Unvalidated Redirects and Forwards

每4年会更新一次,今年(2017)年将会重新更新Top Ten缺陷

安全测试工具

Manual and Semi-automated

Proxies
    WebScarab
    CharlesProxy
    Paros
BurpSuite
Network mapper/port scanner
    Nmap
Zenmap
    Skipfish

Metasploit framework
John The Ripper
Medusa
Sqlmap
Ettercap
Arpspoof
Kali Linux
     Contains all of the above
如果想做安全测试,建议直接使用Kali Linux的系统,因为这个系统里默认包含了上面大部分工具


Web Vulnerability Scanners

Fully automated
Great for catching low hanging fruits
    No understanding of application business model
Can generate large amounts of false positives
Triaging issues can be time consuming
Basic workflow:
    Point the tool to application entry points
    Select tests to perform
    Launch scan
    Triage findings
    Generate report

商业的:
Acunetix
Burp Scanner
IBM AppScan
QualysGuard
HP WebInspect


开源的:
Nikto2
Vega
w3af
Wapiti
ZAP

Static Analysis Tools

Coverity

HP Fortify 360
IBM AppScan Source


扩展阅读

Kali Linux - https://www.kali.org/
skipfish - https://github.com/spinkham/skipfish
BurpSuite Pro - https://portswigger.net/burp/
nmap - https://nmap.org/
Nikto - https://cirt.net/Nikto2
Metasploit Framework - https://www.metasploit.com/
Nessus - https://www.tenable.com/products/nessus-vulnerability-scanner
FuzzDB - https://github.com/fuzzdb-project/fuzzdb
Seclists - https://github.com/danielmiessler/SecLists

The Web Application Hacker's Handbook: Finding and Exploiting Security Flaws by Dafydd Stuttard
The Tangled Web: A Guide to Securing Modern Web Applications by Michal Zalewski
PortSwigger Web Security Blog: http://blog.portswigger.net/
Rsnake’s blog: https://www.whitehatsec.com/blog-tag/rsnake/
WebGoat: https://github.com/WebGoat/WebGoat/wiki
Damn Vulnerable Web Application: http://www.dvwa.co.uk/
OWASP: https://www.owasp.org/index.php/Main_Page






欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2