diff options
author | johannst <stoelp@eit.uni-kl.de> | 2019-06-09 17:54:56 +0200 |
---|---|---|
committer | johannst <stoelp@eit.uni-kl.de> | 2019-06-09 17:54:56 +0200 |
commit | 2e97b8a7cc88b9fcdab606d2c94c376d31a47696 (patch) | |
tree | ecc69499a3b584ae88fa669fc4d1001a094a11ab | |
parent | 47477aef220e155fa9c12c2011764d00a6a967c5 (diff) | |
download | notes-2e97b8a7cc88b9fcdab606d2c94c376d31a47696.tar.gz notes-2e97b8a7cc88b9fcdab606d2c94c376d31a47696.zip |
added binary.txt, notes for xxd(1) & od(1)
-rw-r--r-- | binary.txt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/binary.txt b/binary.txt new file mode 100644 index 0000000..908fff7 --- /dev/null +++ b/binary.txt @@ -0,0 +1,52 @@ +.:: Binary ::. +-------------------------------------------------------------------------------- + +# od(1) +======== + args: + -An don't print addr info + -tx4 print hex in 4 byte chunks + -ta print as named character + -tc printable chars or backslash escape + -w4 print 4 bytes per line + + echo -n AAAABBBB | od -An -w4 -tx4 + >> 41414141 + >> 42424242 + + echo -n "\x7fELF\n" | od -tx1 -ta -tc + >> 0000000 7f 45 4c 46 0a + >> del E L F nl + >> 177 E L F \n + +# xxd(1) +========= + args: + -p dump continuous hexdump + -r convert hexdump into binary ('revert') + -e dump as little endian mode + -i output as C array + + ## from ascii to hex stream + echo -n 'aabb' | xxd -p + >> 61616262 + + ## from hex to binary stream + echo -n '61616262' | xxd -p -r + >> aabb + + ## ascii to binary + echo -n "\x7fELF" | xxd -p | xxd -r -p | file -p - + >> ELF + + ## ascii to C array (hex encoded) + xxd -i <(echo -n '\x7fELF') + >> unsigned char _proc_self_fd_11[] = { + >> 0x7f, 0x45, 0x4c, 0x46 + >> }; + >> unsigned int _proc_self_fd_11_len = 4; + + +-------------------------------------------------------------------------------- +vim:sts=2:et:tw=80:cc=80:fo+=t + |