rapid7/metasploit-framework — pull request #2046 by wchen-r7 (2013-07-02 05:03:52+00:00)
Title: Allow "base" argument for to_hex_dump

[SeeRM:#8121] - For debugging purposes, it's useful to be able to specify a base.

I also changed the output format a little to make it look more like the command "hexdump -C". Here's an example of basic usage.

>> puts Rex::Text.to_hex_dump(Rex::Text.rand_text(20))
c3 66 bb a7 11 2d 9b 10 b3 97 e0 50 95 51 2d 3c |.f...-.....P.Q-<|
8a bc 09 71 |...q|

Here's an example of specifying the base:

>> puts Rex::Text.to_hex_dump(Rex::Text.rand_text(50), 16, 0x00140000)
00140000 b8 d5 1c a6 22 76 2e 78 f2 d6 f7 d5 ec 98 b0 4d |...."v.x.......M|
00140010 6a db 78 03 51 7a 51 87 f1 eb 05 23 41 73 de d4 |j.x.QzQ....#As..|
00140020 23 79 ae c5 fe ca 6b 5c 6f dd 26 0a 85 18 01 b5 |#y....k\o.&.....|
00140030 e5 19 |..|

Note: The base argument is placed 3rd, because this maintains the original usage.