The use of several methods of reading files in MySQL

Source: Internet
Author: User

MySQL database in the penetration process can use more features, in addition to reading data , you can also read and write to the file (but only if the permissions are sufficient)

Summarized under MySQL read file method in different versions roughly there are these 3:

1.load_file () 2.load Data infile ()

3.system Cat

Load_file () and load data infile read the file by creating a new table, reading the file as a string into the table, and then reading the data from the table.

However, there are usually two prerequisites:

1. Under the premise of having file permission

2.secure_file_priv is not NULL

The value of Secure_file_priv can be viewed in this way

After MySQL 5.6.34 version, the value of SECURE_FILE_PRIV is defaulted to null. Can be modified in the following ways

Under Windows :

Modify the Mysql.ini file and add an entry under [mysqld]: Secure_file_priv =

Save and restart MySQL.

Under Linux :

Add the local-infile=0 option under/ETC/MY.CNF [Mysqld].

1.load_file ()

First I create a document in the/tmp directory

Running MySQL

The SQL command is as follows:

1 Create Table text ); 2 Insert  into User (cmd) Values (Load_file ('/tmp/1.txt')); 3 Select *  from user;

 

2.load Data infile


In fact, there is no difference between the load data infile and Load_file () usage, but in the injection process, the load_file () function is often filtered out, but the load data infile is still available.

1 Load ' /tmp/1.txt '  into Table user;

3.system Cat


When the MySQL version is 5.x, you can use the system commands to read the file directly in addition to the last two methods

Attention:

1. This method can only be read locally, the system cannot be used when connecting to MySQL remotely.

2. Unable to read beyond the bounds.

The use of several methods of reading files in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.