National Cyber Warfare Foundation (NCWF)

SCADA (ICS) Hacking and Security: Attacking the Modbus Protocol with ROfuzz


0 user ratings
2026-04-10 20:14:27
milo
Red Team (CNA)
The Modbus protocol can be targeted through fuzzing techniques. Using the R0fuzz framework, we demonstrate how malformed protocol traffic can potentially disrupt industrial communication.

Welcome back, aspiring cyberwarriors!





Industrial systems often appear quiet and predictable from the outside. Machines run day and night and gauges show steady values. Everything seems calm and orderly. But behind this surface lies a complex world of communication protocols coordinating every moving part of the operation. Motors start and stop, valves open and close, and sensors constantly report measurements that keep the process running smoothly. The digital conversations between industrial devices often reveal how an entire facility operates. If you can understand the language these systems speak, you can begin to understand the control mechanisms that drive real-world infrastructure.





One of the most common of these protocols is Modbus.





What is Modbus





Modbus has a long and interesting history. It was originally developed in 1979 by Modicon, a company that specialized in programmable logic controllers, or PLCs. The goal of the protocol was to allow industrial devices to communicate with each other in a predictable and reliable way. At the time, industrial networks were small, isolated, and rarely exposed to external threats. Engineers prioritized stability and compatibility rather than authentication or encryption. The result was a protocol that was simple and reliable. Decades later, that same simplicity is the reason Modbus remains everywhere in the industrial world. Many factories still rely on equipment that was installed years or even decades ago. If those machines still function correctly, replacing them can cost millions of dollars. As a result, legacy protocols remain deeply embedded in operational technology environments.





From an offensive security perspective, this creates a fascinating situation. Critical infrastructure systems are often running protocols designed in an era when hostile networks were not considered. Devices exchange commands and sensor data freely, assuming that every participant in the network is trusted.





Modbus can be found connecting PLC input and output modules, remote terminal units, environmental sensors, power meters, and small industrial control systems. In many smaller installations it acts as the primary communication backbone of the entire automation environment. In practical terms, this means that anyone capable of interacting with Modbus traffic can often observe and influence real industrial processes.





modbus different implementations
Source: Accuenergy








Modbus runs through industrial environments in far more places than most people realize. It does not just sit inside a factory production line. Heating and cooling systems often rely on it to coordinate temperature controls. Water treatment plants use it to keep track of pumps and valves moving water through the system. Electricity meters report power consumption through Modbus messages, and environmental sensors continuously send temperature, pressure, or humidity readings the same way. Without much attention, this protocol ends up acting like part of the nervous system of modern infrastructure, carrying small signals between the machines that keep the physical world running.





In one of our previous articles, Master OTW demonstrated how Modbus values can be manipulated using the modbusclient module inside Metasploit. That example showed how an attacker could interact directly with a PLC and modify values stored inside Modbus registers. During that demonstration it was also shown that the PLC’s ladder logic could sometimes be downloaded. Ladder logic is essentially the program running inside the controller. It defines how sensor inputs influence outputs that control motors, pumps, and other equipment. From an offensive perspective, obtaining this ladder logic provides a blueprint of the entire industrial process. Once an attacker understands the logic running inside the controller, they can determine which registers influence critical operations and which commands could disrupt the process. In a worst-case scenario, an attacker might modify values in ways that cause equipment to behave incorrectly or push a system outside its safe operating limits. History has already shown us how powerful this type of attack can be. The famous Stuxnet malware analyzed PLC logic inside Iranian uranium enrichment facilities before injecting malicious ladder logic that altered the behavior of centrifuges.





Today we will explore another attack technique. Instead of modifying control values or injecting logic, we will examine how attackers can disrupt industrial communication channels themselves by performing denial-of-service attacks against Modbus services.





What is R0fuzz





R0fuzz is a modern tool designed to identify weaknesses in industrial network protocols. Instead of sending only normal protocol traffic, the tool intentionally generates malformed or unusual packets in order to observe how industrial services respond. If the implementation contains programming mistakes or unsafe assumptions, these unexpected inputs can cause crashes or unstable behavior.





The tool focuses on hardware-oriented protocols commonly used in industrial environments, including Modbus, OPC UA, and DNP3. One of the most interesting aspects of R0fuzz is that it combines several fuzzing strategies within a single framework. R0fuzz also includes experimental research exploring artificial intelligence techniques to generate new protocol traffic. By training models such as variational autoencoders or large language models on captured industrial communication patterns, the system can synthesize new message sequences that resemble realistic traffic. This approach attempts to expand fuzzing coverage beyond what simple mutation can achieve. Although the framework is designed to support multiple industrial protocols, the current version focuses primarily on Modbus.





Setting Up the Environment





Before launching an attack, we first need to prepare a controlled testing environment where the fuzzing tool and the target service can interact safely.





Fortunately, the installation process for R0fuzz is straightforward.





