Project obfuscation
Hey Im trying to obfuscate my jar file with proguard, but Im having trouble doing so
I do not want to lose any files, I do not want it to get optimized, I just want all files inside of the jesse/scriptmod package to get obfuscated
I got a dictionary file that contains all words the obfuscator may use, can someone help me?
75 Replies
⌛
This post has been reserved for your question.
Hey @j_sse! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
what exactly is the issue with your current configuration?
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Nothing gets obfuscated, I just get the same exact jar back
then what do you want to obfuscate?
You are using
-keep
which I think means "don't obfuscate that"All the files inside of the jesse/scriptmod package
I tried without this, and it just removes the files that are not in the keep
It has a bunch of other libraries inside which it depends on, I cannot remove nor rename those
I think you can do
-keep class !jesse.** { *; }
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Sorry for the late reply, I tried this and it just seemed to delete the jesse package
I am getting a ton of warnings and without -ignorewarnings it will not build
do you want the class and method names to stay the same?
no, nothing in my jesse package should stay the same
for all other files they should stay the same
-keep class !jesse.** { *; }
seems to delete all my files that are in the jesse package
im not sure if this is because of all the errors its giving which im ignoringI think you might need to keep at least your main class
sure, I have an InstallerFrame though thats not in the jesse package
idk which errors you are getting
but I don't really know obfuscation tbh cause it's pretty useless
if I run it with :
Can you try only keeping your main class?
I think that is fine as long as these classes are present at runtime
it seemed to have obfuscated something?
yeah they are
though I need all the jesse.scriptmod to be obfuscated fully
I meant keeping the main class but nothing else in your jesse package
or all classes you need to be accessible from outside
I think that if proguard sees a class or method that is needer used nor "kept", it deletes that
so you first need to know what is accessed from outside (e.g. via reflection)
and then tell it to keep these things
it does not have anything it does not need
I want it to not remove anything, solely obfuscate it
if I only keep InstallerFrame it doesnt work anymore, does build but its missing necessary stuff
well is there a big difference between removing and moving it somewhere where it can't be accessed by anything?
like by obfuscating it, you are practically removing it
im not too sure what you mean
I have created a ton of classes that solely interact with each other, and some outside libraries, I want to obfuscate the names of my classes and variables so that they are not that easy to read and copy, that is all I want it to do
and what's calling your classes?
It does still need to interact with outside libraries, this is for a minecraft 1.8.9 forge mod, so it cannot rename those other libraries
Minecraft Forge
Then how does forge know what classes it needs to call?
oh its been a long time since ive configured that, let me take a look
I think
-dontshrink
does what you asked forI do know ill need to keep some files for it to be recognized by forge, but I just wanted to see if obfuscation was possible, and figured I would fix that later on
but it would probably not work as you want it to work
YES
I think so
yes I need to keep some files that are nessecary, but at least this is working up until this point
because of exactly that - you are telling forge about some classes - but these wouldn't be accessible to forge any more as soon as you obfuscate it
True, I can just keep my main Mod subclass
and that's what you need to use
-keep
for
and if you "keep" your bot class, it should make sure all classes used by that still exist - but they would be obfuscatedIm pretty sure Forge just looks for an exact name given in some config file, if I rename it there as well I should be good, no?
?
just make sure to "keep" everything forge looks for?
you wouldn't know what to put there I think..?
because the name generated by proguard is random
it looks like I can just
should be all I need
however I do have one issue, I have a mixins json file which references some java files which are renamed, do you know of a way that I can rename them in this json file as well
sure you need the
-dontshrink
now?
keep themthere should be a way to have them get renamed by proguard, no? I decompiled some other mods which use obfuscation and they have them renamed, I assume they have not done this manually
It looks like this,
jesse.scriptmod.envcheck.MixinConfigPlugin
is the exact path, and everything in "mixins" is in jesse.scriptmod.mixins packageIs the file part of whatever you are obfuscating?
is it a "resource file"?
im not sure about the exact terminology, but it is inside a resources folder yes
and does not get obfuscated currently, and I do not want it to, only have these names get renamed as well
Stack Overflow
ProGuard - Obfuscate classes name inside resource file
I'm using reflection to create classes. the classes names are located inside xml file called "classes.xml". I need to obfuscate my code using proguard. I have the following package structure:
/msoft/
updated mixins config file from another mod for reference
idk Minecraft modding lol
should I give this a file filter?
The file I need to get updated is located in
src/main/resources/mixins.scriptmod.json
, what should be the filter
is it just mixins.scriptmod.json
?
ill try
-adaptresourcefilecontents **/mixins.scriptmod.json
does not seem to do anythingDo you need that at all?
You are obfuscating the generated JAR, right?
yes, but forge reads this json file, so they need to exist
oh it looks like it did update the package, the other files were not recognized
perhaps I can fix that
Yeah if the file is part of the JAR, it should be updated I think
at least with that option
in the json file they are solely the class name, not the directory
perhaps thats why it doesnt update these, let me try some things
oh - no, that doesn't work
try keeping those
if it works, you can still try other things
changing it to does work now
though im not sure if Forge will still read them correctly, let me test it out
it seems to be fine, this looks perfect
though my installer seems to be broken now, ill probably have to keep some more files
ill check that out, thanks so much for your help I really appreciate it!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
haha smart bot
ill keep it open for now
that thing is stupidly simple
fair
I meant more like, funny little feature
I cannot seem to get the Installer working when its obfuscated, I cannot find any breaking differences
would it help if I sent both obfuscated and non obfuscated jar files here
oh
in
getLogoLabel()
I have
though the logo is still in the obfuscated zip
is it going wrong at the this.logoLabel == null
?ok so obfuscators do all sorts of stuff that generates half-valid code
ig that's probably some case where it just generated something that couldn't run
The verifier ensures that all code us valid in some ways before executing it - and
VerifyError
means that detected an issueStack Overflow
Obfuscation causes VerifyError: Expecting a stackmap frame
We are using latest JDK 7 (u45) and ProGuard Version 4.10
Lately starting our distribution fails, after obfuscating it, with the following error:
Exception in thread "main" java.lang.VerifyError:
remove
-dontpreverify
its not building when I do this
the manual is telling me I could use
-dontpreverify
try adding
-libraryjars
with all dependency JARs
or maybe you could try -allowaccessmodification
idkhttps://github.com/Guardsquare/proguard/issues/411#issuecomment-2154928641
it seems like
-dontpreverify
can't be usedGitHub
java.lang.VerifyError: Expecting a stackmap frame at branch target ...
Hi Team, While obfuscation my Shadow Jar which is dependent on multiple modules I have added rule to keep class inside one package -keep class com.service.** { *; } Still I can see that proguard is...
no idea about that though
I have no idea where these are located, not too experienced with java compilation
would my gradle build file help?
I think there might be a Gradle command to get all
project.configurations.runtimeClasspath
should give you all dependencies
or alternatively project.configurations.compileClasspath
probably makes more sense
Im getting
........
at proguard.InputReader.readInput(InputReader.java:282) ~[proguard-base-7.5.0.jar:7.5.0]
at proguard.InputReader.readInput(InputReader.java:229) ~[proguard-base-7.5.0.jar:7.5.0]
at proguard.InputReader.readInput(InputReader.java:206) ~[proguard-base-7.5.0.jar:7.5.0]
at proguard.InputReader.execute(InputReader.java:157) ~[proguard-base-7.5.0.jar:7.5.0]
at proguard.pass.PassRunner.run(PassRunner.java:24) ~[proguard-base-7.5.0.jar:7.5.0]
at proguard.ProGuard.readInput(ProGuard.java:330) ~[proguard-base-7.5.0.jar:7.5.0]
at proguard.ProGuard.execute(ProGuard.java:123) ~[proguard-base-7.5.0.jar:7.5.0]
at proguard.ProGuard.main(ProGuard.java:648) ~[proguard-base-7.5.0.jar:7.5.0]
Caused by: java.io.IOException: No such file or directory:
.......
I feel like this is a lot of trouble for something I dont even know will work
are you sure giving it the library jars will have it be able to build?
no
is there maybe something in the compile classpath that isn't a JAR?
or maybe an empty string/path?
doesnt seem to be
I can try to clear the cache
these all do exist
oh my bad I was separating with : and im on Windows so should have been ;
this might be the problem im facing now
this is really weird to me, im keeping everything, so it should include that right? My current proguard rules file:
I added the java.base.jmod file to the libraryjars, now am getting
yeah it cant find JFrame, I have no idea why
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.