最近业务系统报错返回“CA信息和账号不一致”,但是找不到到底是在哪个流程中的报错,于是开启找其代码文件。
如果你能确定代码的目录可以直接在其目录搜索,如果你无法确定可以用全局搜索
grep -R "CA信息和账号" /opt/tai/apache-tomcat-9.0.55/webapps/cas/
搜索返回结果如下:
Binary file /opt/tai/apache-tomcat-9.0.55/webapps/cas/WEB-INF/classes/cn/com/taiji/sso/support/auth/handler/CaOrPhone.class matches
说明“CA信息和账号”这段文字是在 Java 类中写死的,而不是出现在 HTML 页面中。
浏览器页面中显示的 "CA信息和账号不一致"
,是后端 Java 类 CaOrPhone.class
中直接抛出的。
继续排查可以反编译一下源码,流程如下:
1.安装CFR
wget https://www.benf.org/other/cfr/cfr-0.152.jar -O /tmp/cfr.jar
2. 查看是否有Java环境
root@instance-IQCWi7HD:/mzs# java -version
openjdk version "11.0.27" 2025-04-15
OpenJDK Runtime Environment (build 11.0.27+6-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.27+6-post-Debian-1deb11u1, mixed mode, sharing)
root@instance-IQCWi7HD:/mzs# java -jar /tmp/cfr.jar /mzs/CaOrPhoneAuthenticationHandler.class --outputdir /tmp/cfrout
Processing cn.com.taiji.sso.support.auth.handler.CaOrPhoneAuthenticationHandler
3.如果没有就安装
(1)对于基于 Debian / Ubuntu 的系统:
apt update
apt install -y default-jre
(2)对于基于 RHEL / CentOS 的系统:
yum install -y java-1.8.0-openjdk
4.反编译
java -jar /tmp/cfr.jar /mzs/CaOrPhone.class --outputdir /tmp/cfrout
5.搜索你反编译后的Java文件
root@instance-IQCWi7HD:/mzs# find /tmp/cfrout -name "CaOrPhone.java"
6.查看包含“关键字”的逻辑段落,但是提示没有,这说明字符串 "CA信息和账号" 并不是直接写死在源代码里的中文,而是以 Unicode 编码形式存在,或者通过其他手段间接生成的。
grep -A 20 "CA信息" /tmp/cfrout/cn/com/taiji/sso/support/auth/handler/CaOrPhone.java
7.尝试搜索关键字的 Unicode 编码,例如:
中文 "CA信息"
对应 Unicode 编码可能是:
-
\u0043\u0041\u4fe1\u606f
(CA信息)
可以尝试搜索 \u4fe1
、CA\u4fe1
等关键词:
grep -P '\\u4fe1|\\u606f' /tmp/cfrout/cn/com/taiji/sso/support/auth/handler/CaOrPhone.java -A 10
最终找到了代码所在段落提交给开发查看具体问题。
- THE END -
最后修改:2025年6月26日
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:https://ospf.me/20250626-2
共有 0 条评论