jSQL Injection usage guide: a multifunctional tool for scanning and exploiting SQL injection in Kali Linux

jSQL Injection is a multipurpose penetration testing tool. Its main function is to find and exploit SQL-injection vulnerabilities. It is also able to:

  • explore databases from remote host
  • search for admin pages,
  • read files from remote host using injection,
  • create a web shell to remote host and open a terminal
  • create a SQL shell to remote host and open a terminal
  • upload a file to host
  • brute-force hashes
  • encode or decode a string
  • test multiple URLs for SQL injection

To detect and exploit SQL injections, I usually prefer sqlmap. It is a command-line utility, it can do a lot of things, it uses all possible SQL injection methods, tries to bypass server protection, can create shells and much more. It is also cross-platform, reliable and very effective. Since sqlmap is extremely powerful and flexible, for the command-line program it means a huge number of different options. For beginners this may seem too complicated.

JSQL Injection has an excellent graphical interface. The program is written in Java, it is cross-platform and very undemanding to resources. By the way, the executable file is only 2.14 megabytes.

But start in order – with the search for candidates for hacking. It will not be superfluous to recall that hacking is a criminal offense. Therefore, do not do anything that violates the law. Ideal (from the point of view of legality) is the use for training a vulnerable script on localhost or one of the specialized environments. Please, consider the articles:

1. Search for sites vulnerable to SQL injection

One of the ways to find vulnerable web sites is to use Google dorks. This table is borrowed from the site blackmoreops.com:

Google dorks Google dorks Google dorks
inurl:item_id= inurl:review.php?id= inurl:hosting_info.php?id=
inurl:newsid= inurl:iniziativa.php?in= inurl:gallery.php?id=
inurl:trainers.php?id= inurl:curriculum.php?id= inurl:rub.php?idr=
inurl:news-full.php?id= inurl:labels.php?id= inurl:view_faq.php?id=
inurl:news_display.php?getid= inurl:story.php?id= inurl:artikelinfo.php?id=
inurl:index2.php?option= inurl:look.php?ID= inurl:detail.php?ID=
inurl:readnews.php?id= inurl:newsone.php?id= inurl:index.php?=
inurl:top10.php?cat= inurl:aboutbook.php?id= inurl:profile_view.php?id=
inurl:newsone.php?id= inurl:material.php?id= inurl:category.php?id=
inurl:event.php?id= inurl:opinions.php?id= inurl:publications.php?id=
inurl:product-item.php?id= inurl:announce.php?id= inurl:fellows.php?id=
inurl:sql.php?id= inurl:rub.php?idr= inurl:downloads_info.php?id=
inurl:index.php?catid= inurl:galeri_info.php?l= inurl:prod_info.php?id=
inurl:news.php?catid= inurl:tekst.php?idt= inurl:shop.php?do=part&id=
inurl:index.php?id= inurl:newscat.php?id= inurl:productinfo.php?id=
inurl:news.php?id= inurl:newsticker_info.php?idn= inurl:collectionitem.php?id=
inurl:index.php?id= inurl:rubrika.php?idr= inurl:band_info.php?id=
inurl:trainers.php?id= inurl:rubp.php?idr= inurl:product.php?id=
inurl:buy.php?category= inurl:offer.php?idf= inurl:releases.php?id=
inurl:article.php?ID= inurl:art.php?idm= inurl:ray.php?id=
inurl:play_old.php?id= inurl:title.php?id= inurl:produit.php?id=
inurl:declaration_more.php?decl_id= inurl:news_view.php?id= inurl:pop.php?id=
inurl:pageid= inurl:select_biblio.php?id= inurl:shopping.php?id=
inurl:games.php?id= inurl:humor.php?id= inurl:productdetail.php?id=
inurl:page.php?file= inurl:aboutbook.php?id= inurl:post.php?id=
inurl:newsDetail.php?id= inurl:ogl_inet.php?ogl_id= inurl:viewshowdetail.php?id=
inurl:gallery.php?id= inurl:fiche_spectacle.php?id= inurl:clubpage.php?id=
inurl:article.php?id= inurl:communique_detail.php?id= inurl:memberInfo.php?id=
inurl:show.php?id= inurl:sem.php3?id= inurl:section.php?id=
inurl:staff_id= inurl:kategorie.php4?id= inurl:theme.php?id=
inurl:newsitem.php?num= inurl:news.php?id= inurl:page.php?id=
inurl:readnews.php?id= inurl:index.php?id= inurl:shredder-categories.php?id=
inurl:top10.php?cat= inurl:faq2.php?id= inurl:tradeCategory.php?id=
inurl:historialeer.php?num= inurl:show_an.php?id= inurl:product_ranges_view.php?ID=
inurl:reagir.php?num= inurl:preview.php?id= inurl:shop_category.php?id=
inurl:Stray-Questions-View.php?num= inurl:loadpsb.php?id= inurl:transcript.php?id=
inurl:forum_bds.php?num= inurl:opinions.php?id= inurl:channel_id=
inurl:game.php?id= inurl:spr.php?id= inurl:aboutbook.php?id=
inurl:view_product.php?id= inurl:pages.php?id= inurl:preview.php?id=
inurl:newsone.php?id= inurl:announce.php?id= inurl:loadpsb.php?id=
inurl:sw_comment.php?id= inurl:clanek.php4?id= inurl:pages.php?id=
inurl:news.php?id= inurl:participant.php?id=  
inurl:avd_start.php?avd= inurl:download.php?id=  
inurl:event.php?id= inurl:main.php?id=  
inurl:product-item.php?id= inurl:review.php?id=  
inurl:sql.php?id= inurl:chappies.php?id=  
inurl:material.php?id= inurl:read.php?id=  
inurl:clanek.php4?id= inurl:prod_detail.php?id=  
inurl:announce.php?id= inurl:viewphoto.php?id=  
inurl:chappies.php?id= inurl:article.php?id=  
inurl:read.php?id= inurl:person.php?id=  
inurl:viewapp.php?id= inurl:productinfo.php?id=  
inurl:viewphoto.php?id= inurl:showimg.php?id=  
inurl:rub.php?idr= inurl:view.php?id=  
inurl:galeri_info.php?l= inurl:website.php?id=  

