Gabriel Coello
Published © Apache-2.0

OpenPLC Lab with raspberry for Ethical Hacking

A simulated environment controlled by PLCs using OpenPLC give us a practical understanding of how industrial (OT) system works

AdvancedProtipOver 1 day108
OpenPLC Lab with raspberry for Ethical Hacking

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Grove - 4-Channel SPDT Relay
Seeed Studio Grove - 4-Channel SPDT Relay
×1
Axial Fan, 12 VDC
Axial Fan, 12 VDC
×2
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1

Software apps and online services

OpenPLC
Google Colab
https://www.wireguard.com/

Story

Read more

Schematics

Architecture

Code

Python script for ModbusTCP

Python
!pip install pyModbusTCP for Google Colab. If are working on local python install on virtual enviroment using: pip install pyModbusTCP
!pip install pyModbusTCP

from pyModbusTCP.client import ModbusClient

c = ModbusClient(host="34.29.119.21", port=502, unit_id=0, auto_open=True)
regs = c.read_holding_registers(0, 12)
print(regs)

c = ModbusClient(host="34.29.119.21", port=502, unit_id=0, auto_open=True)
coils_l = c.read_coils(811, 8)
print(coils_l)

c = ModbusClient(host="34.29.119.21", port=502, unit_id=0, auto_open=True)
coils_l = c.write_single_coil(811, False)
print(coils_l)

c = ModbusClient(host="34.29.119.21", port=502, unit_id=0, auto_open=True)
coils_l = c.write_single_coil(811, True)
print(coils_l)

c = ModbusClient(host="34.29.119.21", port=502, unit_id=0, auto_open=True)
for i in range(0,10):
  coils_l = c.read_coils(i, 8)
  print(coils_l)
  for j in range(0,7):
    if coils_l[j]:
      print(i)

Credits

Gabriel Coello
4 projects • 1 follower

Comments