Try the following commands yourself. Start creating a regular jar file with any content, or use someone who has one. I will call him "myjar.jar"
Then create the file "hello.sh" with the content:
#!/bin/bash exec echo hello
add this file when starting a new jar file:
cat hello.sh myjar.jar > mytrick.jar chmod 700 mytrick.jar
And finally, the interesting part, type:
./mytrick.jar jar -tf mytrick.jar unzip mytrick.jar
In other words, usually jar / unzip skips any content to its own header. In addition, the shell script "ends" on the line that calls "exec" (because the interpreter interprets the command at the point in the line exec).
However, this trick is based on jar / unzip behavior, possibly outside the standards. Note, for example, that this operator does not work (has no effects):
jar -xf mytrick.jar
source share