Hello, it's possible to hide a .zip archive within a .sh text file. This is a old trick, but still comes in handy every now again. I had to use it today to meet a goal, so I though I'd post this for others while its fresh in my mind.
Start off with a regular bash script and some code to deploy the embedded file.
#!/bin/sh
echo "deploying image.zip"
# this code tails the encoded .zip when the script is run. for example I have created a .zip with Install.png, which I extract to tmp.
SKIPTO=`awk '/^__ARCHIVE__/ { print NR + 1; exit 0; }' $0`
tail +$SKIPTO "$0" > /tmp/Install.zip
unzip -j -o /tmp/Install.zip -d /tmp
mv /tmp/Install.png /User/Shared/
echo "all done"
exit 0
__ARCHIVE__
The extra return after "ARCHIVE" is important.
Next, create a zip file in Finder. In the example above, I right clicked on Install.png on my Desktop and selected "compress". But it can be anything: DMG, IMG, ics, unix binary, etc....
Now we need to get the .zip into the script.
Use this command in terminal to append the zip to the script:
cat /path/to/Install.zip >> /path/to/script.sh
And we're done. The script has been charged with the .zip and is ready to go. Opening the script in a text editor will produce errors, because it mixed ascii and encoded text. BASH doesn't seem to care when the script is executed.
Hope this helps!
