在ClientSideStateHelper#doGetState
中有如下代码
其中guard
来标识是否启用加密 , 有加密时会调用this.guard.decrypt
进行解密
if ("stateless".equals(stateString)) {return null;} else {ObjectInputStream ois = null;InputStream bis = new Base64InputStream(stateString);try {if (this.guard != null) {byte[] bytes = stateString.getBytes("UTF-8");int numRead = ((InputStream)bis).read(bytes, 0, bytes.length);byte[] decodedBytes = new byte[numRead];((InputStream)bis).reset();((InputStream)bis).read(decodedBytes, 0, decodedBytes.length);bytes = this.guard.decrypt(decodedBytes);if (bytes == null) {return null;}bis = new ByteArrayInputStream(bytes);}
加解密逻辑均在ByteArrayGuard
类中 , 需要时扣代码即可
public byte[] decrypt(byte[] bytes) {try {byte[] macBytes = new byte[32];System.arraycopy(bytes, 0, macBytes, 0, macBytes.length);byte[] iv = new byte[16];System.arraycopy(bytes, macBytes.length, iv, 0, iv.length);byte[] encdata = https://www.huyubaike.com/biancheng/new byte[bytes.length - macBytes.length - iv.length];System.arraycopy(bytes, macBytes.length + iv.length, encdata, 0, encdata.length);IvParameterSpec ivspec = new IvParameterSpec(iv);Cipher decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");decryptCipher.init(2, this.sk, ivspec);Mac decryptMac = Mac.getInstance("HmacSHA256");decryptMac.init(this.sk);decryptMac.update(iv);decryptMac.update(encdata);byte[] macBytesCalculated = decryptMac.doFinal();if (this.areArrayEqualsConstantTime(macBytes, macBytesCalculated)) {byte[] plaindata = https://www.huyubaike.com/biancheng/decryptCipher.doFinal(encdata);return plaindata;} else {System.err.println("ERROR: MAC did not verify!");return null;}} catch (Exception var10) {System.err.println("ERROR: Decrypting:" + var10.getCause());return null;}}
整体逻辑为,其中看lib版本和配置来判断走不走加解密
* Generate Payload: *writeObject ==> Gzip ==> Encrpt ==> Base64Encode * * Recive Payload: *Base64Decode ==> Decrpt ==> UnGzip ==> readObject
Referencehttps://www.cnblogs.com/nice0e3/p/16205220.html
https://book.hacktricks.xyz/pentesting-web/deserialization/java-jsf-viewstate-.faces-deserialization
经验总结扩展阅读
- elasticsearch聚合之bucket terms聚合
- 东南第一佳味天下之美的菜系是
- 孔雀为什么被称为百鸟之王
- 我儿王腾有大帝之姿是什么梗?
- “黑绷带的力量” 首先,它有一个奇怪的名字,叫“黑绷带” 其次,在看产品介绍之初,它是一款晚霜。
- 什么口罩不具备安全防护作用
- 我的世界漏斗与漏斗之间怎么相连(我的世界漏斗上怎么放东西)
- 云原生之旅 - 11)基于 Kubernetes 动态伸缩 Jenkins Build Agents
- C#多线程之线程基础篇
- 我是特种兵之利刃出鞘吃豆腐脑是第几集?