🖥️xxd

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the xxd command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗  ██╗██╗  ██╗██████╗ 
#                ╚██╗██╔╝╚██╗██╔╝██╔══██╗
#                 ╚███╔╝  ╚███╔╝ ██║  ██║
#                 ██╔██╗  ██╔██╗ ██║  ██║
#                ██╔╝ ██╗██╔╝ ██╗██████╔╝
#                ╚═╝  ╚═╝╚═╝  ╚═╝╚═════╝ 
                                        
                                        
# Convert bin/string to hex.
# Result: 34322069732074686520736f6c7574696f6e0a
echo '42 is the solution' | xxd -p

# Convert hex to bin/string.
# Result: 42 is the solution
echo '34322069732074686520736f6c7574696f6e0a' | xxd -r -p

# Make a hexdump or do the reverse with the xxd command
xxd /path/to/binary/file
# Explanation: This shows a very nice hexdump of the specified file. You can edit the output and convert it back to binary with xxd -r. But the best part is that you can configure vim to do all the converting back and forth for you, effectively turning vim into a binary editor, by adding this to your .vimrc:

# augroup Binary
     # au!
     # au BufReadPre  *.bin let &bin=1
     # au BufReadPost *.bin if &bin | %!xxd
     # au BufReadPost *.bin set ft=xxd | endif
     # au BufWritePre *.bin if &bin | %!xxd -r
     # au BufWritePre *.bin endif
     # au BufWritePost *.bin if &bin | %!xxd
     # au BufWritePost *.bin set nomod | endif
# augroup END

# This will work for editing .bin files. To use it for other file extensions too, duplicate the lines within augroup and replace *.bin with *.exe for example. This tip is from vim's :help xxd.

#==============================##==============================#
# CMD XXD						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░