43. IoT and OT Security – Cameras, Smart Devices, Plant Networks
43.9 Lab – Mosquitto MQTT or Fake Camera UI on OWN VM
Pick Path A (MQTT – preferred) or Path B (tiny HTTP "camera" page). Host-only only.
Path A – Mosquitto on Amazon Linux / Ubuntu (192.168.56.50 or .40):
# Amazon Linux
sudo yum install mosquitto mosquitto-clients
# Ubuntu:
# sudo apt update && sudo apt install -y mosquitto mosquitto-clients
sudo service mosquitto start
sudo service mosquitto status
# Weak start (lab only – then FIX in project): anonymous open on all interfaces
# Edit /etc/mosquitto/mosquitto.conf (paths vary) toward:
# listener 1883 0.0.0.0
# allow_anonymous true
sudo service mosquitto restart
# From same VM or Kali – OWN lab only:
mosquitto_sub -h 192.168.56.50 -t 'sahyadri/warehouse/#' -v
# Other terminal:
mosquitto_pub -h 192.168.56.50 -t 'sahyadri/warehouse/door' -m 'open'
Path B – tiny "camera" web UI (Python http.server or Nginx static page) with a login form that accepts anything at first (lab), then you fix to a real password check + firewalld source allow from Kali only. Keep it on host-only .50.
# Optional: firewalld on the IoT VM – start open, later tighten
sudo yum install firewalld
sudo systemctl enable firewalld
sudo service firewalld start
sudo firewall-cmd --list-all
From Kali 192.168.56.10 (OWN only): nmap -sS -T2 -p 1883,80,22 192.168.56.50 – document open ports. Do not aim at anything outside 192.168.56.0/24.
| Red team (attacker) does | Blue team (defender) detects / stops |
|---|---|
Anonymous MQTT pub to sahyadri/# |
After fix: auth required; ACL; log shows denied |
| Nmap finds 1883/80 on IoT VM | Expected in weak phase; after fix only needed ports |
Uses Metasploitable .20 as side practice |
Still host-only; don't bridge IoT to internet |
Ravindra Bagale's Tip
Students copy-paste systemctl start – in the notes it is sudo service mosquitto start, with enable only for boot. Keep a snapshot of the weak config before the fix. Interview walk-through: weak → prove → harden → prove. Remember this.
Ravindra Bagale's Tip – मराठी
Students systemctl start copy-paste करतात – notes मध्ये sudo service mosquitto start, enable फक्त boot साठी. Weak config चा snapshot fix च्या आधी ठेवा. Interview walk: weak → prove → harden → prove. हे लक्षात ठेवा.
Ravindra Bagale's Tip – हिंदी
Students systemctl start copy-paste करते हैं – notes में sudo service mosquitto start, enable सिर्फ़ boot के लिए. Weak config का snapshot fix से पहले रखो. Interview walk: weak → prove → harden → prove. यह याद रखो.
Lab
Pair: Salman installs Path A on .50; Ravina runs mosquitto_pub / sub from Kali. Screenshot anonymous success. Ethics line signed (host-only). Then jump to project box to harden.