- mosquitto (host machine): follow the installation instructions here
- docker + docker-compose: both are present in the docker-desktop package (recommended)
git clone [email protected]:e-valente/mqtt-security-labs.git
cd backend/mosquitto-suricata
docker-compose up
mosquitto_sub -t 'sensible' -u client1 -P Tijolo200! -v
Terminal 3:
mosquitto_pub -t 'sensible' -m "Testing sensible" -u client1 -P Tijolo200!
Make sure the backend is stopped:
cd backend/mosquitto-suricata
docker-compose stop # or ctrl + c on previous step terminal
Add the following suricata rule to the backend/mosquitto-suricata/suricata-files/rules/my.rules
file:
my.rules
:
alert tcp $HOME_NET any -> any 1883 (msg:"Sensible topic alert"; mqtt.publish.topic; content:"sensible"; classtype:sensible-topic; sid:10; rev:3;)
cd backend/mosquitto-suricata
docker-compose up
Terminal 2:
mosquitto_sub -t 'sensible' -u client1 -P Tijolo200! -v
Terminal 3:
docker exec -it suricata /bin/bash
Terminal 3:
tail -f /var/log/suricata/fast.log
Terminal 4:
mosquitto_pub -t 'sensible' -m "Testing sensible" -u client1 -P Tijolo200!
After publishing, we'll see in terminal 3 (suricata terminal) the following alert:
1/10/2023-20:57:01.080197 [**] [1:10:3] Sensible topic alert [**] [Classification: Sensible Topic Publishing Activity was Detected] [Priority: 1] {TCP} 172.21.0.1:39630 -> 172.21.0.2:1883
Make sure the backend is stopped:
cd backend/mosquitto-suricata
docker-compose stop # or ctrl + c on previous step terminal
Add the following suricata rule to the backend/mosquitto-suricata/suricata-files/rules/my.rules
file:
my.rules
:
drop tcp $HOME_NET any -> any 1883 (msg:"Sensible topic preventing"; mqtt.publish.topic; content:"sensible"; classtype:sensible-topic; sid:10; rev:3;)
cd backend/mosquitto-suricata
docker-compose up
Terminal 2:
mosquitto_sub -t 'sensible' -u client1 -P Tijolo200! -v
Terminal 3:
docker exec -it suricata /bin/bash
Terminal 3:
tail -f /var/log/suricata/fast.log
Terminal 4:
mosquitto_pub -t 'sensible' -m "Testing sensible" -u client1 -P Tijolo200!
After publishing, we'll see in terminal 3 (suricata terminal) the following drop message (i.e. the message didn't get to the topic):
[Drop] [**] [1:10:3] Sensible topic preventing [**] [Classification: Sensible Topic Publishing Activity was Detected] [Priority: 1] {TCP} 172.21.0.1:53096 -> 172.21.0.2:1883
See also in terminal 2, the mosquitto client didn't receive the message content.