I want to decode a base64 encoded string to human readable data, and seeking right encoding for the same.
This is the command that i am trying
echo H4sICJVHi14AA2ZsYWcyLnR4dAAzsvLzdHb193O1Kkktyk3KzLNKLjMp4gIAtRX2oBcAAAA= | base64 -d
Abve outputs to some fuzzy non human readable data.
�G�^flag2.txt3���tv��s�*I-�M�̳J.3)����
Why many characters are missed? How can i read all the characters?
My gnome terminal is set to utf-8. Is there a better / wider encoding ? How do i set that?
Your Base64 encoded data is binary with mixed printable characters and mixed non-printable.
Lets see what it actually contain with hexdump
:
<<<'H4sICJVHi14AA2ZsYWcyLnR4dAAzsvLzdHb193O1Kkktyk3KzLNKLjMp4gIAtRX2oBcAAAA=' base64 -d | hexdump -C
00000000 1f 8b 08 08 95 47 8b 5e 00 03 66 6c 61 67 32 2e |.....G.^..flag2.|
00000010 74 78 74 00 33 b2 f2 f3 74 76 f5 f7 73 b5 2a 49 |txt.3...tv..s.*I|
00000020 2d ca 4d ca cc b3 4a 2e 33 29 e2 02 00 b5 15 f6 |-.M...J.3)......|
00000030 a0 17 00 00 00 |.....|
00000035
You can extract valid text with the strings
command:
<<<'H4sICJVHi14AA2ZsYWcyLnR4dAAzsvLzdHb193O1Kkktyk3KzLNKLjMp4gIAtRX2oBcAAAA=' base64 -d | strings
flag2.txt
J.3)
Or save it to a bin file:
<<<'H4sICJVHi14AA2ZsYWcyLnR4dAAzsvLzdHb193O1Kkktyk3KzLNKLjMp4gIAtRX2oBcAAAA=' >file.bin base64 -d
Lets check what it is:
file file.bin
file.bin: gzip compressed data, was "flag2.txt", last modified: Mon Apr 6 15:15:33 2020, from Unix, original size modulo 2^32 23
Since it is a gzip
'ed data, lets gunzip
it:
<file.bin gunzip
2:NICEONE:termbin:cv4r
Or doing it all in one-line:
<<<'H4sICJVHi14AA2ZsYWcyLnR4dAAzsvLzdHb193O1Kkktyk3KzLNKLjMp4gIAtRX2oBcAAAA=' base64 -d | gunzip
2:NICEONE:termbin:cv4r