![]() |
|
[Tutorial] Using LOAD_FILE with Time Based MySQL Injection [HQ!] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45) +--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449) +---- Forum: Website Hacking (https://hackforums.net/forumdisplay.php?fid=43) +---- Thread: [Tutorial] Using LOAD_FILE with Time Based MySQL Injection [HQ!] (/showthread.php?tid=4271470) Pages: Pages
1
2
|
[Tutorial] Using LOAD_FILE with Time Based MySQL Injection [HQ!] - -DownFall - Jun 6, 2014 Today I'm going to be going over using LOAD_FILE with Time Based Blind SQL Injection. This method may look advanced, but if you take a look at my tutorials bit by bit the pieces will come together.
First off, Time Based Blind MySQL injection is a painful method, and very time consuming. However, if you're running out of options, this may be a chance to further exploit your vulnerable website. Now first off, time based should only be used when there is NO other option available. Blind MySQL injection is slow enough, but TIME BASED...even worse. Now skipping all the other options using MySQL Injection (digging for login info, into outfile, etc), we're going to jump into LOAD_FILE to get the tutorial started. LOAD_FILE does what it sounds like, loads a file. Ex: on linux. Here's an example of a UNION based attack using LOAD_FILE. Spoiler (Click to View) If magic_quotes_gpc = On, then convert your file name to HEX. Spoiler (Click to View) Using TIME BASED attack: Spoiler (Click to View) Now my page takes 3 seconds to load, this confirms I can use a time based attack. Now in order to use LOAD_FILE, you need file permissions. Here's an example of how to check if the MySQL user you're running has proper privileges. Spoiler (Click to View) If magic_quotes_gpc = On, convert to HEX. Spoiler (Click to View) Now my site takes an extra 3 seconds to load, which means the query returned a true value, meaning I have file privileges. Now that we know I can use LOAD_FILE, let's get some FPD (Full Path Disclosure) to get the full website path (which we will use to guess configuration files). Let's try converting our parameter to an array, in order the force a PHP error. Spoiler (Click to View) Now that we got the full site path, we're going to be using a function in SQL known as ISNULL(), to check whether the file we're looking for exists. As most programmers know, ! is a sign for NOT, so !isnull is the same is NOT null. First, let's try using a known file. Let's take a look at our HTML source. Spoiler (Click to View) Take a look at the HREF attribute, which specifies a destination link. It's referring to a file called "index.css". Now let's combine this with our full path, and check if the file exists using !isnull. Spoiler (Click to View) If magic_quotes_gpc = On Spoiler (Click to View) Success! Our page took an extra 3 seconds to send the request, meaning our file we're attempting to load is NOT NULL (meaning it exists). Now that we know how to check if files exist, let's try digging up some MySQL configuration files 😏 Here's a few common configuration file names. Code connect.phpNow this is my local server, I know the configuration file name. So to save time, let's try guessing one that DOES NOT exist, then one that EXISTS. Spoiler (Click to View) If magic_quotes_gpc = On Spoiler (Click to View) The page loads instantly, meaning our query returned false, and the file we're trying to load is NULL (does not exist). Now, let's try guessing the config file name (in this case, config.php). Spoiler (Click to View) If magic_quotes_gpc = On Spoiler (Click to View) Our page takes 3 seconds to send the request, meaning the file we're loading (config.php) EXISTS!! Now let's try pulling some data from it. As you may know, most PHP files start with "<?php". Let's try seeing if this is true using a combination of a TIME BASED attack, SUBSTRING, and LOAD_FILE. Spoiler (Click to View) If magic_quotes_gpc = On Spoiler (Click to View) The page takes 3 seconds to send the request, meaning this query returns true. This says that the first 5 characters in config.php are '<?php' Now we can dig up some of that login info using Blind MySQL injection. I hope you guys learned something new, enjoy! Resources: Time Based Blind SQLi using SLEEP() [Detailed] Boolean Based Blind Injection [Tutorial] [Behind The Scenes] Boolean Based Blind Injection (Blind SQLi) Mega Webhacking Tutorials By Me ✌ * - AnonRobot - Jun 6, 2014 good job this is a very HQ tutorial as always from you thank you so much :D * - -DownFall - Jun 7, 2014 Thanks for the reply. Any other feedback is appreciated. * - Tea. - Jun 7, 2014 IFNULL works too! here is an example Thank you OP! I am sure I will use this at one point or another. * - dotcppfile - Jun 7, 2014 Great tuts as always DownFall, thanks for sharing. * - -DownFall - Jun 7, 2014 (Jun 7, 2014 04:59 AM)Tea. Wrote: I'm not trying to be disrespectful or anything, I just started sqli yesterday and barely did any research, but I think that IFNULL is a better function. The syntax is much easier for this type of situation. Thanks for the input mate, however ~ they both essentially do the job, so I see neither as a "better" option. I'd label it as a personal preference, use whichever one you find more convenient. Here's an example using IFNULL(). PHP Code * - dotcppfile - Jun 9, 2014 This is probably one of the most important threads on HF and it got thrown away to the third page... * - JACK.HAMMER - Jun 9, 2014 man how we can read all the file config ?!! its imossible how we can guess all the file ? * - -DownFall - Jun 9, 2014 (Jun 9, 2014 02:14 AM)dotcppfile Wrote: This is probably one of the most important threads on HF and it got thrown away to the third page... It's always the best of threads, that usually do :3 (Jun 9, 2014 08:20 AM)JACK.HAMMER Wrote: man how we can read all the file config ?!! its imossible how we can guess all the file ? You guess character by character using SUBSTRING. Look at the tutorials I linked at the bottom where it says resources, study Blind MySQL injection, and you'll understand. * - wowrude - Jun 9, 2014 (Jun 9, 2014 02:14 AM)dotcppfile Wrote: This is probably one of the most important threads on HF and it got thrown away to the third page... How often have you had the need to use load_file in conjunction with a time based MySQL injection vulnerability? Just wondering. * - dotcppfile - Jun 9, 2014 (Jun 9, 2014 12:40 PM)wowrude Wrote: How often have you had the need to use load_file in conjunction with a time based MySQL injection vulnerability? I know you're job in this forum is to act smart and rude Lol but I would use Load_File whenever I can since it's one of the most important functions, don't you think? * - wowrude - Jun 9, 2014 (Jun 9, 2014 12:42 PM)dotcppfile Wrote: I know you're job in this forum is to act smart and rude Lol but I would use Load_File whenever I can since it's one of the most important functions, don't you think? Well if you totally disregard the fact that it's only available while the mysql user is root or dba (aka virtually never), I guess you could call it important. In that case I would argue that it would be more imperative to be able to correctly use INTO OUTFILE with various types of SQLi rather than load_file. * - Ρain - Jun 9, 2014 Nice. Been looking for a nice tutorial on both load_file and time based. * - -DownFall - Jun 9, 2014 (Jun 9, 2014 12:40 PM)wowrude Wrote: How often have you had the need to use load_file in conjunction with a time based MySQL injection vulnerability? I'll admit, it's not very common given the circumstances but it's something new here. (Jun 9, 2014 12:54 PM)CΦrtex Wrote: Nice. Been looking for a nice tutorial on both load_file and time based. Thanks for the feedback mate, I'm glad you'll be using this. * - dotcppfile - Jun 9, 2014 (Jun 9, 2014 12:54 PM)wowrude Wrote: Well if you totally disregard the fact that it's only available while the mysql user is root or dba (aka virtually never), I guess you could call it important. In that case I would argue that it would be more imperative to be able to correctly use INTO OUTFILE with various types of SQLi rather than load_file. I never did that, I did say that I will use it whenever I can and as long as anyone around here have the privileges to use LOAD_FILE then they should because they can do whatever they want with it. I donno what's your point, everyone knows that we can't always use it so please try to say something useful... |