1
- ##! Dovehawk Zeek Module V 1.01.001 2019 07 08 @tylabs dovehawk.io
1
+ ##! Dovehawk Zeek Module V 1.01.002 2019 08 02 @tylabs dovehawk.io
2
2
# This module downloads Zeek Intelligence Framework items and Signature Framework Zeek items from MISP.
3
3
# Sightings are reported back to MISP and optionally to a Slack webhook.
4
4
# This script could be easily modified to send hits to a central database / web dashboard or to add in indicators from other sources.
@@ -14,10 +14,11 @@ module dovehawk;
14
14
@load frameworks/intel/seen
15
15
@load base/frameworks/intel
16
16
@load frameworks/intel/do_notice
17
+ @load base/utils/directions-and-hosts
17
18
18
19
19
20
export {
20
- global DH_VERSION = " 1.01.001 " ;
21
+ global DH_VERSION = " 1.01.002 " ;
21
22
22
23
# removed randomness added to internal + double_to_interval(rand(1200))
23
24
global load_signatures: function ();
@@ -111,7 +112,7 @@ function load_sigs_misp() {
111
112
112
113
for (line in lines) {
113
114
# don't write lines with double ## at start
114
- if (| lines[line]| > 2 && lines[line][0 ] != " #" && lines[line][1 ] != " #" ) {
115
+ if (| lines[line]| >= 1 && lines[line][0 ] != " #" && lines[line][1 ] != " #" ) {
115
116
print f,gsub (lines[line], / \x 0d/ , " " ) + " \n " ; # remove extra newlines Zeek doesn't like
116
117
if (sub_bytes (lines[line], 0 , 10 ) == " signature " )
117
118
cnt += 1 ;
@@ -416,6 +417,8 @@ event signature_match(state: signature_state, msg: string, data: string)
416
417
local src_port: port ;
417
418
local dst_addr: addr ;
418
419
local dst_port: port ;
420
+ local di = NO_DIRECTION;
421
+
419
422
420
423
if ( state$is_orig )
421
424
{
@@ -441,7 +444,122 @@ event signature_match(state: signature_state, msg: string, data: string)
441
444
}
442
445
443
446
hit += fmt (" |orig_h:%s |orig_p:%s |resp_h:%s |resp_p:%s " ,src_addr,src_port,dst_addr,dst_port);
444
-
447
+
448
+
449
+ local conn = state$conn;
450
+
451
+ if (Site::is_local_addr (conn$id$orig_h) || Site::is_private_addr (conn$id$orig_h) ) {
452
+ di = OUTBOUND;
453
+ } else if (Site::is_local_addr (conn$id$resp_h) || Site::is_private_addr (conn$id$resp_h) ) {
454
+ di = INBOUND;
455
+ }
456
+
457
+
458
+ if (di == OUTBOUND) {
459
+ hit += " |d:OUTBOUND" ;
460
+ } else if (di == INBOUND) {
461
+ hit += " |d:INBOUND" ;
462
+ }
463
+
464
+ if (conn?$service) {
465
+ hit += " |service:" ;
466
+ local service = conn$service;
467
+ local servicename: string = " " ;
468
+ for ( ser in service ) {
469
+ servicename += fmt (" %s ," ,ser);
470
+ }
471
+ if (| servicename| > 0 ) {
472
+ hit += cut_tail (servicename, 1 );
473
+ }
474
+ }
475
+
476
+ if (conn?$orig) {
477
+ local orig = conn$orig;
478
+ if (orig?$size) {
479
+ hit += fmt (" |orig:%s " ,orig$size);
480
+ }
481
+ if (orig?$num_pkts) {
482
+ hit += fmt (" |o_pkts:%s " ,orig$num_pkts);
483
+ }
484
+ if (orig?$num_bytes_ip) {
485
+ hit += fmt (" |o_bytes:%s " ,orig$num_bytes_ip);
486
+ }
487
+ if (orig?$state) {
488
+ hit += fmt (" |o_state:%s " ,orig$state);
489
+ }
490
+ }
491
+
492
+ if (conn?$resp) {
493
+ local resp = conn$resp;
494
+ if (resp?$size) {
495
+ hit += fmt (" |resp:%s " ,resp$size);
496
+ }
497
+ if (resp?$num_pkts) {
498
+ hit += fmt (" |r_pkts:%s " ,resp$num_pkts);
499
+ }
500
+ if (resp?$num_bytes_ip) {
501
+ hit += fmt (" |r_bytes:%s " ,resp$num_bytes_ip);
502
+ }
503
+ if (resp?$state) {
504
+ hit += fmt (" |r_state:%s " ,resp$state);
505
+ }
506
+ }
507
+
508
+ if (conn?$start_time) {
509
+ hit += fmt (" |start_time:%s " ,conn$start_time);
510
+ }
511
+
512
+ if (conn?$duration) {
513
+ hit += fmt (" |duration:%s " ,conn$duration);
514
+ }
515
+
516
+ if (conn?$http) {
517
+ local http = conn$http;
518
+ if (http?$host) {
519
+ hit += fmt (" |host:%s " ,http$host);
520
+ }
521
+ if (http?$uri) {
522
+ hit += fmt (" |uri:%s " ,http$uri);
523
+ }
524
+ if (http?$method) {
525
+ hit += fmt (" |method:%s " ,http$method);
526
+ }
527
+ }
528
+
529
+ if (conn?$ssl) {
530
+ local ssl = conn$ssl;
531
+ if (ssl?$server_name) {
532
+ hit += fmt (" |sni:%s " ,ssl$server_name);
533
+ if (ssl?$issuer) {
534
+ hit += fmt (" |issuer:%s " ,ssl$issuer);
535
+ }
536
+ }
537
+
538
+ if (conn?$smtp) {
539
+ local smtp = conn$smtp;
540
+ if (smtp?$from) {
541
+ hit += fmt (" |from:%s " ,smtp$from);
542
+ }
543
+ if (smtp?$subject) {
544
+ hit += fmt (" |subject:%s " ,smtp$subject);
545
+ }
546
+ if (smtp?$rcptto) {
547
+ hit += fmt (" |to:%s " ,smtp$rcptto);
548
+ }
549
+ }
550
+
551
+ if (conn?$dns) {
552
+ local dns = conn$dns;
553
+ if (dns?$qtype_name) {
554
+ hit += fmt (" |q:%s " ,dns$qtype_name);
555
+ }
556
+ if (dns?$answers) {
557
+ hit += fmt (" |answers:%s " ,dns$answers);
558
+ }
559
+ }
560
+ }
561
+
562
+
445
563
hit += " |sigid:" + sig_id + " |msg:" + msg;
446
564
447
565
# This should always be true but check just in case
0 commit comments