Currently reversing a .jar program recreationally, and I understand the workflow proposed here:
But whenever I go to repackage the folder containing the .class files into my .jar a couple of things go wrong. Firstly the file is a different size than the original, and the .jar will not run at all and instead throws a manifest error.
""" no main manifest attribute, in xxx.jar """
The only change I am making at this time is to a string changing it from "Welcome!" to "LOL!xox!".
I repackage the .jar with the following command: jar -cvf xxx-2.jar -C xxx-1/ .
If I extract the new .jar again and diff the two directories I get changes in directories that I didn't touch
└──╼ $diff -q xxx-1/ xxx-2/
Common subdirectories: xxx-1/META-INF and xxx-2/META-INF
Common subdirectories: xxx-1/net and xxx-2/net
Common subdirectories: xxx-1/org and xxx-2/org
It's worth noting that after executing jar -cvf xxx-2.jar -C xxx-1/ .
I see a significant amount of deflation (30-60%) during execution. I suspect this is some sort of Java version issue, currently running:
└──╼ $java -version
openjdk version "13.0.5.1" 2020-11-06
OpenJDK Runtime Environment (build 13.0.5.1+1-Debian-1)
OpenJDK 64-Bit Server VM (build 13.0.5.1+1-Debian-1, mixed mode)
And the Manifest contains the following version information:
- Manifest-Version: 1.0
- Ant-Version: Apache Ant 1.10.10
- Created-By: 16.0.1+0 (Homebrew)
- Main-Class: net.xxx-1.Main
- Build-Date: 2021-08-02
- Build-Revision: 8736
Original header: https://i.stack.imgur.com/HP0fE.jpg
"patched" header https://i.stack.imgur.com/qk5Rz.jpg
Original footer: https://i.stack.imgur.com/rwojo.jpg
"patched" footer: https://i.stack.imgur.com/zb5Ys.jpg
How do I generate a .jar file where the only change is the string I want to change?
Edit: Added header and foot screenshots
Original header: https://imgur.com/a/PnnwuM7
The "patched" jar header https://imgur.com/a/pFC8nPf
Original footer: https://imgur.com/a/wQy4MWq
"patched" footer: https://imgur.com/RuIH1Jl
– triboulet Jan 02 '22 at 16:48Class editing may vary between tools. Some will be very specific with the edits, while others will essentially 'recompute' how the class file's contents are organized. Can't say how each works without looking into each...
The manifest error is not due to any of these things though. Repackaging is done incorrectly. Check META-INF/MANIFEST.MF's contents in the jar/zip for 'main-class'
– Col-E Jan 21 '22 at 17:17