
#README for Lightweight Cyber Risk Management Framework

#This README accompanies a Python-based lightweight cyber risk management framework, designed for Western Balkan Higher Education Institutions (HEIs). The framework focuses on key areas such as risk assessment, mitigation, monitoring, education, and documentation. Below are the algorithm and Python code for each step. 

#Prerequisites
#Python 3.x
#Basic understanding of cybersecurity concepts
#Familiarity with the IT infrastructure of HEIs

#Usage
#The framework is divided into five steps, each with corresponding Python code templates:

#Step 1: Risk Assessment
#Gather information on the HEI's IT infrastructure, data assets, and potential threats.
#Use the provided Python script to evaluate vulnerabilities, asset values, and calculate the overall risk score.

#Step 2: Risk Mitigation
#Identify and prioritize controls using the provided Python code.
#Implement the recommended cybersecurity controls.

#Step 3: Monitoring and Incident Response
#Setting up continuous monitoring and developing an incident response plan.

#Step 4: Education and Training
#Execute the Python script for organizing cybersecurity training sessions.

#Step 5: Documentation and Reporting
#Maintain records and generate reports using the provided Python code.



#The following algorithm provides a conceptual outline, along with Python code templates that serve as an important step for Designing a lightweight cyber risk management framework for Western Balkan Higher Education Institutions.

#Algorithm for Lightweight Cyber Risk Management Framework

#Risk Assessment
#Collect data on IT infrastructure, data assets, and threats.
#Evaluate vulnerabilities, asset values, and threat probabilities.
#Compute risk scores for each asset.

#Risk Mitigation
#Select controls to diminish vulnerabilities and mitigate risks.
#Prioritize controls based on risk scores and resources.
#Implement cybersecurity best practices.

#Monitoring and Incident Response
#Set up ongoing monitoring of IT systems.
#Develop an incident response strategy.
#Regularly perform security assessments and vulnerability scans.

#Education and Training
#Conduct cybersecurity awareness and training for staff and students.
#Foster a cybersecurity culture.
#Encourage reporting of security incidents.

#Documentation and Reporting
#Keep records of risk assessments, controls, and incident responses.
#Produce regular cybersecurity reports.
#Communicate findings to stakeholders and management.






#Python Code Lightweight Cyber Risk Management Framework

#Step 1: Risk Assessment
def assess_risk(assets, vulnerabilities, threats):
    risk_scores = {}
    for asset in assets:
        asset_value = assets[asset]
        for vulnerability in vulnerabilities:
            for threat in threats:
                likelihood = calculate_likelihood(vulnerability, threat)
                risk_score = asset_value * likelihood
                risk_scores[(asset, vulnerability, threat)] = risk_score
    return risk_scores

assets = {"Server": 100, "Database": 80}
vulnerabilities = ["SQL Injection", "Cross-Site Scripting"]
threats = ["External Attack", "Insider Threat"]

risk_scores = assess_risk(assets, vulnerabilities, threats)
print(risk_scores)


#Step 2: Risk Mitigation
def implement_controls(risk_scores, available_resources):
    recommended_controls = {}
    for key, risk_score in risk_scores.items():
        asset, vulnerability, threat = key
        if risk_score > threshold and available_resources > control_cost:
            recommended_controls[key] = "Implement control XYZ"
    return recommended_controls

threshold = 50
control_cost = 20

recommended_controls = implement_controls(risk_scores, available_resources)
print(recommended_controls)


#Step 3: Monitoring and Incident Response
def continuous_monitoring():
    pass  # Implement monitoring mechanisms

def incident_response():
    pass  # Implement incident response plan

continuous_monitoring()
incident_response()


#Step 4: Education and Training
def cybersecurity_training():
    pass  # Implement training programs

cybersecurity_training()


#Step 5: Documentation and Reporting
def maintain_records():
    pass  # Maintain cybersecurity records

def generate_reports():
    pass  # Generate regular reports

maintain_records()
generate_reports()


#Step 1: Risk Assessment (example)
def calculate_likelihood(vulnerability, threat):
    # Simplified likelihood calculation (for demonstration)
    vulnerability_factors = {"SQL Injection": 0.7, "Cross-Site Scripting": 0.5}
    threat_factors = {"External Attack": 0.8, "Insider Threat": 0.6}

    return vulnerability_factors.get(vulnerability, 0) * threat_factors.get(threat, 0)

def assess_risk(assets, vulnerabilities, threats):
    risk_scores = {}
    for asset in assets:
        asset_value = assets[asset]
        for vulnerability in vulnerabilities:
            for threat in threats:
                likelihood = calculate_likelihood(vulnerability, threat)
                risk_score = asset_value * likelihood
                risk_scores[(asset, vulnerability, threat)] = risk_score
    return risk_scores

