天天看點

怎樣用 WPScan,Nmap 和 Nikto 掃描和檢查一個 WordPress 站點的安全性怎樣用 WPScan,Nmap 和 Nikto 掃描和檢查一個 WordPress 站點的安全性

數百萬個網站用着 wordpress ,這當然是有原因的。wordpress 是衆多内容管理系統中對開發者最友好的,本質上說你可以用它做任何事情。不幸的是,每天都有些吓人的報告說某個主要的網站被黑了,或者某個重要的資料庫被洩露了之類的,吓得人一愣一愣的。

如果你還沒有安裝 wordpress ,可以看下下面的文章。

在基于 debian 的系統上:

<a href="http://www.unixmen.com/install-wordpress-ubuntu-14-10/" target="_blank">如何在 ubuntu 上安裝 wordpress</a>

在基于 rpm 的系統上:

<a href="http://www.unixmen.com/install-configure-wordpress-4-0-benny-centos-7/" target="_blank">如何在 centos 上安裝 wordpress</a>

在這篇文章裡面,我将介紹 wpscan 的安裝過程,以及怎樣使用 wpscan 來定位那些已知的會讓你的站點變得易受攻擊的插件和主題。還有怎樣安裝和使用一款免費的網絡探索和攻擊的安全掃描軟體 nmap 。最後展示的是使用 nikto 的步驟。

怎樣用 WPScan,Nmap 和 Nikto 掃描和檢查一個 WordPress 站點的安全性怎樣用 WPScan,Nmap 和 Nikto 掃描和檢查一個 WordPress 站點的安全性

(題圖來自:codersmount.com)

<a target="_blank"></a>

wpscan 是一個 wordpress 黑盒安全掃描軟體,用 ruby 寫成,它是專門用來尋找已知的 wordpress 的弱點的。它為安全專家和 wordpress 管理者提供了一條評估他們的 wordpress 站點的途徑。它的基于開源代碼,在 gplv3 下發行。

在我們開始安裝之前,很重要的一點是要注意 wpscan 不能在 windows 下工作,是以你需要使用一台 linux 或者 os x 的機器來完成下面的事情。如果你隻有 windows 的系統,拿你可以下載下傳一個 virtualbox 然後在虛拟機裡面安裝任何你喜歡的 linux 發行版本。

wpscan 的源代碼放在 github 上,是以需要先安裝 git(lctt 譯注:其實你也可以直接從 github 上下載下傳打包的源代碼,而不必非得裝 git )。

<code>sudo apt-get install git</code>

git 裝好了,我們就要安裝 wpscan 的依賴包了。

<code>sudo apt-get install libcurl4-gnutls-dev libopenssl-ruby libxml2 libxml2-dev libxslt1-dev ruby-dev ruby1.9.3</code>

把 wpscan 從 github 上 clone 下來。

<code>git clone https://github.com/wpscanteam/wpscan.git</code>

現在我們可以進入這個建立立的 wpscan 目錄,通過 bundler 安裝必要的 ruby 包。

<code>cd wpscan</code>

<code>sudo gem install bundler &amp;&amp; bundle install --without test development</code>

現在 wpscan 裝好了,我們就可以用它來搜尋我們 wordpress 站點潛在的易受攻擊的檔案。wpcan 最重要的方面是它能列出不僅是插件和主題,也能列出使用者和縮略圖的功能。wpscan 也可以用來暴力破解 wordpress —— 但這不是本文要讨論的内容。

<code>ruby wpscan.rb --update</code>

要列出所有插件,隻需要加上 “--enumerate p” 參數,就像這樣:

<code>ruby wpscan.rb --url http(s)://www.yoursiteurl.com --enumerate p</code>

或者僅僅列出易受攻擊的插件:

<code>ruby wpscan.rb --url http(s)://www.yoursiteurl.com --enumerate vp</code>

下面是一些例子:

<code>| name: ukiscet</code>

<code>| location: http://********.com/wp-content/plugins/akismet/</code>

<code></code>

<code>| name: audio-player</code>

<code>| location: http://********.com/wp-content/plugins/audio-player/</code>

<code>|</code>

<code>| * title: audio player - player.swf playerid parameter xss</code>

<code>| * reference: http://seclists.org/bugtraq/2013/feb/35</code>

<code>| * reference: http://secunia.com/advisories/52083</code>

<code>| * reference: http://osvdb.org/89963</code>

<code>| * fixed in: 2.0.4.6</code>

<code>| name: bbpress - v2.3.2</code>

<code>| location: http://********.com/wp-content/plugins/bbpress/</code>

