mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 15:18:20 +00:00

- Missing GeoIP databases now generate warnings/errors that go through the reporter framework instead of hitting GeoIP's internal use of stderr - lookup_location now just queries for country code if the city database was not loaded, which gets rid of invalid database type errors. - lookup_location now leaves missing fields uninitialized in the returned geo_location record value. Updated existing scripts to check for initialized fields in geo_location records before use. - Fixed support for GeoIP's IPv6 API and databases
52 lines
1.4 KiB
Text
52 lines
1.4 KiB
Text
@load base/frameworks/notice/main
|
|
@load base/protocols/smtp/main
|
|
|
|
module SMTP;
|
|
|
|
export {
|
|
redef enum Notice::Type += {
|
|
Suspicious_Origination
|
|
};
|
|
|
|
## Places where it's suspicious for mail to originate from represented as
|
|
## all-capital, two character country codes (e.x. US). It requires
|
|
## libGeoIP support built in.
|
|
const suspicious_origination_countries: set[string] = {} &redef;
|
|
const suspicious_origination_networks: set[subnet] = {} &redef;
|
|
|
|
}
|
|
|
|
event log_smtp(rec: Info)
|
|
{
|
|
local ip: addr;
|
|
local loc: geo_location;
|
|
if ( rec?$x_originating_ip )
|
|
{
|
|
ip = rec$x_originating_ip;
|
|
loc = lookup_location(ip);
|
|
|
|
if ( (loc?$country_code &&
|
|
loc$country_code in suspicious_origination_countries) ||
|
|
ip in suspicious_origination_networks )
|
|
{
|
|
NOTICE([$note=Suspicious_Origination,
|
|
$msg=fmt("An email originated from %s (%s).",
|
|
loc?$country_code ? loc$country_code : "", ip),
|
|
$id=rec$id]);
|
|
}
|
|
}
|
|
if ( rec?$path )
|
|
{
|
|
ip = rec$path[|rec$path|-1];
|
|
loc = lookup_location(ip);
|
|
|
|
if ( (loc?$country_code &&
|
|
loc$country_code in suspicious_origination_countries) ||
|
|
ip in suspicious_origination_networks )
|
|
{
|
|
NOTICE([$note=Suspicious_Origination,
|
|
$msg=fmt("Based up Received headers, email originated from %s (%s).", loc?$country_code ? loc$country_code : "", ip),
|
|
$id=rec$id]);
|
|
}
|
|
}
|
|
}
|