# Define assets, vulnerabilities, and threats
assets = {"Server": 100, "Database": 80}
vulnerabilities = ["SQL Injection", "Cross-Site Scripting"]
threats = ["External Attack", "Insider Threat"]

# Calculate and print risk scores
risk_scores = assess_risk(assets, vulnerabilities, threats)
risk_scores

Result:
{('Server', 'SQL Injection', 'External Attack'): 55.99999999999999,
 ('Server', 'SQL Injection', 'Insider Threat'): 42.0,
 ('Server', 'Cross-Site Scripting', 'External Attack'): 40.0,
 ('Server', 'Cross-Site Scripting', 'Insider Threat'): 30.0,
 ('Database', 'SQL Injection', 'External Attack'): 44.8,
 ('Database', 'SQL Injection', 'Insider Threat'): 33.6,
 ('Database', 'Cross-Site Scripting', 'External Attack'): 32.0,
 ('Database', 'Cross-Site Scripting', 'Insider Threat'): 24.0}


#1. Server
#   - SQL Injection, External Attack: 56.0
#   - SQL Injection, Insider Threat: 42.0
#   - Cross-Site Scripting, External Attack: 40.0
#   - Cross-Site Scripting, Insider Threat: 30.0

#2. Database
#   - SQL Injection, External Attack: 44.8
#   - SQL Injection, Insider Threat: 33.6
#   - Cross-Site Scripting, External Attack: 32.0
#   - Cross-Site Scripting, Insider Threat: 24.0

#These scores represent the calculated risks for each combination of asset, vulnerability, and threat based on their respective values and likelihoods.


#Step 2: Risk Mitigation (example)
risk_scores:
('Server1', 'SQL Injection', 'External Hacker'): 60
('Server2', 'Phishing Attack', 'Internal Threat'): 45
('Server3', 'DDoS', 'External Hacker'): 70
available_resources: 30

# Define the risk scores and available resources
risk_scores = {
    ('Server1', 'SQL Injection', 'External Hacker'): 60,
    ('Server2', 'Phishing Attack', 'Internal Threat'): 45,
    ('Server3', 'DDoS', 'External Hacker'): 70
}
available_resources = 30

# Function to implement controls based on risk scores and available resources
def implement_controls(risk_scores, available_resources):
    recommended_controls = {}
    threshold = 50
    control_cost = 20
    for key, risk_score in risk_scores.items():
        asset, vulnerability, threat = key
        if risk_score > threshold and available_resources > control_cost:
            recommended_controls[(asset, vulnerability, threat)] = "Implement control XYZ"
    return recommended_controls

# Get the recommended controls
recommended_controls = implement_controls(risk_scores, available_resources)

# Print the recommended controls
print(recommended_controls)

Results
{
    ('Server1', 'SQL Injection', 'External Hacker'): 'Implement control XYZ',
    ('Server3', 'DDoS', 'External Hacker'): 'Implement control XYZ'
}

#This output indicates that for 'Server1' with the 'SQL Injection' vulnerability from an 'External Hacker' and 'Server3' with the 'DDoS' threat from an 'External Hacker', the function recommends implementing control XYZ, as their risk scores are above the threshold and there are enough resources to cover the control cost.


#Step 3: Monitoring and Incident Response (example)

#In a HEI's IT department, continuous_monitoring() runs 24/7, using software to track network traffic and alert for any anomalies. The monitoring system detects unusual outbound traffic indicating a possible data breach. Immediately after this detection, the incident_response() function is invoked. The IT team follows a predefined protocol to contain the breach, assess the damage, and recover compromised systems. They also work on identifying the cause and strengthening defenses to prevent similar incidents process.

continuous_monitoring() Function:
#This function represents the ongoing process of monitoring an HEI's network for any unusual activity or potential threats. It could involve the use of various tools and techniques to continuously scan, analyze, and evaluate the security posture of the network.

incident_response() Function:
#This function is triggered when a security incident is detected. It encompasses the steps and procedures taken to address and manage the aftermath of a security breach or attack. This could include identifying the extent of the breach, containing the threat, eradicating the cause, recovering systems, and making necessary improvements to prevent future incidents.

#Step 5: Documentation and Reporting
def maintain_records(HEI_data):
    > Update the HEIs records with new data.
    # Code to insert or update HEIs data in a database.
    print("Records updated with new HEIs data.")

def generate_reports():
    > Generate HEIs reports based on the updated records.
    # Code to process the data and generate reports.
    print("HEIs reports generated.")

# Example HEIs data
new_HEIs_data = {
    'date': '2023-11-21',
    'total_HEIs': 10000,
    'number_of_transactions': 50
}

# Updating records with new HEIs data
maintain_records(new_HEIs_data)

# Generating reports after updating records
generate_reports()

#The "maintain_records" function is modified to accept HEIs data as an argument, and the "generate_reports" function processes the updated data to generate reports. 
