Congratulations on getting a SQL shell!
Given that you have the SELECT @@global.local_infile permission and it returns 1, this means that the local_infile option is enabled for your MySQL user. This allows you to read files from the local machine (which in this context is the machine running the MySQL server, i.e., the remote Linux system) using SQL queries.
To read a file on the remote Linux system, you can use the LOAD_FILE() function in MySQL. Here's a basic example of how to use it:
SELECT LOAD_FILE('/path/to/your/file.txt');
Replace /path/to/your/file.txt with the path to the file you want to read. Note that you need to have the necessary file system permissions for the MySQL server's operating system user to read the file.
However, if you are restricted to certain paths or if the file is not directly readable due to permissions, you might need to look for other files or use different techniques.
Tips:
-
Know the MySQL Server's User: Understand which user the MySQL server runs as. Sometimes, you can find this information in configuration files (e.g., my.cnf or similar) or by checking process information.
-
File Path Guessing: If you don't know the exact path, try common files or guess paths. Start with files that are usually accessible like /etc/passwd, /etc/shadow, or files in /var/log/.
-
/proc and /sys: These virtual file systems can provide a lot of information about the system.
-
Check /tmp and Other Writable Directories: Sometimes, sensitive data might be written to temporary directories.
Example:
If you want to read /etc/passwd, you can do:
SELECT LOAD_FILE('/etc/passwd');
This will return the content of /etc/passwd, which can be useful for understanding the system's users.
Writing to a File:
If you also have write permissions or want to escalate your access, you can use SELECT ... INTO OUTFILE to write to a file:
SELECT 'your data here' INTO OUTFILE '/path/to/write/location.txt';
However, be cautious with this, as it might be restricted or monitored.
Escalation:
If your goal is to get a shell or execute system commands, and you find that local_infile=1 but still face limitations, consider exploring other SQLmap features or MySQL-specific escalation techniques, like writing to a MySQL plugin directory if you have appropriate permissions.
Caution:
- Be aware that actions you perform could be logged or monitored.
- Always consider the legal and operational implications of your actions.
Good luck with your CTF!