CLI工具和库,轻松执行padding oracle攻击,支持并发的网络请求和优雅的用户界面
作者:Sec-Labs | 发布时间:
项目地址
https://github.com/KishanBagaria/padding-oracle-attacker
padding-oracle-attacker
CLI 工具和库可轻松执行 Padding oracle 攻击 ,支持并发网络请求和优雅的 UI。


安装
确保 安装了 Node.js ,然后运行
$ npm install --global padding-oracle-attacker
或者
$ yarn global add padding-oracle-attacker
CLI 用法
Usage
$ padding-oracle-attacker decrypt <url> hex:<ciphertext_hex> <block_size> <error> [options]
$ padding-oracle-attacker decrypt <url> b64:<ciphertext_b64> <block_size> <error> [options]
$ padding-oracle-attacker encrypt <url> <plaintext> <block_size> <error> [options]
$ padding-oracle-attacker encrypt <url> hex:<plaintext_hex> <block_size> <error> [options]
$ padding-oracle-attacker analyze <url> [<block_size>] [options]
Commands
decrypt Finds the plaintext (foobar) for given ciphertext (hex:0123abcd)
encrypt Finds the ciphertext (hex:abcd1234) for given plaintext (foo=bar)
analyze Helps find out if the URL is vulnerable or not, and
how the response differs when a decryption error occurs
(for the <error> argument)
Arguments
<url> URL to attack. Payload will be inserted at the end by default. To specify
a custom injection point, include {POPAYLOAD} in a header (-H),
request body (-d) or the URL
<block_size> Block size used by the encryption algorithm on the server
<error> The string present in response when decryption fails on the server.
Specify a string present in the HTTP response body (like PaddingException)
or status code of the HTTP response (like 400)
Options
-c, --concurrency Requests to be sent concurrently [default: 128]
--disable-cache Disable network cache. Saved to [default: false]
poattack-cache.json.gz.txt by default
-X, --method HTTP method to use while making request [default: GET]
-H, --header Headers to be sent with request.
-H 'Cookie: cookie1' -H 'User-Agent: Googlebot/2.1'
-d, --data Request body
JSON string: {"id": 101, "foo": "bar"}
URL encoded: id=101&foo=bar
Make sure to specify the Content-Type header.
-e, --payload-encoding Ciphertext payload encoding for {POPAYLOAD} [default: hex]
base64 FooBar+/=
base64-urlsafe FooBar-_
hex deadbeef
hex-uppercase DEADBEEF
base64(xyz) Custom base64 ('xyz' represent characters for '+/=')
--dont-urlencode-payload Don't URL encode {POPAYLOAD} [default: false]
--start-from-1st-block Start processing from the first block instead [default: false]
of the last (only works with decrypt mode)
Examples
$ poattack decrypt http://localhost:2020/decrypt?ciphertext=
hex:e3e70d8599206647dbc96952aaa209d75b4e3c494842aa1aa8931f51505df2a8a184e99501914312e2c50320835404e9
16 400
$ poattack encrypt http://localhost:2020/decrypt?ciphertext= "foo bar 🦄" 16 400
$ poattack encrypt http://localhost:2020/decrypt?ciphertext= hex:666f6f2062617220f09fa684 16 400
$ poattack analyze http://localhost:2020/decrypt?ciphertext=
Aliases
poattack
padding-oracle-attack
图书馆API
const { decrypt, encrypt } = require('padding-oracle-attacker')
// or
import { decrypt, encrypt } from 'padding-oracle-attacker'
const { blockCount, totalSize, foundBytes, interBytes } = await decrypt(options)
const { blockCount, totalSize, foundBytes, interBytes, finalRequest } = await encrypt(options)
decrypt(options: Object): Promise
encrypt(options: Object): Promise
必需的选项
url: string
要攻击的 URL。 默认情况下,有效载荷将附加在末尾。 要指定自定义注入点,请 {POPAYLOAD} 在 URL 中包含标头 ( requestOptions.headers ) 或请求正文 ( requestOptions.data )
blockSize: number
服务器上加密算法使用的块大小。
isDecryptionSuccess: ({ statusCode, headers, body }) => boolean
如果服务器响应指示解密成功,则返回 true 的函数。
ciphertext: Buffer ( decrypt 仅)
要解密的密文。
plaintext: Buffer ( encrypt 仅)
要加密的明文。 填充将自动添加。 例子: Buffer.from('foo bar', 'utf8')
可选选项
concurrency: number = 128
要同时发送的网络请求。
isCacheEnabled: boolean = true
响应默认缓存并保存到 poattack-cache.json.gz.txt . 设置 false 为禁用缓存。
requestOptions: { method, headers, data }
requestOptions.method: string
发出请求时使用的 HTTP 方法。 GET 默认情况下。 POST , PUT , DELETE 是一些有效的选项。
requestOptions.headers: { string: string }
与请求一起发送的标头。 例子: { 'Content-Type': 'application/x-www-form-urlencoded' }
requestOptions.body: string
请求正文。 可以是 JSON 字符串、URL 编码参数等。 Content-Type 标头必须手动设置。
logMode: 'full'|'minimal'|'none' = 'full'
full :将所有内容记录到控制台(默认)minimal :仅在启动和完成后记录到控制台none :不记录任何内容到控制台
transformPayload: (ciphertext: Buffer) => string
ciphertext 发出请求时 将其转换为字符串的函数。 默认情况下,以 ciphertext 十六进制编码并插入到注入点(除非 {POPAYLOAD} 存在 URL 结尾)。
可选选项( decrypt 仅)
alreadyFound: Buffer
已知/发现的可以跳过的明文字节(从末尾开始)。 如果您提供 Buffer 十个字节的 a,将跳过最后十个字节。
initFirstPayloadBlockWithOrigBytes: boolean = false
ciphertext 用原始字节而不是零 初始化第一个有效负载块。
示例: abcdef12345678ff 1111111111111111 而不是 00000000000000ff 1111111111111111
startFromFirstBlock: boolean = false
从第一个块而不是最后一个块开始处理。
makeInitialRequest: boolean = true
使用提供的原始请求 ciphertext 和日志服务器对控制台的响应发出初始请求,以允许用户确保正确发送网络请求。
可选选项( encrypt 仅)
makeFinalRequest: boolean = true
找到 ciphertext 新的字节后 plaintext ,使用找到的字节发出最终请求并将服务器响应记录到控制台。
lastCiphertextBlock: Buffer
最后一个块的自定义密文。 默认情况下,最后一个块只是零 ( 000000000000000 )。
发展
padding-oracle-attacker 是用打字稿写的。 如果你想修改源文件并运行它们,你可以先将文件编译成 JS 然后使用 node 运行它们,或者使用 ts-node 。
示例: yarn build 然后 node dist/cli ... 或简单地 ts-node src/cli ...
yarn build 或者 npm run build
将目录中的 TypeScript 文件构建 src 为 JS 文件并输出到 dist 目录中。
yarn clean 或者 npm run clean
删除 dist 目录。
yarn lint 或者 npm run lint
使用 eslint 对文件进行检查。
yarn test 或者 npm run test
使用 ava 检测并运行测试。
node test/helpers/vulnerable-server.js
在http://localhost:2020 运行易受 padding oracle 攻击的测试服务器