5

At the end, it looks like it's just a regular sh script:

[USER@MACHINE ~/Desktop/D] head -2 truecrypt-7.1-setup-x86 
#!/bin/sh
CHECKSUM=163123652

but @the scripts end:

[USER@MACHINE ~/Desktop/D] tail -2 truecrypt-7.1-setup-x86 
5��\V<Rx+÷o��6ܺF!&8�ʷ�����^��T4
Sk�!�0"�W���L�`���Su�VP�!m�]5����C'}�/���%�������8�4�?�N;:��zgf�q�14S%oL�hҌz����+����Ƥ<'��jN7)m�H�^�ɧa��:�S���so[�$_�/Ø��&#X�+x����
                                                                                                                                                        Sd  hz=��H����)n�_�������48�,4�M�x�w��z�Mp��)�Ѩa=2a��0ۙI
���YI��`��om��0�3���,�}�ȇ��I.��G���x���g��ЌÞ%�H��4�ڛ{35��0�C!�$Fԝ�?�.�T�UǺEa���38sl)��[x"��,
                                                                                               /�/���o���hV���R�`���nʂ�a��ۛ=~{#��FV����35�5Y;k��D��[mK����9 *lY��hD�:��{n����۝�$^�'���w�!$��Ĝ������*�����!'�?����?����?�+�L#(+�V

well.. binary data.. how??

[USER@MACHINE ~/Desktop/D] file truecrypt-7.1-setup-x86 
truecrypt-7.1-setup-x86: POSIX shell script text executable
[USER@MACHINE ~/Desktop/D] 

How could the file contain ASCII + binary data too? The script is launched as a script, but ends with binary data? How can they do that? How can I keep a "hello word" binary at the end of a script? [and launch the binary part from the script?]

GAD3R
  • 63,407
  • 31
  • 131
  • 192
LanceBaynes
  • 39,295
  • 97
  • 250
  • 349
  • Looks like a shar or some variant thereof (http://en.wikipedia.org/wiki/Shar#). – Ulrich Schwarz Dec 21 '11 at 07:15
  • Creating such a file is not difficult: `cat script_text_file.sh binaryfile > file_that_contains_both.sh` As far as invoking the binary from the shell, that I don't know. If the binary is compressed data, extraction may not be too hard if the extraction program "opens itself" and waits to perform decompression until it sees a header, which could be made not to appear until the binary part starts. – LawrenceC Sep 05 '12 at 14:31

3 Answers3

10

The only difference between text and binary is how you interpret it. *nix tends to not interpret them, so mixing them in this manner is fine; the text part of the script can extract the contents of the binary part of the script using various commands.

Ignacio Vazquez-Abrams
  • 44,857
  • 7
  • 93
  • 100
3

This is a common trick I see in installers. Usually the binary part is an archive and the top has the commands to extract it.

Atilla Filiz
  • 624
  • 1
  • 6
  • 13
1

"How could the file contain ASCII + binary data too?"

Simply because ASCII text is just a subset of binary data.

rozcietrzewiacz
  • 38,754
  • 9
  • 94
  • 102