Aggregator
安全服务的发展
安全服务的发展
安全服务的发展
安全服务的发展
某知笔记服务端docker镜像授权分析
The Threat That Never Went Away Is Back (with a Vengeance)
JVMTI加密保护绕过
数据众包平台Premise持续向美军提供情报数据
数据众包平台Premise持续向美军提供情报数据
数据众包平台Premise持续向美军提供情报数据
宝,我今天发财了!发的什么财?诚聘英才!
宝,我今天发财了!发的什么财?诚聘英才!
宝,我今天发财了!发的什么财?诚聘英才!
Airtag hacks - scanning via browser, removing speaker and data exfiltration
Until the Apple Airtag came out a few months ago I hadn’t really looked into the tag tracking market. Turns out there were already quite a lot of offerings available before Apple joined the market, most notably Tile.
However, I wanted to try out the Airtag and ended up ordering a few.
This post will explore three things:
- Removing the speaker of my Airtag
- Using Browser APIs to scan for Airtags (if you don’t have an iPhone but someone tries to stalk you this might be handy)
- Explore data exfiltration via Airtags and Apple’s “Find My” network
By the way, when you order your Airtags online you can customize them. So, I have some cool icons on mine, like this one:
Bypassing JVMTI-Based Encryption Protection
While researching a specific vehicle recently, I encountered a Windows application used to connect to a dealer intranet.
After installation, the application directory contained both .jar files and an .exe executable.
Upon executing start.exe, I observed two Java processes launching:
C:\LC\Elsapro\lib\jre\bin\java.exe -agentlib:C:\LC\Elsapro\lib\jna\jvmprotect -Djava.library.path=C:\LC\Elsapro\lib\jna -Dfile.encoding=utf-8 -classpath C:\LC\Elsapro -cp C:\LC\Elsapro\ElsaPro.jar com.qqw.lcst.softp.superc.v5.app.epweb.gui.OptGuiI surmised that the second process was likely an embedded browser to display the UI, while the first process contained the core logic I was interested in.
Opening the main JAR file with jd-gui, I found that many classes displayed an Internal Error, and key classes appeared to be missing. Other Java decompilers yielded similar results.
A quick analysis of start.exe suggested it primarily functioned as a custom ClassLoader, likely handling tasks such as online updates.
From the startup parameters, I noticed the -agentlib flag pointing to jvmprotect. Loading jvmprotect into IDA Pro, I confirmed it functions as a JVMTI agent, leading me to suspect it serves as the decryption module.
JVMTI (Java Virtual Machine Tool Interface) supports a wide range of analytical tools, including those for forensics, debugging, monitoring, thread analysis, and code coverage.
Skimming the JVMTI documentation, I identified three primary export functions that serve as excellent entry points for reverse engineering:
- Agent_OnLoad (Called at startup)
- Agent_OnAttach (Called when attaching to a running VM)
- Agent_OnUnload (Called when the agent is unloaded)
I loaded the agent into IDA Pro, identifying Agent_OnLoad as the entry point. Analyzing raw JNI and JVMTI code can be cumbersome, so I imported a consolidated jvmti_all.h header file to aid the reversing process (though it helped only marginally here, as the callback logic was straightforward and didn’t utilize complex features).
During startup, the agent calls SetEventCallbacks. Subsequently, as classes are loaded, ClassFileLoadHook events are triggered. Each class file content is passed to the registered callback, which decrypts the bytecode and prints logs.
Instead of reverse-engineering the custom decryption algorithm—which can be time-consuming—I decided to dump the decrypted classes directly from memory using a Java Agent.
After reading Talking about Java Instrumentation and related applications by Yilun Fan, I learned that the Instrumentation API is based on JVMTI, meaning it sits at the same layer and can access the modified (decrypted) classes.
Referring to the article How to get dynamically generated class files in Java runtime?, I packaged a custom agent named ClazzDumpAgent.jar.
The parameters used are:
- -d: Specifies the dump output path.
- -f: Matches the class path prefix to extract.
- -r: Indicates the specific package name to filter.
Crucial Note: The order of -agentlib and -javaagent is critical. You must allow the native agent to decrypt the classes before the Java agent attempts to dump them.
C:\LC\Elsapro\lib\jre\bin\java.exe -Xms256m -Xmx512m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -agentlib:C:\LC\Elsapro\lib\jna\JvmtiCry -Djava.library.path=C:\LC\Elsapro\lib\jna -javaagent:C:\LC\Elsapro\ClazzDumpAgent.jar=-d=C:\LC\Elsapro\clazzDump\;-f=com/qqw/lcst;-r=lcst -Dfile.encoding=utf-8 -classpath C:\LC\Elsapro -cp C:\LC\Elsapro\ElsaPro.jar com.qqw.lcst.softp.superc.v5.app.epweb.gui.OptGuiUpon executing this command, you can see the classes being dumped immediately after they are decrypted by the protection module.
I then packaged the dumped directory into a zip file and opened it with a Java decompiler. In comparison to the initial attempt, the previously null or missing classes were now visible. However, some classes that initially showed Internal Error were still missing. This is because classes are only decrypted when they are loaded/executed.
By proactively traversing the application’s functionality (i.e., clicking through the UI), I triggered the loading of those specific classes, allowing them to be decrypted and captured in real-time.
I recommend using CFR for decompilation as it generally handles modern Java features better and produces fewer errors than older tools.
cfrd -jar ./decypted.zip ./out Surprise ReferencesTalking about Java Instrumentation and related applications
How to get dynamically generated class files in Java runtime?
JVMTI加密保护绕过
最近研究某汽车,遇到一个Win下的软件,用于连接经销商内网。
安装完成,目录有jar文件又有exe文件。
执行start.exe之后可以看到启动了两个Java进程
C:\LC\Elsapro\lib\jre\bin\java.exe -agentlib:C:\LC\Elsapro\lib\jna\jvmprotect -Djava.library.path=C:\LC\Elsapro\lib\jna -Dfile.encoding=utf-8 -classpath C:\LC\Elsapro -cp C:\LC\Elsapro\ElsaPro.jar com.qqw.lcst.softp.superc.v5.app.epweb.gui.OptGui猜测第二个进程可能是内置浏览器,第一个进程是关键进程
使用jdgui打开,发现部分类显示Internel Error,并且关键类没有显示。使用其他java反编译工具也一样。
简单逆向start.exe文件,发现只是用作ClassLoader,可能用于在线更新。
在启动参数看到了agentlib指向jvmprotect,使用IDA Pro打开jvmprotect,发现使用了JVMTI作为agent,猜测可能作为解密模块。
JVMTI支持包括但不限于取证,调试,监控,线程分析,覆盖率分析等工具。
简单查阅JVMTI文档,得知如下三个主要方法,可以作为逆向切入点
- Agent_OnLoad 启动时调用
- Agent_OnAttach 附加时调用
- Agent_OnUnload 卸载时调用
使用IDA Pro打开这个agent。得知Agent_OnLoad是启动函数,由于代码基于JNI和JVMTI,打开阅读不太方便。我整合了一个jvmti_all.h头文件,方便逆向。(由于这个回调函数太简单,并且没有用到其他功能,所以没有派上什么用场)。
启动时设置SetEventCallbacks,此时会把jar包的class文件逐个传入这个回调函数。然后把每个类解密,并且输出日志。
我很懒,不想还原算法,打算用frida或者unicorn engine去解密。
阅读完这篇文章 Yilun Fan - 谈谈Java Intrumentation和相关应用,发现Instrumentation API基于JVMTI,因此可以使用Java Agent来导出class文件
参考等你归去来 - 如何获取java运行时动态生成的class文件?,我打包了名为ClazzDumpAgent.jar的Agent。d参数代表dump路径,-f参数是匹配提取的前缀,-r文件代表包名。
agentlib和javaagent存在先后顺序,一定要先解密完再导出。
C:\LC\Elsapro\lib\jre\bin\java.exe -Xms256m -Xmx512m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -agentlib:C:\LC\Elsapro\lib\jna\JvmtiCry -Djava.library.path=C:\LC\Elsapro\lib\jna -javaagent:C:\LC\Elsapro\ClazzDumpAgent.jar=-d=C:\LC\Elsapro\clazzDump\;-f=com/qqw/lcst;-r=lcst -Dfile.encoding=utf-8 -classpath C:\LC\Elsapro -cp C:\LC\Elsapro\ElsaPro.jar com.qqw.lcst.softp.superc.v5.app.epweb.gui.OptGui执行这段脚本,可以看到解密完每个class之后,都会导出这个class。
随后将路径打包成zip文件,用 Java 反编译软件打开,相比较第一张图,可以看到之前显示为null的class已经出现率,但是有些显示Internal Error的类没有出现。这是因为没有执行的class不会被解密,这时候主动触发这个功能,在命令行可以看到相关的类被实时解密。
建议用CFR去反编译,报错更少。
cfrd -jar ./decypted.zip ./out 彩蛋 参考JVMTI加密保护绕过
最近研究某汽车,遇到一个Win下的软件,用于连接经销商内网。
安装完成,目录有jar文件又有exe文件。
执行start.exe之后可以看到启动了两个Java进程
C:\LC\Elsapro\lib\jre\bin\java.exe -agentlib:C:\LC\Elsapro\lib\jna\jvmprotect -Djava.library.path=C:\LC\Elsapro\lib\jna -Dfile.encoding=utf-8 -classpath C:\LC\Elsapro -cp C:\LC\Elsapro\ElsaPro.jar com.qqw.lcst.softp.superc.v5.app.epweb.gui.OptGui猜测第二个进程可能是内置浏览器,第一个进程是关键进程
使用jdgui打开,发现部分类显示Internel Error,并且关键类没有显示。使用其他java反编译工具也一样。
简单逆向start.exe文件,发现只是用作ClassLoader,可能用于在线更新。
在启动参数看到了agentlib指向jvmprotect,使用IDA Pro打开jvmprotect,发现使用了JVMTI作为agent,猜测可能作为解密模块。
JVMTI支持包括但不限于取证,调试,监控,线程分析,覆盖率分析等工具。
简单查阅JVMTI文档,得知如下三个主要方法,可以作为逆向切入点
- Agent_OnLoad 启动时调用
- Agent_OnAttach 附加时调用
- Agent_OnUnload 卸载时调用
使用IDA Pro打开这个agent。得知Agent_OnLoad是启动函数,由于代码基于JNI和JVMTI,打开阅读不太方便。我整合了一个jvmti_all.h头文件,方便逆向。(由于这个回调函数太简单,并且没有用到其他功能,所以没有派上什么用场)。
启动时设置SetEventCallbacks,此时会把jar包的class文件逐个传入这个回调函数。然后把每个类解密,并且输出日志。
我很懒,不想还原算法,打算用frida或者unicorn engine去解密。
阅读完这篇文章 Yilun Fan - 谈谈Java Intrumentation和相关应用,发现Instrumentation API基于JVMTI,因此可以使用Java Agent来导出class文件
参考等你归去来 - 如何获取java运行时动态生成的class文件?,我打包了名为ClazzDumpAgent.jar的Agent。d参数代表dump路径,-f参数是匹配提取的前缀,-r文件代表包名。
agentlib和javaagent存在先后顺序,一定要先解密完再导出。
C:\LC\Elsapro\lib\jre\bin\java.exe -Xms256m -Xmx512m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -agentlib:C:\LC\Elsapro\lib\jna\JvmtiCry -Djava.library.path=C:\LC\Elsapro\lib\jna -javaagent:C:\LC\Elsapro\ClazzDumpAgent.jar=-d=C:\LC\Elsapro\clazzDump\;-f=com/qqw/lcst;-r=lcst -Dfile.encoding=utf-8 -classpath C:\LC\Elsapro -cp C:\LC\Elsapro\ElsaPro.jar com.qqw.lcst.softp.superc.v5.app.epweb.gui.OptGui执行这段脚本,可以看到解密完每个class之后,都会导出这个class。
随后将路径打包成zip文件,用 Java 反编译软件打开,相比较第一张图,可以看到之前显示为null的class已经出现率,但是有些显示Internal Error的类没有出现。这是因为没有执行的class不会被解密,这时候主动触发这个功能,在命令行可以看到相关的类被实时解密。
建议用CFR去反编译,报错更少。
cfrd -jar ./decypted.zip ./out 彩蛋 参考