copy paste multiple binary files

tar -c bins/ | gzip -9 | openssl enc -base64
Useful when you have multiple files or binary files that you need to transfer to a different host and scp or the like is unavailable. To unpack on the destination host copy paste output using the opposite order: openssl enc -d -base64 | gunzip | tar -x Terminate openssl input using ^d Note: gzip is outside of tar because using -z in tar produces lots of extra padding.
Sample Output
[foobar@awesome ~]$ ll
total 4
drwxr-xr-x 2 foobar foobar 4096 2011-02-24 15:02 bins
[foobar@awesome ~]$ tar -c bins/ | gzip -9 | openssl enc -base64
H4sIAKLXZk0CA+3VMUrEQBQG4MHSE4g2kwu4eZl5k2XbLQQ7sdoykRiDkEjmLWwn
iJUHEBUv4h0UK1uxsBAsLSw1UVmwWKyyy8r/NTNvZrqfn0mL0vdUt8JGzPy9Oteu
FHP0Nf9QRGyIOXJkVUhkIqc0qzkYe0lqrdV+VaVJPfvdX/dLKm3zl8xLUeabzdBV
/s7a2fk3+2n+YXNOxrpY6RD5d+51/eEuONl+eT9/2jrdHcngaJI9y+3KzvHV5cfj
4fXZsP92f7Fxk68p+Id+9V8mspD+GzvtP7f/BBm2jP7Pw7Aq8zoRH+hRNdZ7Sal9
lmk5KHywinYAAAAAAAAAAAAAAAAAAAAsh08a2nTbACgAAA==
[foobar@awesome ~]$ rm -fr bins
[foobar@awesome ~]$ openssl enc -d -base64 | gunzip | tar -x
H4sIAKLXZk0CA+3VMUrEQBQG4MHSE4g2kwu4eZl5k2XbLQQ7sdoykRiDkEjmLWwn
iJUHEBUv4h0UK1uxsBAsLSw1UVmwWKyyy8r/NTNvZrqfn0mL0vdUt8JGzPy9Oteu
FHP0Nf9QRGyIOXJkVUhkIqc0qzkYe0lqrdV+VaVJPfvdX/dLKm3zl8xLUeabzdBV
/s7a2fk3+2n+YXNOxrpY6RD5d+51/eEuONl+eT9/2jrdHcngaJI9y+3KzvHV5cfj
4fXZsP92f7Fxk68p+Id+9V8mspD+GzvtP7f/BBm2jP7Pw7Aq8zoRH+hRNdZ7Sal9
lmk5KHywinYAAAAAAAAAAAAAAAAAAAAsh08a2nTbACgAAA==
[foobar@awesome ~]$ ll
total 4
drwxr-xr-x 2 foobar foobar 4096 2011-02-24 15:02 bins

1
By: mweed
2011-02-24 22:15:23

These Might Interest You

  • Tired copy paste to get opcode from objdump huh ? Get more @ http://gunslingerc0de.wordpress.com Show Sample Output


    4
    objdump -d ./PROGRAM|grep '[0-9a-f]:'|grep -v 'file'|cut -f2 -d:|cut -f1-6 -d' '|tr -s ' '|tr '\t' ' '|sed 's/ $//g'|sed 's/ /\\x/g'|paste -d '' -s |sed 's/^/"/'|sed 's/$/"/g'
    gunslinger_ · 2010-07-11 15:44:48 4
  • When working with jailed environments you need to copy all the shared libraries to your jail environment. This is done by running ldd on a binary which needs to run inside the jail. This command will use the output from ldd to automatically copy the shared libraries to a folder of your choice. Show Sample Output


    2
    ldd file | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination
    rickard2 · 2012-02-11 17:50:10 0
  • Please note that binary file checking is NOT perfect. So, use it with caution. It does not delete hidden files whose name has a leading '.' character. And it regards an empty file as a binary file.


    1
    perl -e 'unlink grep { -f -B } <*>'
    seungwon · 2011-04-05 10:32:40 0
  • The options -b binary and -m are needed for disassembling raw machine code when it is not part of a full binary executable with proper headers. Show Sample Output


    2
    objdump -b binary -m i386 -D shellcode.bin
    recursiverse · 2010-04-27 11:11:36 2

What Others Think

why not use tar -cz?
coffeeaddict_nl · 381 weeks and 5 days ago
updated notes with explanation. Basically tar -cz uses more space/padding. du -sh wheee/ 20K wheee/ tar -cz wheee/ | wc -c 10240 tar -c wheee/ | gzip | wc -c 767
mweed · 381 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: