How to Print string in Bro

Hi,

I am writing a bro event handler with one argument as “string” type. The string is actually treated as a byte stream but not ended with ‘\0’ in Bro.
I am wondering is there any way to print the hexadecimal value of each byte in this string (including how to index each byte within the string). I know that %s can print string, but it prints out the ASCII code, which sometimes is hard to decode.

Best,

You have a couple of choices with this right now.

local test_string = "this is\x00a test";
print string_to_ascii_hex(test_string);
  => 7468697320697300612074657374
print hexdump(test_string);
  => 0000 74 68 69 73 20 69 73 00 61 20 74 65 73 74 this is. a test^J

Would either of those work for you?

  .Seth