Do you prefer that cold sweat trickling down your back when the factory line stops, or those sudden heart palpitations when you spot an unknown IP address in what you thought was an 'air-gapped' system?
Hey buddy, today we’re stepping into a dusty, noisy, and equally dangerous territory: the heart of Operational Technology (OT) and Industrial Control Systems (ICS). In our Red Team world, this is the most 'fun yet risky' place to break. Why? Because a tiny syntax error here doesn’t just crash a server; it could cause a massive real-world accident or turn a million-dollar production line into scrap metal.
That Famous 'Air-Gap' Lie
Let’s be real. We’ve all heard—or even said—the phrase 'Man, that system isn't connected to the internet, nobody can get in.' But you know as well as I do that those systems are never truly isolated. Think about those 'clean' USB sticks brought in for maintenance, that ancient laptop the contractor uses to connect to the PLC (which probably hosts three different RATs), or those stealthy 4G modems tucked behind a panel for 'remote technical support'...
In cybersecurity, 'Air-Gap' has become more of a marketing slogan than a technical term. In the real world, the IT (Information Technology) and OT (Operational Technology) worlds are now joined at the hip. If your ERP system isn’t getting data from the production line, you can’t run that factory. And that exact connection point? That’s our entry ticket.
The Naive World of PLCs: Why is Modbus so 'Polite'?
Most industrial protocols (Modbus, Profinet, EtherNet/IP) were built back in the day with a 'just make it work' mindset, not security. Take Modbus TCP, for example. There’s no such thing as authentication in this protocol. If you’ve pivoted into the network and can reach the PLC (Programmable Logic Controller), you can essentially make it do anything.
Think about it: You tell the PLC, 'Open that valve,' and it just goes, 'Sure thing, boss, opening it now.' It doesn’t question who you are, it doesn’t check your permissions. This naivety is one of the vulnerabilities we simulate most often in our 'testCompany' labs.
Below is a simple and defanged Python example aimed at modifying a digital output (coil) on a PLC. The goal of this code is purely to demonstrate how vulnerable the protocol is by design:
# SECURITY WARNING: This code is for educational purposes only.
# Defanged Modbus Write Example
from pymodbus.client import ModbusTcpClient
import logging
# Target PLC IP address (localhost for simulation)
PLC_IP = '127.0.0.1'
PORT = 502
def check_and_manipulate_valve(address, status):
# Connection attempt
client = ModbusTcpClient(PLC_IP, port=PORT)
try:
if client.connect():
print(f"[+] Connected to PLC at {PLC_IP}.")
# Read current status
current_val = client.read_coils(address, 1)
# current_val.bits[0] would show the actual status
print(f"[*] Checking Valve (Address {address}) status...")
# Logic: If we want to change it (Defanged demonstration)
# client.write_coil(address, status)
print(f"[!] Simulation: Command to change address {address} to {status} would be sent here.")
else:
print(f"[-] Could not connect to {PLC_IP}.")
except Exception as e:
print(f"[!] Error: {e}")
finally:
client.close()
# Simulate checking valve at address 10
check_and_manipulate_valve(10, True)
How Do We Actually Defend This?
Since we can't just 'patch' a protocol that was designed 40 years ago, we have to build a fortress around it. Here’s what we usually advise after our Red Team exercises:
- Deep Packet Inspection (DPI): Use firewalls that actually understand industrial protocols. They shouldn't just see 'TCP 502' traffic; they should see that someone is trying to 'Write' a coil and block it if it's coming from an unauthorized source.
- Network Segmentation (The Right Way): The OT network should be behind a DMZ. No direct path from the corporate Wi-Fi to the factory floor. Ever.
- Physical Security & Port Disabling: If a port isn't being used on a switch, shut it down. If a PLC has a physical 'Run/Stop' key, don't leave it in 'Remote' mode unless absolutely necessary.
Stay safe out there, and remember: if it's got a wire (or a radio wave) attached to it, it's not truly air-gapped.
