{"id":4108,"date":"2017-01-23T00:32:17","date_gmt":"2017-01-23T00:32:17","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=4108"},"modified":"2017-01-23T00:36:48","modified_gmt":"2017-01-23T00:36:48","slug":"hunting-for-a-better-hex-dump-tool","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2017\/01\/23\/hunting-for-a-better-hex-dump-tool\/","title":{"rendered":"Hunting for a better hex dump tool"},"content":{"rendered":"<p>Many command line tools are written with an ancient 80&#215;25 terminal size in mind and as such their output is often limited (at least, for a current standard). This is quite amazing that a concept of writing tools destined for such a small terminal is so omnipresent given the fact high resolution computer screens, as well as dual- and multi- monitor setups are now such a common thing.<\/p>\n<p>With this in mind a few years ago I coded a simple hex dump tool which I now use quite often &#8211; it gives me a better output than a typical hexdump, and&#8230; it was a fun exercise to do. The script is written in perl, fully portable (no dependencies) and&#8230; it can for sure be a) buggy b) improved in many ways &#8211; use at your own risk \ud83d\ude42<\/p>\n<p>The idea that I came with was based on a large amount of unused space I have observed on my terminal (one that I use on Windows). It is typically at least 140&#215;50 and even more, when needed. As such, the 80 columns used by the standard hex dump tool leaves an empty space of at least 70 characters&#8230;<\/p>\n<p>Let&#8217;s have a look at cygwin&#8217;s hexdump ran in a canonical mode:<\/p>\n<p><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-4109\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex1-300x58.png\" width=\"500\" height=\"97\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex1-300x58.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex1-768x150.png 768w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex1-1024x200.png 1024w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex1.png 1149w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a>I had an idea that this gap could be utilized to present more data. So, my script prints the output similar to the canonical output of hexdump, plus a bonus. The bonus includes:<\/p>\n<ul>\n<li>the data decimal offset<\/li>\n<li>extracted strings (both ANSI and wide) that start within the current line<\/li>\n<\/ul>\n<p>The output looks like this:<\/p>\n<p><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex2-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-4115\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex2-1-300x63.png\" width=\"500\" height=\"105\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex2-1-300x63.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex2-1-768x161.png 768w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex2-1-1024x215.png 1024w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/hex2-1.png 1157w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a>Isn&#8217;t that cool?<\/p>\n<p>You can immediately copy many of the strings to clipboard w\/o using strings tool.<\/p>\n<p>This is how to run the script:<\/p>\n<pre>perl hex.pl &lt;filename&gt;\r\nperl hex.pl -s &lt;filename&gt;\r\nperl hex.pl -S &lt;filename&gt;\r\nwhere:\r\n-s - extract strings\r\n-S - extract strings, and skip output lines w\/o strings<\/pre>\n<p>You can download the script <a href=\"https:\/\/hexacorn.com\/d\/hex.pl\">here<\/a>.<\/p>\n<p>If you find any bugs or run into any issue, please let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many command line tools are written with an ancient 80&#215;25 terminal size in mind and as such their output is often limited (at least, for a current standard). This is quite amazing that a concept of writing tools destined for &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2017\/01\/23\/hunting-for-a-better-hex-dump-tool\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[54,44,5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/4108"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=4108"}],"version-history":[{"count":6,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/4108\/revisions"}],"predecessor-version":[{"id":4117,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/4108\/revisions\/4117"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=4108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=4108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=4108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}