- SQLMAP installation and usage in Ubuntu and Kali linux
- Sql Injection Tool to discover vulnerabilities on your site
- What is SQLMAP?
- UBUNTU
- KALI LINUX
- UBUNTU
- KALI LINUX
- UBUNTU
- KALI LINUX
- UBUNTU
- KALI LINUX
- REWRITED URLS
- Инструменты Kali Linux
- Список инструментов для тестирования на проникновение и их описание
- sqlmap
- Описание sqlmap
- Справка по sqlmap
- Руководство по sqlmap
- Доступные tamper скрипты sqlmap
- Примеры запуска sqlmap
- Установка sqlmap
- Установка sqlmap в Linux
- Установка sqlmap в Windows
SQLMAP installation and usage in Ubuntu and Kali linux
Sql Injection Tool to discover vulnerabilities on your site
Let’s talk about the penetration testing using one of the KALI linux tool called SQLMAP.
What is SQLMAP?
sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers. It is a open source tool to use sql injection in better and simpler way.
It is pre installed on KALI LINUX Operating System.
Let’s go to see how to install this tool in your ubuntu machine and run test to hack the database of any sql injection vulnerable websites.
First download SQLMAP in your machine by using below command.
This command will download latest sqlmap package from github into your current directory.
Now run this command to extract your sqlmap package from tar file.
If all done successfully go to to your sqlmap directory and run below command to test sqlmap in ubuntu.
Now Let’s Hack begin.
You can find may sql injection vulnerable websites through google search by passing bellow query
open www.google.com and type php?id=1
Next from search result open website which url something like that..
Now check url is venerable or not by adding ‘ and hit enter if page gives sql error means You are lucky, Given url is ready for hack.
Go to your sqlmap directory and Run this command to test sql injunction.
Where
-u :- means url we are going to hack
–dbs :- command will show hack-able list of database.
UBUNTU
KALI LINUX
Open terminal and run below command no need to install sqlmap in KALI LINUX
In below image you can see the hacked database
Now hack the tables of hacked database.
Where
-D :- means database name you are going to hack
–tables :- command will show all the tables of hacked database.
UBUNTU
KALI LINUX
You can see the table list of hacked database.
Next task is fetch the column of any table.
Where
-T :- means Table name you are going to hack
–columns :- command will show all the columns of table.
UBUNTU
KALI LINUX
Below you can see the list of columns of the hacked table.
Now this is your final task fetch real data from tables.
Where
-C :- means Column name of the table.
–dump :- command will show all data of given columns.
UBUNTU
KALI LINUX
Above command will show the data of particular column, You can use this trick to hack website database which are less secure and must use this testing on your own website to test your website is secure or not.
REWRITED URLS
It’s also possible to test for SQL injection vulnerabilities with using sqlmap with a url that is using mod rewrite
To test your sites that have urls like: http://mysite.com/?id=1
But also sites that have clean urls, like: http://mysite.com/1
You should use * in your URI, creating URI injection point(s). So instead of using:
See sqlmap wiki for more usage options. From that page:
URI injection point
There are special cases when injection point is within the URI itself. sqlmap does not perform any automatic test against URI paths, unless manually pointed to. You have to specify these injection points in the command line by appending an asterisk ( * ) after each URI point that you want sqlmap to test for and exploit a SQL injection.
This is particularly useful when, for instance, Apache web server’s mod_rewrite module is in use or other similar technologies.
An example of valid command line would be:
Источник
Инструменты Kali Linux
Список инструментов для тестирования на проникновение и их описание
sqlmap
Описание sqlmap
sqlmap — это инструмент с открытым исходным кодом для тестирования на проникновение, который автоматизирует процесс выявления и эксплуатации уязвимости SQL-инъекця и захват серверов баз данных. Он поставляется с мощным движком выявления и многими нишевыми функциями для конечного тестера на проникновение, имеет широкий набор возможностей, начиная от сбора отпечатков баз данных по полученной от них данным, до доступа к файловой системе и выполнения команд в операционной системе посредством внеполосных (out-of-band) подключений.
- Полная поддержка для таких систем управления базами данных как MySQL, Oracle, PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite, Firebird, Sybase, SAP MaxDB и HSQLDB.
- Полная поддержка шести техник SQL-инъекций: слепая логическая (boolean-based blind), слепая, основанная на времени (time-based blind), основанная на ошибке (error-based), основанная на запросе UNION (UNION query-based), многоярусные запросы (stacked queries) и внеполосная (out-of-band).
- Поддержка прямого подключения к базе данных без прохода через SQL инъекцию, посредством введения учётных данных СУБД, IP адреса, порта и имени БД.
- Поддержка перечисления пользователей, хешей паролей, привилегий, ролей, БД, таблиц и колонок.
- Автоматическое распознавание форматов хешей паролей и предложение их взлома с использованием атаки по словарю.
- Поддержка сдампливания записей таблиц БД, диапазона записей или указанных колонок по пользовательскому выбору.
- Пользователь также может выбрать сдампливать только диапазон символов из каждой записи колонки.
- Поддержка поиска указанных имён БД, указанных таблиц по всем БД или указанным колонкам по всем таблицам БД. Это полезно, например, для идентификации таблиц, содержащих пользовательские учётные данные приложений, где колонки с соответствующими именами колонок содержат такие строки как имя и пароль.
- Поддержка загрузки и выгрузки любого файла из файловой системы с сервера БД, когда ПО БД MySQL, PostgreSQL или Microsoft SQL Server.
- Поддержка выполнения произвольных команд на ОС сервера БД и получение их стандартного вывода когда ПО MySQL, PostgreSQL или Microsoft SQL Server.
- Поддержка установления внедиапазонного TCP подключения между атакующей машиной и лежащей в основе сервера базы данных операционной системой. Этот канал по выбору пользователя может быть интерактивным приглашением командной строки, сессией Meterpreter или сессией графического пользовательского интерфейса (VNC).
- Поддержка повышения пользовательских привилегий процесса базы данных через команду Metasploit’а — Meterpreter getsystem.
Автор: Bernardo Damele Assumpcao Guimaraes, Miroslav Stampar
Справка по sqlmap
Руководство по sqlmap
Страница man присутствует, но является устаревшей и не дополняет ничего нового к справке.
Доступные tamper скрипты sqlmap
- 0x2char.py — Заменить каждую (MySQL) 0x кодированную строку на эквивалентный CONCAT(CHAR(),…) двойник
- apostrophemask.py — Заменить символ апострофа (‘) на его UTF-8 full width аналог (то есть ‘ -> %EF%BC%87)
- apostrophenullencode.py — Заменить символ апострофа (‘) на его нелегальный double unicode аналог (то есть ‘ -> %00%27)
- appendnullbyte.py — Appends (Access) NULL byte character (%00) at the end of payload
- base64encode.py — Base64-encodes all characters in a given payload
- between.py — Replaces greater than operator (‘>’) with ‘NOT BETWEEN 0 AND #’ and equals operator (‘=’) with ‘BETWEEN # AND #’
- bluecoat.py — Replaces space character after SQL statement with a valid random blank character. Afterwards replace character ‘=’ with operator LIKE
- chardoubleencode.py — Double URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %2553%2545%254C%2545%2543%2554)
- charencode.py — URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %53%45%4C%45%43%54)
- charunicodeencode.py — Unicode-URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %u0053%u0045%u004C%u0045%u0043%u0054)
- charunicodeescape.py — Unicode-escapes non-encoded characters in a given payload (not processing already encoded) (e.g. SELECT -> \u0053\u0045\u004C\u0045\u0043\u0054)
- commalesslimit.py — Replaces (MySQL) instances like ‘LIMIT M, N’ with ‘LIMIT N OFFSET M’ counterpart
- commalessmid.py — Replaces (MySQL) instances like ‘MID(A, B, C)’ with ‘MID(A FROM B FOR C)’ counterpart
- commentbeforeparentheses.py — Prepends (inline) comment before parentheses (e.g. ( -> /**/()
- concat2concatws.py — Replaces (MySQL) instances like ‘CONCAT(A, B)’ with ‘CONCAT_WS(MID(CHAR(0), 0, 0), A, B)’ counterpart
- equaltolike.py — Replaces all occurrences of operator equal (‘=’) with ‘LIKE’ counterpart
- escapequotes.py — Slash escape single and double quotes (e.g. ‘ -> \’)
- greatest.py — Replaces greater than operator (‘>’) with ‘GREATEST’ counterpart
- halfversionedmorekeywords.py — Adds (MySQL) versioned comment before each keyword
- htmlencode.py — HTML encode (using code points) all non-alphanumeric characters (e.g. ‘ -> ‘)
- ifnull2casewhenisnull.py — Replaces instances like ‘IFNULL(A, B)’ with ‘CASE WHEN ISNULL(A) THEN (B) ELSE (A) END’ counterpart
- ifnull2ifisnull.py — Replaces instances like ‘IFNULL(A, B)’ with ‘IF(ISNULL(A), B, A)’ counterpart
- informationschemacomment.py — Add an inline comment (/**/) to the end of all occurrences of (MySQL) «information_schema» identifier
- least.py — Replaces greater than operator (‘>’) with ‘LEAST’ counterpart
- lowercase.py — Replaces each keyword character with lower case value (e.g. SELECT -> select)
- luanginx.py — LUA-Nginx WAFs Bypass (e.g. Cloudflare)
- modsecurityversioned.py — Embraces complete query with (MySQL) versioned comment
- modsecurityzeroversioned.py — Embraces complete query with (MySQL) zero-versioned comment
- multiplespaces.py — Adds multiple spaces (‘ ‘) around SQL keywords
- overlongutf8.py — Converts all (non-alphanum) characters in a given payload to overlong UTF8 (not processing already encoded) (e.g. ‘ -> %C0%A7)
- overlongutf8more.py — Converts all characters in a given payload to overlong UTF8 (not processing already encoded) (e.g. SELECT -> %C1%93%C1%85%C1%8C%C1%85%C1%83%C1%94)
- percentage.py — Adds a percentage sign (‘%’) infront of each character (e.g. SELECT -> %S%E%L%E%C%T)
- plus2concat.py — Replaces plus operator (‘+’) with (MsSQL) function CONCAT() counterpart
- plus2fnconcat.py — Replaces plus operator (‘+’) with (MsSQL) ODBC function
counterpart - randomcase.py — Replaces each keyword character with random case value (e.g. SELECT -> SEleCt)
- randomcomments.py — Add random inline comments inside SQL keywords (e.g. SELECT -> S/**/E/**/LECT)
- sp_password.py — Appends (MsSQL) function ‘sp_password’ to the end of the payload for automatic obfuscation from DBMS logs
- space2comment.py — Replaces space character (‘ ‘) with comments ‘/**/’
- space2dash.py — Replaces space character (‘ ‘) with a dash comment (‘—‘) followed by a random string and a new line (‘\n’)
- space2hash.py — Replaces (MySQL) instances of space character (‘ ‘) with a pound character (‘#’) followed by a random string and a new line (‘\n’)
- space2morecomment.py — Replaces (MySQL) instances of space character (‘ ‘) with comments ‘/**_**/’
- space2morehash.py — Replaces (MySQL) instances of space character (‘ ‘) with a pound character (‘#’) followed by a random string and a new line (‘\n’)
- space2mssqlblank.py — Replaces (MsSQL) instances of space character (‘ ‘) with a random blank character from a valid set of alternate characters
- space2mssqlhash.py — Replaces space character (‘ ‘) with a pound character (‘#’) followed by a new line (‘\n’)
- space2mysqlblank.py — Replaces (MySQL) instances of space character (‘ ‘) with a random blank character from a valid set of alternate characters
- space2mysqldash.py — Replaces space character (‘ ‘) with a dash comment (‘—‘) followed by a new line (‘\n’)
- space2plus.py — Replaces space character (‘ ‘) with plus (‘+’)
- space2randomblank.py — Replaces space character (‘ ‘) with a random blank character from a valid set of alternate characters
- symboliclogical.py — Replaces AND and OR logical operators with their symbolic counterparts (&& and ||)
- unionalltounion.py — Replaces instances of UNION ALL SELECT with UNION SELECT counterpart
- unmagicquotes.py — Replaces quote character (‘) with a multi-byte combo %BF%27 together with generic comment at the end (to make it work)
- uppercase.py — Replaces each keyword character with upper case value (e.g. select -> SELECT)
- varnish.py — Appends a HTTP header ‘X-originating-IP’ to bypass Varnish Firewall
- versionedkeywords.py — Encloses each non-function keyword with (MySQL) versioned comment
- versionedmorekeywords.py — Encloses each keyword with (MySQL) versioned comment
- xforwardedfor.py — Append a fake HTTP header ‘X-Forwarded-For’
Примеры запуска sqlmap
Перечислить базы данных (—dbs) для сайта http://www.sqldummywebsite.name/rubrika.php?id=31 (-u http://www.sqldummywebsite.name/rubrika.php?id=31)
Построить список таблиц (—tables) для базы данных laminat (-D laminat) для сайта http://www.sqldummywebsite.name/rubrika.php?id=31 (-u http://www.sqldummywebsite.name/rubrika.php?id=31)
Показать колонки (—columns) для таблицы admin (-T admin) для базы данных laminat (-D laminat) для сайта http://www.sqldummywebsite.name/rubrika.php?id=31 (-u http://www.sqldummywebsite.name/rubrika.php?id=31)
Вывести дамп (—dump) для таблицы admin (-T admin) для базы данных laminat (-D laminat) для сайта http://www.sqldummywebsite.name/rubrika.php?id=31 (-u http://www.sqldummywebsite.name/rubrika.php?id=31)
Вывести содержимое (—dump) колонки login (-C login) для таблицы admin (-T admin) для базы данных laminat (-D laminat) для сайта http://www.sqldummywebsite.name/rubrika.php?id=31 (-u http://www.sqldummywebsite.name/rubrika.php?id=31)
Установка sqlmap
Программа предустановлена в Kali Linux.
Установка sqlmap в Linux
Установка sqlmap в Windows
Для запуска sqlmap под Windows, кроме sqlmap, нужен Python.
За sqlmap заходим на официальный сайт, или скачиваем по прямой ссылке zip-файл.
За Python’ом заходим на его официальный сайт в раздел загрузок. Там представлены две ветки 3.* и 2.*. В данном случае (для запуска sqlmap) нам нужна версия 2.*. На момент скачивания доступна Python 2.7.11.
Установка скаченного файла элементарна. Только запомните, в какой каталог вы его установили.
Так, теперь переходим в каталог с установленным Python. У меня это каталог C:\Python27\ (думаю, у вас также, если вы не меняли дефолтные значения).
Запустите командную строку (Win+x и в открывшемся окне выберите «Командная строка»). Теперь хватаете файл python.exe (который лежит в каталоге C:\Python27\) и перетаскиваете его в окно командной строки. В командной строке должен появится полный путь до файла. Дописываете к нему через пробел -v
И нажимаете Enter. Если видите много разной информации, в том числе и о версии, значит всё в порядке. Нажмите Ctrl+c, чтобы выйти.
Запуск sqlmap
Помните наш скаченный архив с sqlmap? Распакуйте его. Теперь в командную строку перетаскиваете файл python.exe, ставите пробел, перетаскиваете в эту же командную строку файл sqlmap.py (из архива с sqlmap) ставите ещё один пробел и пишите -h. У меня получилось так
Если появилась справка по sqlmap, значит всё работает как надо! Можно приступать к анализу сайтов.
Как использовать sqlmap на Windows
В командной строке на Windows sqlmap нужно запускать следующим образом:
Источник