<code>| readme: http://********.com/wp-content/plugins/bbpress/readme.txt</code>

<code>| * title: bbpress - multiple script malformed input path disclosure</code>

<code>| * reference: http://xforce.iss.net/xforce/xfdb/78244</code>

<code>| * reference: http://packetstormsecurity.com/files/116123/</code>

<code>| * reference: http://osvdb.org/86399</code>

<code>| * reference: http://www.exploit-db.com/exploits/22396/</code>

<code>| * title: bbpress - forum.php page parameter sql injection</code>

<code>| * reference: http://osvdb.org/86400</code>

<code>| name: contact</code>

<code>| location: http://********.com/wp-content/plugins/contact/</code>

列舉主題和列舉插件差不多,隻要用"--enumerate t"就可以了。

<code>ruby wpscan.rb --url http(s)://www.host-name.com --enumerate t</code>

或者隻列出易受攻擊的主題:

<code>ruby wpscan.rb --url http(s)://www.host-name.com --enumerate vt</code>

例子的輸出:

<code>| name: path</code>

<code>| location: http://********.com/wp-content/themes/path/</code>

<code>| style url: http://********.com/wp-content/themes/path/style.css</code>

<code>| description:</code>

<code>| name: pub</code>

<code>| location: http://********.com/wp-content/themes/pub/</code>

<code>| style url: http://********.com/wp-content/themes/pub/style.css</code>

<code>| name: rockstar</code>

<code>| location: http://********.com/wp-content/themes/rockstar/</code>

<code>| style url: http://********.com/wp-content/themes/rockstar/style.css</code>

<code>| * title: woothemes wooframework remote unauthenticated shortcode execution</code>

<code>| * reference: https://gist.github.com/2523147</code>

<code>| name: twentyten</code>

<code>| location: http://********.com/wp-content/themes/twentyten/</code>

<code>| style url: http://********.com/wp-content/themes/twentyten/style.css</code>

wpscan 也可以用來列舉某個 wordpress 站點的使用者和有效的登入記錄。攻擊者常常這麼做——為了獲得一個使用者清單,好進行暴力破解。

<code>ruby wpscan.rb --url http(s)://www.host-name.com --enumerate u</code>

關于 wpscan ,我要說的最後一個功能是列舉 timthub (縮略圖)相關的檔案。近年來,timthumb 已經成為攻擊者眼裡的一個常見目标,因為無數的漏洞被找出來并發到論壇上、郵件清單等等地方。用下面的指令可以通過 wpscan 找出易受攻擊的 timthub 檔案:

<code>ruby wpscan.rb --url http(s)://www.host-name.com --enumerate tt</code>

nmap 是一個開源的用于網絡探索和安全審查方面的工具。它可以迅速掃描巨大的網絡,也可一單機使用。nmap 用原始 ip 資料包通過不同尋常的方法判斷網絡裡那些主機是正在工作的,那些主機上都提供了什麼服務(應用名稱和版本),是什麼作業系統(以及版本),用的什麼類型的防火牆,以及很多其他特征。

要在基于 debian 和 ubuntu 的作業系統上安裝 nmap ,運作下面的指令:

<code>sudo apt-get install nmap</code>

輸出樣例

<code>reading package lists... done</code>

<code>building dependency tree</code>

<code>reading state information... done</code>

<code>the following new packages will be installed:</code>

<code>nmap</code>

<code>0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.</code>

<code>need to get 1,643 kb of archives.</code>

<code>after this operation, 6,913 kb of additional disk space will be used.</code>

<code>get:1 http://mirrors.service.networklayer.com/ubuntu/ precise/main nmap amd64 5.21-1.1ubuntu1 [1,643 kb]</code>

<code>fetched 1,643 kb in 0s (16.4 mb/s)</code>

<code>selecting previously unselected package nmap.</code>

<code>(reading database ... 56834 files and directories currently installed.)</code>

<code>unpacking nmap (from .../nmap_5.21-1.1ubuntu1_amd64.deb) ...</code>

<code>processing triggers for man-db ...</code>

<code>setting up nmap (5.21-1.1ubuntu1) ...</code>

輸出 nmap 的版本:

<code>nmap -v</code>

或者

<code>nmap --version</code>

