Leveraging Generative AI for Critical Infrastructure Security: LLM Agents
by Mayank Nauni · January 24, 2025

As a PhD student & researcher I’ve spent the better part of my studies exploring ways to protect critical infrastructure systems. Today, I’d like to share my excitement about CyberBoT—a tool I’ve developed that marries good old-fashioned security scanning with the brains of Generative AI (namely GPT-4). If you work with, or are simply curious about, both IT and OT (Operational Technology) environments, I think you’ll find CyberBoT an interesting new approach to vulnerability assessment.
Why Critical Infrastructure Security Is So Challenging
Securing critical infrastructure is no walk in the park. We’re not just dealing with typical IT servers and desktops here; there are also industrial control systems (ICS) humming away in factories, power plants, and water treatment facilities. These ICS setups speak their own set of protocols, come with a bunch of specialized hardware, and often have strict uptime requirements. Basically, if something breaks in an ICS environment, it can cause serious real-world disruptions.
Historically, teams juggling IT and OT security have had to navigate two very different worlds. That’s where the idea of using an AI assistant came to me: Why not have a tool that not only knows how to handle traditional IT systems but also recognizes and cares about ICS protocols and constraints?
Introducing CyberBoT: AI Meets Security Scanning
So, how does CyberBoT actually work? Here’s a quick rundown:
- Intelligent Port Scanning
CyberBoT starts by probing typical ICS ports, think port 102 for Siemens S7 or port 502 for Modbus—using Nmap. This is your go-to step to see which industrial services might be active. - ICS Protocol Detection
If the scan picks up on protocols like Modbus, DNP3, BACnet, S7, or EtherNet/IP, CyberBoT can automatically switch to deeper, specialized Nmap scripts that are tailored to each protocol’s quirks. - GPT-4 Integration
Here’s where it gets really fun. Using LangChain, the scan results are fed into GPT-4. The AI will categorize findings into IT vs. OT concerns, look for possible lateral movement opportunities, and even reflect on past security incidents if they’re relevant. In short, it’s not just telling you “Port X is open;” it’s telling you why that might be a real problem. - Exploit Database Check
If you’ve ever rummaged through ExploitDB looking for known vulnerabilities, you’ll appreciate that CyberBoT does this step automatically. It queries the database for discovered services and highlights any exploits or proof-of-concepts that might be floating around.

For those who love poking around the code, you can find it all on my GitHub.
What’s Special & How to Stay Safe
1. Chain-of-Thought Prompting
I use a guided prompt that nudges GPT-4 to think step by step, but still keeps the final output clear and concise. This helps avoid “hallucinations” and ensures you get methodical reasoning.
2. Automatic CVE Extraction
Whenever the AI references a CVE, CyberBoT automatically flags and grabs that data. This makes cross-referencing a breeze.
3. ICS-Aware Scanning
Because ICS systems can be extra delicate, CyberBoT includes protocol-specific checks to make scanning safer. We definitely don’t want to accidentally cause a production line to halt or a substation to freak out.
4. Safety Controls
CyberBoT won’t just blindly run scripts without warning you first. It’ll let you know if something might be risky before you pull the trigger.
Using CyberBoT Wisely
- Always Have Authorization: Seriously, only scan systems you have explicit permission to test. That’s a legal and ethical must.
- Double-Check Findings: GPT-4 is awesome, but it can still miss things or misinterpret them. Treat the AI’s output as a starting point, and validate using official documentation.
- Remember OT Context: Industrial environments often have zero tolerance for downtime. Plan your scans accordingly; messing with ICS in production can have real-world consequences.
- Keep an Eye on Impact: Even a basic Nmap scan can cause some hiccups. Monitor the target systems closely while CyberBoT does its thing.
Under the Hood: How It All Comes Together
CyberBoT relies on:
- Streamlit for an easy-to-use interface
- Nmap (through
python-nmap) to handle scanning - LangChain to plug GPT-4 into the pipeline
- Custom ICS NSE scripts for protocol-specific scanning
- Regex for spotting CVEs in GPT-4’s output
- searchsploit for hooking into ExploitDB

What’s Next?
I see a whole lot of possibilities for future development:
- Deeper Protocol Analysis: Add more ICS protocol analyzers for even greater coverage.
- Attack Path Visualization: Maybe generate a graphical or more detailed representation of how attackers might leapfrog across systems.
- ICS-Focused Databases: Tie in specialized OT vulnerability databases to sharpen the AI’s recommendations.
- Machine Learning on ICS Data: Train domain-specific models that pick up on patterns unique to industrial environments.
- Compliance Reporting: Generate official-looking audit reports for your compliance team at the click of a button.
Wrapping Up
At the end of the day, CyberBoT is my attempt to bring a little AI magic to a very real-world problem: protecting the systems that keep our critical infrastructure running. It’s an open-source project, so feel free to give it a spin, contribute code, or just share any ideas you might have.
Final Word: AI tools can be a huge help, but they aren’t a silver bullet. Keep a holistic view, blend advanced scanning with expert judgment, watch out for system stability, and focus on the bigger security picture. Happy scanning, and stay safe out there!
Note: This tool is for research and authorised testing only. Always ensure proper authorisation before conducting any security assessments on critical infrastructure systems.


Thanks for sharing. Good insights