Padding oracle attack!

本文介绍了 Padding Oracle 攻击的基本原理,包括填充(padding)的概念、CBC分组密码的工作模式,以及攻击所需的条件。通过一个具体的例子,展示了如何利用CBC模式中的漏洞来解密数据,并在解题过程中学习到了相关技巧。
摘要由CSDN通过智能技术生成

终于补题补到了这个题目!这个也是非常经典的问题了,但是一直没有搞明白,之前鸡哥的讲解已经非常清楚了,忍不住还是想佩服一下4ction。下面还是大概讲一下这个Padding oracle attack到底是个啥,这里采用白帽子上的讲解方式就很好了!

1.基础知识

(1)padding

由于CBC是块密码工作模式, 所以要求明文长度必须是块长度的整数倍.
对于不满足的数据, 会进行数据填充到满足整数倍. 即 padding,格式如下

** ** ** ** ** ** ** 01
** ** ** ** ** ** 02 02
** ** ** ** ** 03 03 03
** ** ** ** 04 04 04 04
** ** ** 05 05 05 05 05
** ** 06 06 06 06 06 06
** 07 07 07 07 07 07 07
08 08 08 08 08 08 08 08

当然这里是64位为一块的情况,其他的情况自行分析

(2)CBC分组密码的链接模式

这里写图片描述

CBC模式加密流程图

这里写图片描述

CBC模式解密流程图

理解以上两张图以后还需要知道以下这张图中的IV的意思,中间值,也是我们解密过程中最后的需要抑或的地方

这里写图片描述

这个的认识非常关键!下买你讲一下攻击的原理

    在Padding Oracle Attack攻击中,攻击者输入的参数是IV+Cipher,我们要通过对IV的”穷举”来请求服务器端对我们指定的Cipher进行解密,并对返回的结果进行判断。

    和SQL注入中的Blind Inject思想类似。我觉得Padding Oracle Attack也是利用了这个二值逻辑的推理原理,或者说这是一种”边信道攻击(Side channel attack)”

2.攻击条件

二者缺一不可

1.可以控制密文 或者 IV
2.如果解密后不满足 padding 服务端会报错.

然后这里需要搞清楚到底是怎样猜解,具体比较复杂,不多讲了。总之就是控制IV在解密的过程中寻找成功解密的IV值,并且根据填充的内容确定中间值。至于我们需要的明文只要中间值和原有的IV抑或一下就有了(本人就坑在这几个变量的关系上)

3.一个例子

题目来自于第三届上海大学生网络安全大赛中的is_aes_secure密码题目,题目中明显就是了利用此漏洞,给定一个rb,贴一下代码如下

#!/usr/bin/ruby -w
require 
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Padding Oracle attack is a type of cryptographic attack that exploits the behavior of cryptographic systems using block ciphers with padding. The attack allows an attacker to decrypt the contents of encrypted data by sending specially crafted ciphertexts to a server that uses the encryption algorithm. The attack works by exploiting the server's ability to detect whether a ciphertext is properly padded or not. Padding is commonly used in block ciphers to ensure that the input block is a fixed length. If the padding is incorrect, the server will reject the ciphertext and return an error message. However, by analyzing the error messages, an attacker can infer information about the plaintext and eventually decrypt it. To carry out the attack, the attacker sends many modified ciphertexts to the server, each with a different block of the ciphertext modified. By analyzing the responses from the server, the attacker can determine whether the modified block of ciphertext was properly padded or not. This information can be used to gradually determine the value of each byte of the plaintext. Padding Oracle attack is a serious threat to many cryptographic systems that use block ciphers with padding. To prevent this attack, it is important to use authenticated encryption modes, such as AES-GCM or ChaCha20-Poly1305, that provide both encryption and authentication of the ciphertext. Additionally, servers should be configured to return a generic error message, rather than specific error messages that reveal information about the encryption process.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值