<code>nmap version 5.21 ( http://nmap.org )</code>

要在基于 rhel 的 linux 上面安裝 nmap ,輸入下面的指令:

<code>yum install nmap</code>

<code>loaded plugins: protectbase, rhnplugin, security</code>

<code>0 packages excluded due to repository protections</code>

<code>setting up install process</code>

<code>resolving dependencies</code>

<code>--&gt; running transaction check</code>

<code>---&gt; package nmap.x86_64 2:5.51-2.el6 will be installed</code>

<code>--&gt; finished dependency resolution</code>

<code>dependencies resolved</code>

<code>================================================================================</code>

<code>package arch version repository size</code>

<code>installing:</code>

<code>nmap x86_64 2:5.51-2.el6 rhel-x86_64-server-6 2.8 m</code>

<code>transaction summary</code>

<code>install 1 package(s)</code>

<code>total download size: 2.8 m</code>

<code>installed size: 0</code>

<code>is this ok [y/n]: y</code>

<code>downloading packages:</code>

<code>nmap-5.51-2.el6.x86_64.rpm | 2.8 mb 00:00</code>

<code>running rpm_check_debug</code>

<code>running transaction test</code>

<code>transaction test succeeded</code>

<code>running transaction</code>

<code>installing : 2:nmap-5.51-2.el6.x86_64 1/1</code>

<code>verifying : 2:nmap-5.51-2.el6.x86_64 1/1</code>

<code>installed:</code>

<code>nmap.x86_64 2:5.51-2.el6</code>

<code>complete!</code>

輸出 nmap 版本号:

<code>nmap version 5.51 ( http://nmap.org )</code>

你可以用 nmap 來獲得很多關于你的伺服器的資訊,它可以讓你站在對你的網站不懷好意的人的角度看你自己的網站。

是以,請僅用它測試你自己的伺服器或者在行動之前通知伺服器的所有者。

nmap 的作者提供了一個測試伺服器:

<code>scanme.nmap.org</code>

有些指令可能會耗時較長:

要掃描一個 ip 位址或者一個主機名(全稱域名),運作:

<code>nmap 192.168.1.1</code>

輸出樣例:

怎樣用 WPScan,Nmap 和 Nikto 掃描和檢查一個 WordPress 站點的安全性怎樣用 WPScan,Nmap 和 Nikto 掃描和檢查一個 WordPress 站點的安全性

fig.01: nmap in action

掃描以獲得主機的作業系統:

<code>sudo nmap -o 192.168.1.1</code>

加上“-”或者“/24”來一次性掃描某個範圍裡面的多個主機:

<code>sudo nmap -pn xxx.xxx.xxx.xxx-yyy</code>

掃描某個範圍内可用的服務:

<code>sudo nmap -sp network_address_range</code>

掃描 ip 位址時部進行反向 dns 解析。多數情況下這會加快你獲得結果的速度:

<code>sudo nmap -n remote_host</code>

掃描一個特定端口而不是所有常用端口:

<code>sudo nmap -p port_number remote_host</code>

掃描一個網絡,找出哪些伺服器線上,分别運作了什麼服務。

這就是傳說中的主機探索或者 ping 掃描:

<code>nmap -sp 192.168.1.0/24</code>

<code>host 192.168.1.1 is up (0.00035s latency).</code>

<code>mac address: bc:ae:c5:c3:16:93 (unknown)</code>

<code>host 192.168.1.2 is up (0.0038s latency).</code>

<code>mac address: 74:44:01:40:57:fb (unknown)</code>

<code>host 192.168.1.5 is up.</code>

<code>host nas03 (192.168.1.12) is up (0.0091s latency).</code>

<code>mac address: 00:11:32:11:15:fc (synology incorporated)</code>

<code>nmap done: 256 ip addresses (4 hosts up) scanned in 2.80 second</code>

了解端口配置和如何發現你的伺服器上的攻擊目标隻是確定你的資訊和你的 vps 安全的第一步。

<code>wget https://cirt.net/nikto/nikto-2.1.4.tar.gz</code>

你可以用某個歸檔管理工具解包,或者如下同時使用 tar 和 gzip :

<code>tar zxvf nikto-2.1.4.tar.gz</code>

<code>cd nikto-2.1.4</code>

<code>perl nikto.pl</code>

安裝正确的話會得到這樣的結果:

<code>- ***** ssl support not available (see docs for ssl install) *****</code>

<code>- nikto v2.1.4</code>

<code>---------------------------------------------------------------------------</code>

<code>+ error: no host specified</code>

<code>-config+ use this config file</code>

<code>-cgidirs+ scan these cgi dirs: 'none', 'all', or values like "/cgi/ /cgi-a/"</code>

<code>-dbcheck check database and other key files for syntax errors</code>

<code>-display+ turn on/off display outputs</code>

<code>-evasion+ ids evasion technique</code>

<code>-format+ save file (-o) format</code>

<code>-host+ target host</code>

<code>-help extended help information</code>

<code>-id+ host authentication to use, format is id:pass or id:pass:realm</code>

<code>-list-plugins list all available plugins</code>

<code>-mutate+ guess additional file names</code>

<code>-mutate-options+ provide extra information for mutations</code>

<code>-output+ write output to this file</code>

<code>-nocache disables the uri cache</code>

<code>-nossl disables using ssl</code>

<code>-no404 disables 404 checks</code>

<code>-port+ port to use (default 80)</code>

<code>-plugins+ list of plugins to run (default: all)</code>

<code>-root+ prepend root value to all requests, format is /directory</code>

<code>-ssl force ssl mode on port</code>

<code>-single single request mode</code>

<code>-timeout+ timeout (default 2 seconds)</code>

<code>-tuning+ scan tuning</code>

<code>-update update databases and plugins from cirt.net</code>

<code>-vhost+ virtual host (for host header)</code>

<code>-version print plugin and database versions</code>

<code>+ requires a value</code>

<code>note: this is the short help output. use -h for full help.</code>

這個報錯隻是告訴我們沒有給出必要的參數。ssl 支援可以通過安裝相關的 perl ssl 子產品得到(sudo apt-get install libnet-ssleay-perl)。

在開始使用之前我們需要先更新 nikto 資料庫:

<code>/usr/local/bin/nikto.pl -update</code>

下面的指令可以列出可用的 nikto 插件。

<code>nikto.pl -list-plugins // to list the installed plugins //</code>

我們用一個 url 來在做個簡單的測試。

<code>perl nikto.pl -h http://www.host-name.com</code>

<code>$ nikto -h http://www.host-name.com</code>

<code>+ target ip: 1.2.3.4</code>

<code>+ target hostname: host-name.com</code>

<code>+ target port: 80</code>

<code>+ start time: 2012-08-11 14:27:31</code>

<code>+ server: apache/2.2.22 (freebsd) mod_ssl/2.2.22 openssl/1.0.1c dav/2</code>

<code>+ robots.txt contains 4 entries which should be manually viewed.</code>

<code>+ mod_ssl/2.2.22 appears to be outdated (current is at least 2.8.31) (may depend on server version)</code>

<code>+ etag header found on server, inode: 5918348, size: 121, mtime: 0x48fc943691040</code>

<code>+ mod_ssl/2.2.22 openssl/1.0.1c dav/2 - mod_ssl 2.8.7 and lower are vulnerable to a remote buffer overflow which may allow a remote shell (difficult to exploit). cve-2002-0082, osvdb-756.</code>

<code>+ allowed http methods: get, head, post, options, trace</code>

<code>+ osvdb-877: http trace method is active, suggesting the host is vulnerable to xst</code>

<code>+ /lists/admin/: phplist pre 2.6.4 contains a number of vulnerabilities including remote administrative access, harvesting user info and more. default login to admin interface is admin/phplist</code>

<code>+ osvdb-2322: /gallery/search.php?searchstring=&lt;script&gt;alert(document.cookie)&lt;/script&gt;: gallery 1.3.4 and below is vulnerable to cross site scripting (xss). upgrade to the latest version. http://www.securityfocus.com/bid/8288.</code>

<code>+ osvdb-7022: /calendar.php?year=&lt;script&gt;alert(document.cookie);&lt;/script&gt;&amp;month=03&amp;day=05: dcp-portal v5.3.1 is vulnerable to cross site scripting (xss). http://www.cert.org/advisories/ca-2000-02.html.</code>

<code>+ osvdb-3233: /phpinfo.php: contains php configuration information</code>

<code>+ osvdb-3092: /system/: this might be interesting...</code>

<code>+ osvdb-3092: /template/: this may be interesting as the directory may hold sensitive files or reveal system information.</code>

<code>+ osvdb-3092: /updates/: this might be interesting...</code>

<code>+ osvdb-3092: /readme: readme file found.</code>

<code>+ 6448 items checked: 1 error(s) and 14 item(s) reported on remote host</code>

<code>+ end time: 2012-08-11 15:52:57 (5126 seconds)</code>

<code>+ 1 host(s) tested</code>

<code>$</code>

nikto 是一個非常輕量級的通用工具。因為 nikto 是用 perl 寫的,是以它可以在幾乎任何伺服器的作業系統上運作。

有想說的,留下你的評論。

原文釋出時間:2015-04-26

本文來自雲栖合作夥伴“linux中國”

繼續閱讀