Open sites one by one from the search results and try to add a quote to a variable in the query string. For example, the site address:

http://maral-mt.ru/maintextile.php?cat=1

Then I try so:

http://maral-mt.ru/maintextile.php?cat=1'

If you receive any SQL error message, then the site is likely to be vulnerable to SQL injection.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1

In addition, often vulnerable sites in response to a quote character, do not display anything, or the behavior of the site gives grounds for assuming insufficient data filtering.

It is definitely not worth looking for SQL injection in popular CMSs. Even if they are found there, they are almost always difficult to exploit. If you read this guide, then it is for sure (yet) not your level. Popular CMSs can become vulnerable due to vulnerable plugins (especially self-written ones). However, again, this is not our level yet.

2. Installing jSQL Injection

jSQL Injection is already preinstalled in Kali Linux. But the version there could be outdated is already available.

To check the latest release number visit the release page: https://github.com/ron190/jsql-injection/releases

To launch pre-installed jSQL Injection type in your console:

jsql

If you need, you can download the latest release:

wget https://github.com/`curl -s https://github.com/ron190/jsql-injection/releases | grep -E -o '/ron190/jsql-injection/releases/download/v[0-9]{1,2}.[0-9]{1,2}/jsql-injection-v[0-9]{1,2}.[0-9]{1,2}.jar' | head -n 1`

Once the file is downloaded, start the tool like this:

java -jar ./jsql-injection-v*.jar

The main window of the program looks like this:

By the way, this is one of those programs for pentesting that work fine in Windows.

To run in Windows, download the latest version from the official website: https://github.com/ron190/jsql-injection/releases

Run the downloaded file with a double click (you need to have a Java virtual machine).

3. Scanning a web site for SQL injection with jSQL

Working with the program is extremely simple. Just enter the address of the site and press ENTER.

The following screenshot shows that the site is vulnerable to three types of SQL injections at once.

We already got names of available databases.

Click on a database to explore its tables. You can see the contents of each table. Click on a table; wait for a list of columns appears:

Select columns of interest:

Click the table name by right button of your mouse and select ‘Load’:

The content of the table will appear:

Usually, tables with named administrator, users are the most interesting, because the can contain credentials.

If you are lucky and you found the administrator's credentials, it is still not enough. We still need to find an admin page where to enter these credentials.

4. Searching for admin pages with jSQL Injection

