Chatbot and similar AI Tools
Chatbots and other AI tools operate in a certain set of rules (specific domains). If we take the example of an automobile dealership, the chatbot immediately gets launched when a user browses the website. Asks for what vechicle models we are looking for and gives some high level answers and asks for email address etc. to go further. Then it is a matter of visiting the dealership, fill up online form etc. or in some cases bring a car for at-home sale.
 
Conventional Process - To Update Vulnerable Port In Systems
In business, the cybersecurity team wants to fix a vulnerability such as a port that can be exposed. The cyber security team identifies the port and sends out an analysis of the vulnerability. Many teams meet and access the business impact, criticality, downtimes to fix it, costs involved, and so on. This is mostly human interaction between teams with limited use of AI. Company wide broadcast emails are sent and lots of human interactions, planning, downtimes, accessing business hierarchy and all aspects necessary to revise the port and step-by-step enhance all the systems to new port. With human activities, there is a high chance of missed step or critical system (or systems) accidentally excluded from newer setup.
 
Event Based Triggers
In databases and other tools, there has been triggers that perform task B upon completion of task A or on occurance of a set of predesignated processes. They are used for routine data procesing, time sensitive specific tasks etc. and aren't designed to perform RCA and take further steps autonomously.
 
Agentic AI - To Update Vulnerable Port In Systems
When AI is setup with agents, it can perform many autonomous actions and reduce human interactions. Below is a high-level steps an agentic AI can be setup to autonomously update the systems and avoid human errors.
  • AI agents analyze all systems that use the current port setup
  • AI agents create a hierarchy of systems, the configuration and dependencies
  • AI agents perform impact anaylsis of all systems along with risk assessment
  • AI agents create a plan of action and inform all the system/product owners (plan of action, dates of update, hierarchy etc.)
  • AI agents send out high-level assessment and dates of operational actions to update the port and system configuration
  • AI agents will test the upgrades in lower environments ( development, test, QA, etc.) first
  • Upon successful test and meeting all acceptance criteria, production will be updated in specific order. Humans may just overview the agentic AI in action
#----------------------------------------------------------------------------
# Sample high level basic Agentic AI code
#----------------------------------------------------------------------------
# Reference python code to trace vulnerable port 8088 and replace with 8080
#----------------------------------------------------------------------------

import os
import sys
import time
import subprocess
import psutil

class PortMigrationAgent:
    def __init__(self, target_port=8088, secure_port=8080):
        self.target_port = target_port
        self.secure_port = secure_port
        self.process_info = None

    def log(self, message):
        print(f"[*] [Agent] {message}")

    def run_remediation_loop(self):
        """Main agentic loop: Sense, Plan, Act, Verify."""
        self.log(self"Starting audit for vulnerable port {self.target_port}...")
        
        # 1. SENSE: Scan for the target port
        if not self._discover_vulnerable_port():
            self.log(f"Target port {self.target_port} is not active. No vulnerability found.")
            return True

        # 2. PLAN: Evaluate what process is running
        self._analyze_process()

        # 3. ACT: Terminate the vulnerable instance
        if self._mitigate_vulnerable_port():
            # 4. VERIFY: Ensure migration or alternative port availability
            return self._verify_and_redeploy()
        
        return False

    def _discover_vulnerable_port(self):
        """Scans active network connections to find the target port."""
        for conn in psutil.net_connections(kind='inet'):
            if conn.laddr.port == self.target_port:
                try:
                    self.process_info = psutil.Process(conn.pid)
                    return True
                except psutil.NoSuchProcess:
                    continue
        return False

    def _analyze_process(self):
        """Gathers intelligence on the process occupying the port."""
        if self.process_info:
            self.log(f"Vulnerability identified!")
            self.log(f"  - Process Name: {self.process_info.name()}")
            self.log(f"  - PID: {self.process_info.pid}")
            self.log(f"  - Command Line: {' '.join(self.process_info.cmdline())}")

    def _mitigate_vulnerable_port(self):
        """Kills the target process to free up the vulnerable configuration."""
        if not self.process_info:
            return False
        
        try:
            self.log(f"Terminating vulnerable PID {self.process_info.pid}...")
            self.process_info.terminate()
            
            # Wait up to 5 seconds for process to exit cleanly
            gone, alive = psutil.wait_procs([self.process_info], timeout=5)
            if alive:
                self.log("Process ignored SIGTERM. Escalating to SIGKILL...")
                for p in alive:
                    p.kill()
            
            self.log(f"Port {self.target_port} successfully cleared.")
            return True
        except Exception as e:
            self.log(f"Failed to mitigate process: {e}")
            return False

    def _verify_and_redeploy(self):
        """Checks if port 8080 is free, then initiates the new service."""
        # Check if 8080 is already in use
        for conn in psutil.net_connections(kind='inet'):
            if conn.laddr.port == self.secure_port:
                self.log(f"[Error] Secure port {self.secure_port} is already blocked.")
                return False

        self.log(f"Port {self.secure_port} is clear. Simulating service redeployment...")
        
        # Agent execution block: Replace this with your actual application restart command
        # Example: subprocess.Popen(["python3", "app.py", "--port", str(self.secure_port)])
        time.sleep(1) 
        
        self.log(f"[Success] Remediation complete. Traffic successfully rerouted to {self.secure_port}.")
        return True

if __name__ == "__main__":
    # Ensure script has adequate permissions to query/kill system processes
    if os.getuid() != 0 if hasattr(os, 'getuid') else False:
        print("[Warning] This agent may require administrative/sudo privileges to read all PIDs.")
        
    agent = PortMigrationAgent(target_port=8088, secure_port=8080)
    agent.run_remediation_loop()

#----------------------------------------------------------------------------
 
Agentic AI for autonomous data management
In another scenario, data load can be autonomously processed from system to system. When deadlines/SLA are about to be breached, systems are configured to send email alerts to respective data owners/stewards. With agentic AI, the systems can be greatly improved such that breaches never occur, unless there is a major natural diaster that is beyond agentic AI control. There needs to be guardrails which determine to what extent the agentic AI can operate and when human intervention is required.
 


Table of Content



Revised Date: April 16th, 2026