kali > git clone https://github.com/br34dcrumb/r0fuzz.git
kali > cd r0fuzz
kali > python3 -m venv .venv
kali > source .venv/bin/activate
kali > pip install -r requirements.txt




The repository conveniently includes a small Modbus server implementation that can be used as a testing target.





Attacking Modbus





With the environment prepared, we can begin experimenting with how R0fuzz interacts with a Modbus service.





r0fuzz fuzzing tool help menu








When examining the help menu of the tool, you will notice that it supports several fuzzing strategies. For demonstration purposes we will focus on three of them: mutation-based fuzzing, generation-based fuzzing, and a simple brute-force mode often referred to as a “dumb” attack.





Mutation-Based Testing





The first technique involves mutating captured Modbus traffic in order to trigger unexpected behavior from the server. Instead of inventing packets from scratch, the tool begins with legitimate communication captured from real environments and gradually distorts those packets.





To observe the process clearly, we split the terminal using Tmux so the Modbus server runs in one pane while the fuzzing tool runs in the other.





The server is started with the following command:





kali > python3 run_server.py –server server/modbus/server –library server/modbus/libmodbus.so.5




The fuzzing tool is then launched with:





kali > python3 r0fuzz.py -t modbus -i 127.0.0.1 -p 1502 mutate -s sample/modbus-pcap/modbus.pcap




setting up the environment for the tests








On the right side of the screen the Modbus server is running. It is essentially a wrapper that launches the real server binary while linking against the libmodbus.so.5 library. The service listens locally on port 1502, while production Modbus deployments typically operate on port 502.





On the left side the fuzzer begins operating. It loads a seed file containing captured Modbus traffic that represents legitimate communication between a client and server.





mutation based attack against modbus








Using the Radamsa mutation engine, the tool begins modifying these packets. Each mutated packet is then transmitted to the server. The goal is to keep sending unusual inputs until something breaks. 





mutation based attack against modbus








As the fuzzing process runs, the server begins receiving malformed requests. Eventually error messages appear as the server processes invalid function codes or references registers that do not exist. These behaviors indicate that the fuzzer is successfully pushing the server outside its expected operating conditions. If a vulnerability exists in the implementation, the malformed traffic may eventually trigger a crash.





modbus service crash








Generation-Based Testing





The second fuzzing strategy follows a more structured approach. Instead of mutating captured packets, the tool generates new protocol messages directly from the Modbus specification.





This mode can be launched with:





kali > python3 r0fuzz.py -t modbus -i 127.0.0.1 -p 1502 generate




generation mode attacks against modbus








When operating in generation mode, the fuzzing environment becomes more visual. A web interface becomes available on port 26000, allowing you to monitor the progress.





web app for the generation based attacks against modbus








Because packets are constructed from protocol grammar rather than random mutation, this method can explore deeper logical states within the protocol.





The “Dumb” Attack Mode





The final method included in R0fuzz is a simple brute-force approach sometimes referred to as the dumb mode. Unlike the other strategies, this mode does not rely on captured traffic or protocol structure. Instead it repeatedly sends variations of raw data in loops. Many testers ignore this technique because mutation and generation methods usually provide better coverage.





This mode can be launched with:





kali > python3 r0fuzz.py -t modbus -i 127.0.0.1 -p 1502 dumb




brute force mode attacks against modbus








However, brute-force approaches can still expose simple boundary errors or input validation failures.





What Happens After a Crash





When fuzzing successfully triggers a failure, the impact depends heavily on the design of the target device. In many modern industrial environments, communication services are separated from the core control logic of the PLC. If the Modbus communication service crashes, the underlying control program may continue running normally. In that scenario the industrial process continues operating, but operators temporarily lose monitoring and remote control capabilities.





In smaller or older devices, the communication layer and control logic may be tightly integrated. When the Modbus service fails, the entire controller may freeze or reboot. Even a short interruption can cause visible effects within the facility. SCADA dashboards may suddenly display connection errors and monitoring systems may trigger alarms as communication with the device disappears.





modbus crash behavior results








Capturing the packet that caused the crash is important. It reveals the vulnerability responsible for the failure and allows to reproduce the issue during further testing.





Summary





Industrial control systems operate many of the processes that modern society depends on. These environments were designed for reliability and longevity rather than adversarial security, and many of their protocols still reflect that design philosophy. This creates an opportunity to study how industrial devices behave when pushed outside their expected operating conditions. 





Understanding these vulnerabilities is an important step toward building more resilient infrastructure. For those interested in going deeper, we offer dedicated training in Advanced SCADA Hacking and Security.



Source: HackersArise
Source Link: https://hackers-arise.com/scada-ics-hacking-and-security-attacking-the-modbus-protocol-with-rofuzz/


Comments
new comment
Nobody has commented yet. Will you be the first?
 
Forum
Red Team (CNA)



Copyright 2012 through 2026 - National Cyber Warfare Foundation - All rights reserved worldwide.