To do this, go to the next tab. Here we are met by a list of possible addresses. You can select one or more pages to check:

Convenience is that you do not need to use other programs.

Unfortunately, negligent programmers, who store passwords in clear test, are not very numerous. Quite often in the password line we see something like

8743b52063cd84097a65d1633f5c74f5

This is a hash. You can decipher it with brute force. And … jSQL Injection has a built-in brute-force.

5. Brute-forcing hashes using jSQL Injection

Undoubted convenience is that you do not need to look for other programs. There is support for many of the most popular hashes.

This is not the best solution. To brute-force on maximum speed use Hashcat.

However, of course, when there is no other program at hand or there is no time to learn Hashcat, jSQL Injection with the built-in brute force function will be very useful.

There are settings: you can specify what characters are in the password, the length range of the password.

6. Operations with files after detection of SQL injections

In addition to database operations – reading and modifying them, in the case of detecting SQL injections, the following file operations are possible:

  • reading files on the server
  • uploading new files to the server
  • unloading shells to the server

And all this is implemented in jSQL Injection!

There are restrictions – the SQL server must have enough privileges. Good system administrators disables it option and access to the file system cannot be obtained.

The presence of file privileges is easy enough to verify. Go to one of the tabs (reading files, creating a shell, uploading a new file) and try one of the specified operations.

Still very important remark – we need to know the exact absolute path to the file with which we will work – otherwise it will not work.

Look at the following screenshot:

Any response to a file operation is answered by us: No FILE privilege, and nothing can be done about it.

If instead you have another error:

Problem writing into [folder_name]

This means that you have incorrectly specified the absolute path to which the file should be written.

In order to assume the absolute path, you need, at a minimum, to know the operating system on which the server is running. To do this, switch to the Network tab.

Such a record (Win64 string) gives us reason to assume that we are dealing with Windows OS:

Keep-Alive: timeout=5, max=99
Server: Apache/2.4.17 (Win64) PHP/7.0.0RC6
Connection: Keep-Alive
Method: HTTP/1.1 200 OK
Content-Length: 353
Date: Fri, 11 Dec 2015 11:48:31 GMT
X-Powered-By: PHP/7.0.0RC6
Content-Type: text/html; charset=UTF-8

Here we have some kind of Unix (*BSD, Linux):

Transfer-Encoding: chunked
Date: Fri, 11 Dec 2015 11:57:02 GMT
Method: HTTP/1.1 200 OK
Keep-Alive: timeout=3, max=100
Connection: keep-alive
Content-Type: text/html
X-Powered-By: PHP/5.3.29
Server: Apache/2.2.31 (Unix)

And here we have CentOS:

Method: HTTP/1.1 200 OK
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Set-Cookie: PHPSESSID=9p60gtunrv7g41iurr814h9rd0; path=/
Connection: keep-alive
X-Cache-Lookup: MISS from t1.hoster.ru:6666
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.4.37
X-Cache: MISS from t1.hoster.ru
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Date: Fri, 11 Dec 2015 12:08:54 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=WINDOWS-1251

In Windows, the typical folder for sites is C:\Server\data\htdocs\. But, in fact, if someone thought of making a server on Windows, then, very likely, this person has not heard anything about file permissions. Therefore, the attempt starts directly from the C:/Windows/ folder:

As you can see, everything went fine from the first time.

But here I myself have doubts about the jSQL Injection shells themselves. If there are file privileges, then you can download anything with the web interface.

7. Mass check of sites on SQL-injection

And even this function is in jSQL Injection. Everything is extremely simple – insert a list of sites (you can import from a file), select the ones you want to check and click the button to start the operation.

Conclusion on jSQL Injection

jSQL Injection is a good, powerful tool for searching and post-exploiting vulnerable to SQL injection web sites. Its undoubted advantages: ease of use, built-in related functions. jSQL Injection can become a novice's best friend when analyzing websites.

Like all tools with a graphical interface, it cannot be automated in scripts. Nevertheless, some automation is possible in this program as well, thanks to the built-in function of mass web site scanning.

The jSQL Injection program is much easier to use than sqlmap. But sqlmap supports more types of SQL injection, has options for working with file-based firewalls and some other functions.

Outcome: jSQL Injection is the best friend of a beginner hacker.

Also recommended:

Leave a Reply

Your email address will not be published.

wp-puzzle.com logo