# Padding Oracle Attack

padding-oracle attack in C language.

## 问题描述

In this assignment, you must decrypt a challenge ciphertext generated using AES in CBC-mode with PKCS #5 padding. (Note: technically this is PKCS #7 padding,since the block size of AES is 16 bytes. But the padding is done in exactly the same way as PKCS #5 padding.) To do so, you will be given access to a server that will decrypt any ciphertexts you send it (using the same key that was used to generate the challenge ciphertext)…but that will only tell you whether or not decryption results in an error!

All the files needed for this assignment are available here, including a README file that should explain everything.

Note that this assignment requires the ability to perform basic networking. Because we do not assume students necessarily know this, we have provided stub code for doing basic networking in C, Java, Ruby, and Python, but you are welcome to use any language of your choice as long as you are able to write code for basic networking functionality in that language. (Students may feel free to post stub code in other languages for the networking component on the discussion boards.)

The first step in this project is to send the challenge ciphertext to the server, and verify that you receive back a “no error” message. Once you can do that, the rest is “just” crypto…

The plaintext,when converted to ASCII, is readable English text, and so you should be able to tell once you have been successful. Once you have successfully recovered the plaintext (in ASCII).

## 前置技能

### CBC工作模式

CBC模式即密码分组链接模式（Cipher-block chaining）。在该模式中，每个明文块先与前一个密文块进行异或后，再进行加密。在这种方法中，每个密文块都依赖于它前面的所有明文块。同时，为了保证每条消息的唯一性，在第一个块中需要使用初始化向量。

### PKCS #7填充

$IV^{‘}[6] = D(C[n][6]) \otimes 0X02 = 0X01 \otimes IV[6] \otimes 0X02$ .

## 连接服务器并测试

The first step in this project is to send the challenge ciphertext to the server, and verify that you receive back a “no error” message. Once you can do that, the rest is “just” crypto…

### 修改服务器地址和端口

oracle.c中修改servaddr.sin_addr.s_addrservaddr.sin_port

## 改写sample文件

### Komentar

###### Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×