我试图使用yguard 3.0.0 maven插件混淆JAR文件。模糊化的JAR和预期的差不多,它被缩小了,所有的私有方法和变量都被重命名了。我需要重新命名包名,这是执行的,但是启动我的Tomcat所需的spring XML文件没有被模糊化的包更新。
我的蚂蚁任务如下:
<configuration>
<tasks>
<property name="runtime-classpath" refid="maven.runtime.classpath"/>
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="${runtime-classpath}"/>
<yguard>
<inoutpair in="C:/test/webapp.jar" out="C:/test/webapp_obfuscated.jar" />
<shrink>
<property name="error-checking" value="pedantic"/>
</shrink>
<rename>
<adjust replaceContent="true" replaceName="true">
<include name="ApplicationContext.xml"/>
</adjust>
</rename>
</yguard>
</tasks>
</configuration>请注意,在我的示例中,我只是尝试处理ApplicationContext.xml,但是这个文件仍然使用与没有混淆的版本相同的类名。我确信y卫士任务正在对我的ApplicationContext.xml做一些事情,因为我在文件中有一个标记,文件的路径被正确地混淆了,但是类名和其他东西没有:
<!-- Properties ldap -->
<bean id="ldapProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean" scope="singleton">
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<list>
<value>classpath:A/A/B/E/ldap.properties</value> <--Obfuscated!-->
</list>
</property>
</bean>
<bean id="authenticationBO" class="com.grifols.grb.authentication.bo.AuthenticationBO" scope="singleton">
<property name="dbAccess" ref="dbAccessGRB"/>
<property name="usersSecurityBO" ref="usersSecurityBO" />
<property name="settings" ref="settings" />
<property name="ldapProperties" ref="ldapProperties" />
</bean>根据Yguard文档,我认为我只需要使用replaceContent="true“并详细说明哪个文件,但我不是
有什么想法吗?我真的很感激你能提供的任何帮助。
伊万
发布于 2022-03-24 13:43:47
yGuard可以在资源文件中替换文件/路径名称或类名,但不能同时替换两者。
也就是说。
<adjust replaceContent="true">将调整
<example>
<class>com.yworks.yguard.StringReplacer</class>
<file>com/yworks/yguard/StringReplacer.properties</file>
</example>至
<example>
<class>com.yworks.yguard.StringReplacer</class>
<file>A/A/A/SR.properties</file>
</example>使用
<adjust replaceContent="true" replaceContentSeparator=".">结果将是
<example>
<class>A.A.A.SR</class>
<file>com/yworks/yguard/StringReplacer.properties</file>
</example>然而,期望的结果
<example>
<class>A.A.A.SR</class>
<file>A/A/A/SR.properties</file>
</example>还没有得到支持。
https://stackoverflow.com/questions/70879811
复制相似问题