0% found this document useful (0 votes)
58 views4 pages

Proguard Ofustication 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views4 pages

Proguard Ofustication 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Code Obfuscation

Follow below steps for code Obfuscation


1. Add below properties in pom.xml (where the final jar of service build)
<proguard.conf>${project.basedir}/proguard.conf</proguard.conf>
<proguard-maven-
plugin.version>2.6.0</proguard-maven-plugin.version>

2. Add below plugins in service pom.xml (where the final jar of service build). Also add groupId
of service as comma separated in below spring plugin <excludeGroupIds> properties.

e.g if group id you the service is com.bootnext.visualyzer and add this group in plulgin property
like this <excludeGroupIds>com.bootnext.platform,com.bootnext.commons,
com.bootnext.visualyzer </excludeGroupIds>

Note: Do not remove com.bootnext.platform,com.bootnext.commons string from properties only


append service groupId

<plugin>

<groupId>com.github.wvengen</groupId>

<artifactId>proguard-maven-plugin</artifactId>

<version>${proguard-maven-plugin.version}</version>

<executions>

<execution>

<phase>package</phase>

<goals>

<goal>proguard</goal>

</goals>

</execution>

</executions>

<configuration>

<silent>false</silent>

<injar>${project.build.finalName}.${project.packaging}</injar>

<proguardInclude>${proguard.conf}</proguardInclude>

<includeDependency>true</includeDependency>
<obfuscate>true</obfuscate>

<mappingFileName>${project.name}_map.txt</mappingFileName>

<assembly>

<inclusions>

<inclusion>

<groupId>com.bootnext.*</groupId>

<artifactId>*</artifactId>

</inclusion>

</inclusions>

</assembly>

<libs>

<lib>${java.home}/jmods/java.base.jmod</lib>

<lib>${java.home}/jmods/java.datatransfer.jmod</lib>

<lib>${java.home}/jmods/java.prefs.jmod</lib>

<lib>${java.home}/jmods/java.xml.jmod</lib>

<lib>${java.home}/jmods/java.desktop.jmod</lib>

</libs>

</configuration>

</plugin>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

<configuration>

<outputDirectory>${output.dir}</outputDirectory>

<excludeGroupIds>com.bootnext.platform,com.bootnext.commons</excludeGroupIds>

<addResources>false</addResources>

</configuration>

<executions>

<execution>

<goals>
<goal>repackage</goal>

</goals>

<configuration>

<mainClass>com.bootnext.Application</mainClass>

</configuration>

</execution>

</executions>

</plugin>

3. Copy attached progaurd.conf(proguard) file parallel to Pom.xml file.


4. Modifiy progaurd conf file is any class or class member not required to obfuscation.
5. Run mvn clean package to generate build.
6. Replace –cp with –jar and mainClass name with Jar name in run.sh cmd
e.g.
Replace
java -cp $JAR:lib/*:. -Xms$XMS -Xmx$XMX -XX:TieredStopAtLevel=1 -noverify -Xverify:none
-XX:+UseParallelGC -XX:MaxMetaspaceSize=1024m
-Dspring.config.location=file:./application.properties com.bootnext.Application

With
java -jar -Xms$XMS -Xmx$XMX -XX:TieredStopAtLevel=1 -noverify -Xverify:none -XX:
+UseParallelGC -XX:MaxMetaspaceSize=1024m
-Dspring.config.location=file:./application.properties $JAR

Recommendation: Comment out copy dependency and maven jar plugin to skip lib folder
creation in final build. Spring plugin will create executable complete jar with all
dependencies.

Follow below Step for print log as deofuscated


1. Take updated bootnext-core-3.10 jar
2. use attached log4j2.xml
(https://bootnext-my.sharepoint.com/personal/manoj_bootnext_biz/_layouts/15/
onedrive.aspx?login_hint=manoj%40bootnext%2Ebiz&id=%2Fpersonal%2Fmanoj
%5Fbootnext%5Fbiz%2FDocuments%2Fproguard&view=0)
3. After mvn package or install command inside target folder mapping file with name $
{project.name}_map.txt generated.
4. encode generate file with below command (new Crpyto.zip avaible in above link)
sh encodec.sh ef ${project.name}_map.txt
5. keep generate encoded file in s3 or filesystem
6. add below properties in application.properties file
detrace.filename=<encoded_map file name>
detrace.filepath=<buckectName or Filepath>
7. value of above properties should be AES encrypted

Additional Info

Use LogUtils.getStackTrace(e); to print stacktrace as string

To Change log level use below api

Post call http://<Service_host>:<Service:port>/<Service_context>/rest/logger/


{loggerpackage}/{loglevel}

Add dependency if not required


<dependency>
<groupId>com.bootnext.commons</groupId>
<artifactId>detrace-log</artifactId>
<version>1.0.0</version>
</dependency>

For Debugging prograud generate jar as java class use below


Jar decompiler command:
./jd-cli -/Users/bootnext-mac-63/Downloads/analytics-service-3.1.0.jar -od
/Users/bootnext-mac-63/workspace/sla/ana -g ALL

You might also like