在Ubuntu 14.04上使用Lynis,Nmap,Nikto,Wapiti,w3af,Arachni和Skipfish进行Web应用程序和服务器安全性测试

时间:2020-03-21 11:47:32  来源:igfitidea点击:

开始之前

您可以从以下位置获得一次性安装所有内容的脚本:https://github.com/crylium/security-scripts-for-linux

$git clone https://github.com/crylium/security-scripts-for-linux.git
$bash ./security-scripts-for-linux/sec-tools-installer.sh

创建一个目录来存储安装文件:

$mkdir /home/"$USER"/bin

Lynis(社区版v1.6.4)

Lynis是针对基于Unix和Linux的系统的开源安全审核工具。
其主要目标是在系统上执行快速安全扫描,并确定改进的空间。

建议下载最新的Lynis版本。

用法

扫描可用的几个选项:

--man: view a man page.
-c: perform a full check of the system, printing out the results of each test to stdout.
-Q: perform a quick scan and do not wait for user input.
--logfile: define location and name of log file, instead of default /var/log/lynis.log.
--check-update: check for updates.
--pentest: run a non-privileged scan. Some of the tests will be skipped if they require root permissions.

我们可能需要root特权才能运行完整的安全审核:

$sudo lynis -c -Q --logfile /tmp/scan-lynis.txt

检查输出文件中是否有任何警告和/或者建议:

$sudo egrep -i 'warning|suggestion' /tmp/scan-lynis.txt

nmap

Nmap是一个开源端口扫描程序和网络浏览工具。
它可以用于网络发现和安全审核。

从存储库安装

$sudo apt-get update && sudo apt-get install nmap

用法

将目标主机(localhost)视为联机(-Pn),通过使用主动(-T4)计时模式仅扫描标准SSH,HTTP,HTTPS,MSSQL,MySQL和RDP端口(-p),并探测打开的端口以确定服务和版本信息(-sV)。
以正常(-oN)输出扫描,仅显示可能打开的端口(-open)。

$nmap -Pn -p T:22,80,443,1433,3306,3389 -sV -T4 --open -oN /tmp/scan-nmap.txt localhost

有几种扫描技术和许多其他扫描选项可用,请查看nmap手册页以获取更多信息。
也可以随时查看此页面上的一些nmap示例。

Nikto(v2.1.5)

Nikto是一个开放源代码的Web服务器扫描程序,可以对Web服务器进行多项测试,包括多个项目,检查过时的版本以及特定于版本的服务器问题。

从tar包安装

安装前提条件:

$sudo apt-get install perl perl-modules libnet-ssleay-perl libwhisker2-perl openssl

下载最新的Nikto版本并安装软件包:

$cd /home/"$USER"/bin
$wget http://cirt.net/nikto/nikto-2.1.5.tar.gz
$tar xvfz ./nikto-2.1.5.tar.gz
$mv ./nikto-2.1.5 ./nikto
$chown -R "$USER":"$USER" ./nikto;
$chmod u+x ./nikto/nikto.pl
$./nikto/nikto.pl -update
$cd ./nikto

用法

扫描可用的几个选项:

-H: view an extended help page.
-h: host to can.
-p: TCP port(s) to use for a scan.
-maxtime: maximum execution time per host, in seconds. Accepts minutes and hours such that all of these are one hour: 3600s, 60m, 1h
-ssl: only test SSL on the ports specified.
-nossl: do not use SSL to connect to the server.
-F: save the output file specified with -o (-output) option in this format.
-o: write output to the file specified.
-t: seconds to wait before timing out a request. Default timeout is 10 seconds.
-T: tuning options to control the test that Nikto will use against a target. By default, all tests are performed.
-update: update the plugins and databases directly from cirt.net.

调整选项:

0 - File Upload
1 - Interesting File/Seen in logs
2 - Misconfiguration/Default File
3 - Information Disclosure
4 - Injection (XSS/Script/HTML)
5 - Remote File Retrieval - Inside Web Root
6 - Denial of Service
7 - Remote File Retrieval - Server Wide
8 - Command Execution/Remote Shell
9 - SQL Injection
a - Authentication Bypass
b - Software Identification
c - Remote Source Inclusion
x - Reverse Tuning Options (i.e., include all except specified). The given string will be parsed from left to right, any x characters will apply to all characters to the right of the character.

仅使用SSL扫描端口443上的localhost,并将输出发送到文本文件/tmp/scan-nikto.txt
使用除拒绝服务(x6)以外的所有测试。

$./nikto.pl -h localhost -p 443 -ssl -F txt -o /tmp/scan-nikto.txt -t 5 -T x6

故障排除

无法使用SSL支持(有关SSL安装,请参阅文档)

$sudo apt-get install libnet-ssleay-perl

Wapiti(v2.3.0)

