mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00

While we support initializing records via coercion from an expression list, e.g., local x: X = [$x1=1, $x2=2]; this can sometimes obscure the code to readers, e.g., when assigning to value declared and typed elsewhere. The language runtime has a similar overhead since instead of just constructing a known type it needs to check at runtime that the coercion from the expression list is valid; this can be slower than just writing the readible code in the first place, see #4559. With this patch we use explicit construction, e.g., local x = X($x1=1, $x2=2);
73 lines
2.1 KiB
Text
73 lines
2.1 KiB
Text
@load base/frameworks/intel
|
|
@load ./where-locations
|
|
@load base/utils/addrs
|
|
|
|
event http_header(c: connection, is_orig: bool, name: string, value: string) &group="Intel::ADDR"
|
|
{
|
|
if ( ! is_orig )
|
|
return;
|
|
|
|
switch ( name )
|
|
{
|
|
case "HOST":
|
|
# Remove the occasional port value that shows up here.
|
|
local host = gsub(value, /:[[:digit:]]+$/, "");
|
|
if ( is_valid_ip(host) )
|
|
Intel::seen(Intel::Seen($host=to_addr(host),
|
|
$indicator_type=Intel::ADDR,
|
|
$conn=c,
|
|
$where=HTTP::IN_HOST_HEADER));
|
|
break;
|
|
|
|
case "X-FORWARDED-FOR":
|
|
if ( is_valid_ip(value) )
|
|
{
|
|
local addrs = extract_ip_addresses(value);
|
|
for ( i in addrs )
|
|
{
|
|
Intel::seen(Intel::Seen($host=to_addr(addrs[i]),
|
|
$indicator_type=Intel::ADDR,
|
|
$conn=c,
|
|
$where=HTTP::IN_X_FORWARDED_FOR_HEADER));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
event http_header(c: connection, is_orig: bool, name: string, value: string) &group="Intel::DOMAIN"
|
|
{
|
|
if ( ! is_orig || name != "HOST" )
|
|
return;
|
|
|
|
# Remove the occasional port value that shows up here.
|
|
local host = gsub(value, /:[[:digit:]]+$/, "");
|
|
if ( ! is_valid_ip(host) )
|
|
Intel::seen(Intel::Seen($indicator=host,
|
|
$indicator_type=Intel::DOMAIN,
|
|
$conn=c,
|
|
$where=HTTP::IN_HOST_HEADER));
|
|
}
|
|
|
|
|
|
event http_header(c: connection, is_orig: bool, name: string, value: string) &group="Intel::URL"
|
|
{
|
|
if ( ! is_orig || name != "REFERER" )
|
|
return;
|
|
|
|
Intel::seen(Intel::Seen($indicator=sub(value, /^.*:\/\//, ""),
|
|
$indicator_type=Intel::URL,
|
|
$conn=c,
|
|
$where=HTTP::IN_REFERRER_HEADER));
|
|
}
|
|
|
|
event http_header(c: connection, is_orig: bool, name: string, value: string) &group="Intel::SOFTWARE"
|
|
{
|
|
if ( ! is_orig || name != "USER-AGENT" )
|
|
return;
|
|
|
|
Intel::seen(Intel::Seen($indicator=value,
|
|
$indicator_type=Intel::SOFTWARE,
|
|
$conn=c,
|
|
$where=HTTP::IN_USER_AGENT_HEADER));
|
|
}
|