-
Notifications
You must be signed in to change notification settings - Fork 1
/
mqtt_stego.zeek
66 lines (56 loc) · 1.91 KB
/
mqtt_stego.zeek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@load policy/protocols/mqtt
@load vtcs.zeek
global MQTT_id : table[addr] of STC = {};
global MQTT_user : table[addr] of STC = {};
global MQTT_pass : table[addr] of STC = {};
global MQTT_alive : table[addr] of ITC = {};
global MQTT_clean : table[addr] of BTC = {};
global counter : int;
event zeek_init() {
print "hello";
counter = 0;
}
event mqtt_publish (c: connection, is_orig: bool, msg_id: count, msg: MQTT::PublishMsg){
# print "pub";
# print find_entropy(msg$payload)$entropy;
if (find_entropy(msg$payload)$entropy > 3.5){
print "entrophy too high";
NOTICE([$note=Possible_Steganography,
$conn=c,
$ts = network_time(),
$sub = "The entrophy of MQTT payload is too high",
$msg = "Possible steganography"]);
}
check_freqency_b(MQTT_clean,c$id$orig_h,msg$retain,"MQTT RETAIN MESSAGE");
print msg_id;
}
event mqtt_subscribe(c: connection, msg_id: count, topics: string_vec, requested_qos: index_vec){
print "subscribe";
for (i in topics)
{
print topics[i];
print find_entropy(topics[i])$entropy;
if (find_entropy(topics[i])$entropy> 3.5){
NOTICE([$note=Possible_Steganography,
$conn=c,
$msg = "Possible steganography",
$sub = "The entrophy of topic is too high",
$ts = network_time()]);
}
}
print msg_id;
}
event mqtt_connect(c: connection, msg: MQTT::ConnectMsg){
counter = counter + 1;
print counter;
print "=====";
check_freqency(MQTT_id,c$id$orig_h,msg$client_id,"MQTT ID CHANGING TOO FREQUENTLY");
check_freqency(MQTT_user,c$id$orig_h,msg$username,"MQTT USER CHANGING TOO FREQUENTLY");
check_freqency(MQTT_pass,c$id$orig_h,msg$password,"MQTT PASSWORD CHANGING TOO FREQUENTLY");
check_freqency_t(MQTT_alive,c$id$orig_h,msg$keep_alive,"MQTT KEEP ALIVE CHANGING TOO FREQUENTLY");
check_freqency_b(MQTT_clean,c$id$orig_h,msg$clean_session,"MQTT CLEAN SESSION");
}
event log_mqtt( msg: MQTT::ConnectInfo)
{
print msg;
}