Wapiti是一个开放源代码Web应用程序漏洞扫描程序。
它可以检测以下漏洞:

  • 文件处理错误(本地和远程include/require,fopen,readfile)。

  • 数据库注入(PHP/JSP/ASP SQL注入和XPath注入)。

  • XSS(跨站点脚本)注入。

  • LDAP注入。

  • 命令执行检测(eval(),system(),passtru())。

  • CRLF注入(HTTP响应拆分,会话固定)。

从tar包安装

安装前提条件:

$sudo apt-get install python2.7 python2.7-dev python-requests python-ctypes python-beautifulsoup

下载最新的Wapiti版本并安装软件包:

$cd /home/"$USER"/bin
$wget http://netcologne.dl.sourceforge.net/project/wapiti/wapiti/wapiti-2.3.0/wapiti-2.3.0.tar.gz
$tar xvfz wapiti-2.3.0.tar.gz
$mv ./wapiti-2.3.0 ./wapiti
$chown -R "$USER":"$USER" ./wapiti;
$chmod u+x ./wapiti/bin/wapiti
$cd ./wapiti/bin

用法

要访问帮助页面:

$./wapiti --help | less

可用于扫描的几个选项:

-b: scope of the scan (page, folder or domain).
-t: timeout to wait for the server to send a response.
-n: a limit of URLs to browse with the same pattern.
-u: use colours to highlight vulnerabilities and anomalies in output.
-v: verbose level, from 0 to 2.
-f: report format type (txt, html etc).
-o: the name of the report file, or directory if html.
-i: resume the previous scan saved in the specified XML status file.
-k: resume the attacks without scanning the website again, loading the scan status from the specified file.
--verify-ssl: check and verify SSL certificates if set to 1, ignore if set to 0.
-m: the modules (and HTTP methods for each module) to use for attacks.

可用模块:

crlf - CRLF attack.
exec - command execution attack.
file - file handling attack.
sql - error-based SQL Injection attack.
xss - cross site scripting attack.
backup - backup attack. 
htaccess - htaccess attack, i.e. redirecting users coming from search engines to malware.
blindsql - blind SQL Injection attack.
permanentxss - cross site scripting attack.
nikto - Nikto attack. Nikto databases are csv files. http://cirt.net/nikto/UPDATES/2.1.5/db_tests

开始对本地主机进行扫描,详细并使用颜色突出显示漏洞:

$./wapiti http://localhost -v 2 -u

要仅浏览目标(不发送任何有效载荷),请使用-m" -all"停用每个模块:

$./wapiti http://localhost -v 2 -u -m "-all"

如果我们未指定HTTP方法,则将使用GET和POST。
要仅使用HTTP GET方法:

$./wapiti http://localhost -v 2 -u "-all,all:get"

在标准HTTPS端口上扫描localhost而不验证SSL证书,输出到/tmp/scan-wapiti.txt文件:

$./wapiti https://localhost -n 1 -b folder -f txt -o /tmp/scan-wapiti.txt -v 2 -t 5 -u --verify-ssl 0 -m "-all,all:get,exec:post,-nikto"

如果取消正在运行的扫描,则可以通过传递-i参数来恢复扫描。
当我们启动对localhost的扫描时,Wapiti创建一个/home /" $USER" /。 wapiti/scans/localhost.hmtl文件。
如果我们传递-i参数而未指定名称,则Wapiti将从" scans"文件夹中获取默认文件。

我们可以使用-k参数来恢复攻击。

w3af

w3af代表Web应用程序攻击和审核框架。
w3af是用于审核和攻击Web应用程序的完整环境。
该环境为Web漏洞评估和渗透测试提供了一个可靠的平台。

从GitHub安装

安装前提条件:

$sudo apt-get install git python2.7 python2.7-dev python-pip python-gitdb python-yaml libssl-dev libxml2-dev libxslt1-dev libyaml-dev libsqlite3-dev

注意:如果要使用w3af_gui,则可能需要python-gtksourceview2和python-webkit。

$dpkg --get-selections python-* | awk '{print '}
python-apt
python-apt-common
python-async
python-beautifulsoup
python-chardet
python-cheetah
python-colorama
python-configobj
python-debian
python-distlib
python-gdbm
python-gitdb
python-html5lib
python-json-pointer
python-jsonpatch
python-minimal
python-oauth
python-openssl
python-pam
python-pip
python-pkg-resources
python-prettytable
python-pycurl
python-requests
python-serial
python-setuptools
python-six
python-smmap
python-twisted-bin
python-twisted-core
python-twisted-names
python-twisted-web
python-urllib3
python-xapian
python-yaml
python-zope.interface

安装w3af:

$cd /home/"$USER"/bin
$git clone https://github.com/andresriancho/w3af.git
$chown -R "$USER":"$USER" ./w3af;
$chmod u+x ./w3af/w3af_console
$./w3af/w3af_console
$sudo /tmp/w3af_dependency_install.sh

用法(CLI)

创建一个示例扫描脚本:

$cat > /tmp/w3af-script.w3af