Skip to content

Commit 9bcb0e8

Browse files
committed
additional metadata for content hits
fix for signature download parsing from misp ignoring single character lines added flow direction to intel framework indicator hits added additional sample content signatures
1 parent f0ce049 commit 9bcb0e8

File tree

3 files changed

+156
-5
lines changed

3 files changed

+156
-5
lines changed

Diff for: scripts/dovehawk.bro

+122-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
22
# This module downloads Zeek Intelligence Framework items and Signature Framework Zeek items from MISP.
33
# Sightings are reported back to MISP and optionally to a Slack webhook.
44
# 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;
1414
@load frameworks/intel/seen
1515
@load base/frameworks/intel
1616
@load frameworks/intel/do_notice
17+
@load base/utils/directions-and-hosts
1718

1819

1920
export {
20-
global DH_VERSION = "1.01.001";
21+
global DH_VERSION = "1.01.002";
2122

2223
#removed randomness added to internal + double_to_interval(rand(1200))
2324
global load_signatures: function();
@@ -111,7 +112,7 @@ function load_sigs_misp() {
111112

112113
for (line in lines) {
113114
# 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] != "#") {
115116
print f,gsub(lines[line], /\x0d/, "") + "\n"; #remove extra newlines Zeek doesn't like
116117
if (sub_bytes(lines[line], 0, 10) == "signature ")
117118
cnt += 1;
@@ -416,6 +417,8 @@ event signature_match(state: signature_state, msg: string, data: string)
416417
local src_port: port;
417418
local dst_addr: addr;
418419
local dst_port: port;
420+
local di = NO_DIRECTION;
421+
419422

420423
if ( state$is_orig )
421424
{
@@ -441,7 +444,122 @@ event signature_match(state: signature_state, msg: string, data: string)
441444
}
442445

443446
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+
445563
hit += "|sigid:" + sig_id + "|msg:" + msg;
446564

447565
# This should always be true but check just in case

Diff for: scripts/dovehawk_expire.bro

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
##! Dovehawk Zeek Module - Intel Framework Extension V 1.01.001 2019 07 08 @tylabs
1+
##! Dovehawk Zeek Module - Intel Framework Extension V 1.01.002 2019 08 02 @tylabs
22
# dovehawk.io
33
#
44
##! This script adds per item expiration for MISP intel items. This
@@ -130,6 +130,13 @@ hook extend_match(info: Info, s: Seen, items: set[Item])
130130
hit += fmt("|node:%s",s$node);
131131
}
132132

133+
if (di == OUTBOUND) {
134+
hit += "|d:OUTBOUND";
135+
} else if (di == INBOUND) {
136+
hit += "|d:INBOUND";
137+
}
138+
139+
133140
if (conn?$service) {
134141
hit += "|service:";
135142
local service = conn$service;

Diff for: signatures/signatures.sig

+26
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,34 @@ signature cancyber_test_content {
55
payload /.*991CANCYBER_TEST_BAD_SIGNATURE991/
66
event "MISP: test content in TCP"
77
}
8+
89
signature eicar_test_content {
910
ip-proto == tcp
1011
payload /.*X5O\!P%@AP\[4\\PZX54\(P\^\)7CC\)7\}\$EICAR\-STANDARD\-ANTIVIRUS\-TEST\-FILE\!\$H\+H\*/
1112
event "MISP: eicar test file in TCP"
1213
}
14+
15+
signature cancyber-gh0st {
16+
ip-proto == tcp
17+
payload /^Gh0st/
18+
tcp-state originator
19+
event "MISP: Gh0stRat header in tcp"
20+
21+
# Plugx Variants
22+
signature cancyber-plugx_http {
23+
ip-proto == tcp
24+
tcp-state established,originator
25+
payload /POST /
26+
http-request-header /.{2,32}: 61456/
27+
event "MISP: PLUGX Beacon HTTP "
28+
}
29+
30+
# China chopper https://www.fireeye.com/blog/threat-research/2013/08/breaking-down-the-china-chopper-web-shell-part-ii.html
31+
signature cancyber-chopper_http_post {
32+
ip-proto == tcp
33+
tcp-state established,originator
34+
payload /POST /
35+
http-request-header /X-Forwarded-For/
36+
payload /.*FromBase64String/
37+
event "MISP: China Chopper POST"
38+
}

0 commit comments

Comments
 (0)