I’m testing a new script in 2.5 that uses ActiveHTTP but I’m unable to retrieve the response. With a simple test script of:
when ( local resp = ActiveHTTP::request([$url=“https://www.google.com/”]) )
{
print “Inside the Matrix."
}
I can see the ActiveHTTP request was successful based on the temporary files created:
-rw-r–r-- 1 dave wheel 162 Jan 27 23:43 /tmp/bro-activehttp-HJKhXt6UYXi_body
-rw-r–r-- 1 dave wheel 163 Jan 27 23:43 /tmp/bro-activehttp-HJKhXt6UYXi_headers
But the print statement within the when block never executes. Any ideas what I’m missing?
I added simple print statements in base/utils/active-http.bro and it doesn’t appear to be entering it’s when() block either. These are the two print statements I added:
print “Entering the ActiveHTTP::Request when() block”;
return when ( local result = Exec::run([$cmd=cmd, $stdin=stdin_data, $read_files=set(bodyfile, headersfile)]) )
{ print “In ActiveHTTP::Request when() block”;
If there is no response line then nothing else will work either.
And the second print doesn’t execute:
$ bro -r test.pcap local …/test.bro
Entering the ActiveHTTP::Request when() block…
I have ‘exit_only_after_terminate’ set to true so it just hangs at this point until I ctrl-c and I see the tmp files deleted.
I responded with a follow-up to my original email and temp files are there because I have ‘exit_only_after_terminate’ set to true, so it pauses until I ctrl-c and the tmp files are then deleted.
I tried with —pseudo-realtime as well as creating a new PCAP to test with but it still exhibits the same behavior. ActiveHTTP successfully makes the request, and receives a response based other the contents of the temp files, but the when() block is never executed.
The reporter.log only has an event for the termination:
#types time enum string string
1485725443.690539 Reporter::INFO received termination signal (empty)
Is anyone able to re-create the same issue or is this limited to my environment?
I’ve been able to test this in another environment (Debian 8.7 x64) and unlike OS X where the ActiveHTTP conducts a successful request but then doesn’t enter the when{} block, on Debian it errors with the following written to reporter.log:
Ok, scratch that error message. The box I was testing on didn’t have curl installed. After installing curl the test script has the same behavior as when run on OS X. Work great by itself but hangs before the when{} block if passed a PCAP.
Ok, scratch that error message. The box I was testing on didn’t have curl installed. After installing curl the test script has the same behavior as when run on OS X. Work great by itself but hangs before the when{} block if passed a PCAP.
Thanks Jan, what version of Bro are you running and on which platform?
I have 'bro version 2.5-30’, compiled from Github master, on Debian 8.7 and macOS 10.12.2 and both hang until I ctrl-C, and neither enters the when{} block:
macOS$ time bro -r bro_dev/Mswab_Yayih_FD1BE09E499E8E380424B3835FC973A8_2012-03.pcap b.bro
^C1330843811.964963 received termination signal
real 8m30.316s
user 1m31.343s
sys 6m58.036s
debian$ time bro -r test2.pcap b.bro
^C1330843811.964963 received termination signal
Thanks Jan, what version of Bro are you running and on which platform?
I am using Bro 2.5 on Fedora 23 (4.8 kernel).
I have 'bro version 2.5-30’, compiled from Github master, on Debian 8.7 and macOS 10.12.2 and both hang until I ctrl-C, and neither enters the when{} block:
$ time bro --pseudo-realtime -r
Mswab_Yayih_FD1BE09E499E8E380424B3835FC973A8_2012-03.pcap b.bro
[code=302, msg=Found\x0d, body=...]
1485807420.620682 received termination signal
real 1m0.583s
user 0m26.229s
sys 0m34.185s
Without "--pseudo-realtime" it seems to hang for me, too. Have you tried
using it?
Following on this ticket from the main Bro list, I wonder if we could change the behavior of Bro slightly to make what Dave tried work? I *think* the problem here is that once the packets run out, Bro's internal clock stops moving forward which causes all sorts of trouble for timers and other stuff I'm sure.
What does everyone think about making the clock continue to move forward even after the packet source runs dry? This especially makes sense when someone uses pseudo-realtime because we can keep moving the clock at the rate it was moving (but not jump to current time, we'd just do subtraction based on the time when the packet source ran dry). The main problem I see with this idea is if someone reads a PCAP at full speed, what rate do we make the clock continue ticking?
Does this idea make sense at all? I think we've had too many new Bro programmers get frustrated with this behavior which worries me a little bit.