waqasbm's picture
Update app.py
ec51e09 verified
import streamlit as st
import pandas as pd
from fpdf import FPDF
from groq import Groq
# Initialize GROQ Client
client = Groq(api_key=st.secrets["wbm3"])
# ICS Cybersecurity Areas and Prompts
cyber_areas = {
"ASSET MANAGEMENT": "Generate an asset inventory template for an ICS network in a [industry] facility, including fields like asset type, IP, MAC address, firmware version, and vendor.",
"VULNERABILITY MANAGEMENT": "Design a practical patch and vulnerability management workflow for a [industry] plant that includes OT risk-based prioritization and the Now, Next, Never approach.",
"SECURE NETWORK ARCHITECTURE": "Draw a high-level secure network architecture diagram for an [industry] facility, including IT, DMZ, and OT zones with firewalls, unidirectional gateways and data diodes.",
"BACKUP & RECOVERY": "Write a backup and recovery strategy for PLCs and HMIs in a large [industry] plant, including storage types, validation processes and testing procedures.",
"INCIDENT RESPONSE PLANNING": "Write a complete OT/ICS-specific incident response plan for a mid-sized [industry] plant, including roles, escalation paths, and communication protocols.",
"SECURITY AWARENESS TRAINING": "Develop a 1-hour awareness training outline for control engineers on how to avoid common OT cybersecurity mistakes. Include real world examples from [industry].",
"COMPLIANCE & GOVERNANCE": "Break down ISA/IEC 62443-3-3 requirements in plain language and provide an example implementation for a [industry] control room; use only information in the public domain.",
"TABLETOP EXERCISES": "Generate a tabletop exercise for an OT cybersecurity incident in a [industry] plant based on a realistic example which has occurred at another facility in the same industry.",
"RISK ASSESSMENT": "Create a list of the top 10 cybersecurity risks for a [industry] plant using SCADA systems, including likelihood and impact.",
"THREAT INTEL": "Summarize the TTPs (Tactics, Techniques, and Procedures) used by attackers in past ICS/OT-related attacks, and map them to the MITRE ATT&CK for ICS matrix for [industry].",
"NETWORK SECURITY MONITORING": "List the top 10 log sources in an OT network that would help detect early signs of a cyber attack in [industry]. Provide a list of tips & tricks on implementation and configuration.",
"SECURE REMOTE ACCESS": "What are the recommended security controls for enabling vendor remote access to a PLC in a [industry] facility? List challenges and fixes with SRA seen at other similar facilities.",
"THREAT HUNTING": "Write example detection rules for an OT network that alert on suspicious Modbus TCP function codes such as write coil or force listen-only mode. Provide example responses.",
"HONEYPOTS FOR INCIDENT DETECTION": "Help me design a Modbus honeypot for an OT lab that logs all activity, maps IPs to geolocation, and mimics a real-world PLC interface.",
"PHYSICAL SECURITY": "List the top physical security controls that should be implemented to protect critical OT systems in a [industry] facility. Include real world examples that have occurred.",
"AWARENESS FOR EXECUTIVES": "Write a 5-slide executive briefing explaining why investing in ICS cybersecurity is critical to operational continuity and safety in [industry].",
"METRICS": "Generate a list of meaningful KPIs and metrics to measure the maturity of an ICS/OT cybersecurity program over time in the [industry] industry.",
"THREAT MODELING": "Perform a threat model using various methodologies for a [industry] control system connected via wireless telemetry.",
"CAREER DEVELOPMENT": "What skills, certifications, and hands-on labs should someone focus on during their first year trying to break into ICS/OT cybersecurity?",
"PENETRATION TESTING": "What are the top OT-specific tools and techniques to enumerate PLCs, HMIs, and RTUs safely within an ICS/OT network?"
}
# Streamlit UI
st.set_page_config(page_title="OT ICS Cybersecurity Resource Generator", layout="wide")
st.title("OT ICS Cybersecurity Resource Generator")
industry = st.text_input("Enter Industry", placeholder="e.g., Oil & Gas")
selected_area = st.selectbox("Select Cybersecurity Area", list(cyber_areas.keys()))
generate = st.button("Generate Resource")
if generate and industry and selected_area:
with st.spinner("Generating response..."):
prompt = cyber_areas[selected_area].replace("[industry]", industry)
try:
response = client.chat.completions.create(
model="llama3-70b-8192",
messages=[{"role": "user", "content": prompt}]
)
result = response.choices[0].message.content
st.markdown("### Generated Output")
st.text_area("Response", result, height=300)
# Download options
def create_pdf(text):
pdf = FPDF()
pdf.add_page()
pdf.set_auto_page_break(auto=True, margin=15)
pdf.set_font("Arial", size=12)
for line in text.split("\n"):
pdf.multi_cell(0, 10, line)
pdf_path = "/tmp/generated.pdf"
pdf.output(pdf_path)
return pdf_path
def create_excel(text):
df = pd.DataFrame([text], columns=["Content"])
excel_path = "/tmp/generated.xlsx"
df.to_excel(excel_path, index=False)
return excel_path
col1, col2 = st.columns(2)
with col1:
if st.download_button("πŸ“„ Download PDF", data=open(create_pdf(result), "rb"), file_name="cyber_output.pdf"):
st.success("PDF downloaded!")
with col2:
if st.download_button("πŸ“Š Download Excel", data=open(create_excel(result), "rb"), file_name="cyber_output.xlsx"):
st.success("Excel downloaded!")
except Exception as e:
st.error(f"Error: {e}")
# Footer
st.markdown("---")
st.caption("Built with ❀️ for ICSS & Controls Professionals | Created by waqasbm")