[Bro-Dev] How to Print string in Bro

Seth Hall seth at icir.org
Wed Aug 10 22:41:32 PDT 2011


On Aug 11, 2011, at 1:28 AM, Hui Lin wrote:

> 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. 

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

--
Seth Hall
International Computer Science Institute
(Bro) because everyone has a network
http://www.bro-ids.org/




More information about the bro-dev mailing list