shadeebhossain commited on
Commit
f582037
·
verified ·
1 Parent(s): 32014a3

Upload 3 files

Browse files
Files changed (3) hide show
  1. Graph_2_Paper2.m +88 -0
  2. Graph_4_Paper_2.m +118 -0
  3. Graph_5_paper_2.m +83 -0
Graph_2_Paper2.m ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % Graph2 Paper2
2
+ clear; clc; close all;
3
+
4
+ % Input signal
5
+ N = 10000;
6
+ gamma = 4;
7
+
8
+ LEF_min = 0.5;
9
+ LEF_mode = 0.8;
10
+ LEF_max = 1.2;
11
+
12
+ PLM_min = 80;
13
+ PLM_mode = 94;
14
+ PLM_max = 120;
15
+
16
+ SLM_min = 5;
17
+ SLM_mode = 15;
18
+ SLM_max = 40;
19
+
20
+ %% 3. Using PERT Beta Distributions
21
+ % Helper function for PERT sampling
22
+ draw_pert = @(a, b, c, n) pert_sample(a, b, c, gamma, n);
23
+
24
+ % Having the max, min and mode
25
+ LEF_samples = draw_pert(LEF_min, LEF_mode, LEF_max, N);
26
+ PLM_samples = draw_pert(PLM_min, PLM_mode, PLM_max, N);
27
+ SLM_samples = draw_pert(SLM_min, SLM_mode, SLM_max, N);
28
+
29
+
30
+ LM_samples = PLM_samples + SLM_samples;
31
+
32
+ ALE_samples = LEF_samples .* LM_samples;
33
+
34
+ %% 4. Statistical Analysis
35
+ mean_ALE = mean(ALE_samples);
36
+ std_ALE = std(ALE_samples);
37
+ p95_ALE = prctile(ALE_samples, 95); % 95th Percentile (Value at Risk)
38
+ p50_ALE = median(ALE_samples);
39
+
40
+ fprintf('================ Monte Carlo FAIR Results ================\n');
41
+ fprintf('Mean Expected Annual Loss (ALE): $%6.2f Million\n', mean_ALE);
42
+ fprintf('Median (50th Percentile) Loss: $%6.2f Million\n', p50_ALE);
43
+ fprintf('95th Percentile (VaR / Max Risk): $%6.2f Million\n', p95_ALE);
44
+ fprintf('Standard Deviation: $%6.2f Million\n', std_ALE);
45
+ fprintf('==========================================================\n');
46
+
47
+ %% 5. Visualization
48
+ figure('Color', [1 1 1]);
49
+
50
+
51
+ histogram(ALE_samples, 50, 'Normalization', 'pdf', 'FaceColor', [0.2 0.4 0.6], 'EdgeColor', 'none');
52
+ hold on;
53
+
54
+ % Kernel Density Estimation
55
+ [f, x] = ksdensity(ALE_samples);
56
+ plot(x, f, 'r-', 'LineWidth', 2.5);
57
+
58
+
59
+ xline(mean_ALE, '--k', sprintf(' Mean: $%.1fM', mean_ALE), 'LineWidth', 2, 'LabelOrientation', 'aligned');
60
+ xline(p95_ALE, '--m', sprintf(' 95th Pct: $%.1fM', p95_ALE), 'LineWidth', 2, 'LabelOrientation', 'aligned');
61
+
62
+ title('MGM Resorts Cyber Event: FAIR Monte Carlo Loss Distribution (N = 10,000)');
63
+ xlabel('Annual Loss Exposure (ALE) [$ Millions USD]');
64
+ ylabel('Probability Density');
65
+ grid on;
66
+ legend('Simulated Iterations', 'Probability Density Function (PDF)', 'Location', 'northeast');
67
+
68
+
69
+
70
+ %%% These are from equation -5,6, and 7
71
+
72
+ function samples = pert_sample(a, b, c, g, n)
73
+ % a: Min, b: Mode, c: Max, g: Shape Parameter (default 4)
74
+ mu = (a + g*b + c) / (g + 2);
75
+
76
+ % Beta parameters (alpha and beta)
77
+ if mu == b
78
+ alpha = g/2 + 1;
79
+ beta_param = g/2 + 1;
80
+ else
81
+ alpha = ((mu - a) * (2*b - a - c)) / ((b - mu) * (c - a));
82
+ beta_param = alpha * (c - mu) / (mu - a);
83
+ end
84
+
85
+ % Beta distributed random variables and scale to [a, c]
86
+ r = betarnd(alpha, beta_param, [n, 1]);
87
+ samples = a + r .* (c - a);
88
+ end
Graph_4_Paper_2.m ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %%% Paper-2-Graph_4
2
+ clear; clc; close all;
3
+
4
+ %Input Parameter
5
+ T = 100;
6
+ dt = 1;
7
+ time = 0:dt:T;
8
+ N = length(time);
9
+
10
+
11
+ lambda_0 = 50; % Noise EPS
12
+ lambda_A = 30;
13
+ lambda_1 = lambda_0 + lambda_A; % Elevated EPS
14
+
15
+
16
+ P_d = 0.90; % True Positive Rate / Sensitivity
17
+ P_fp = 0.03; % False Positive Rate / Noise Floor
18
+
19
+ % Stackelberg Game Parameters (These are estimate values)
20
+ C_D = 15; % Operational Containment cost
21
+ P_E = 0.739; % CVSS v3.1 Exploitability Probability (This was calculated using equation 1 and 2
22
+ E_L_FAIR = 92.58; % Expected FAIR Loss
23
+
24
+ % Calculate mu^*
25
+ mu_star = C_D / (P_E * E_L_FAIR); % From equation 17
26
+
27
+
28
+ attack_start = 35;
29
+ attack_end = 75;
30
+
31
+
32
+ pi_0 = 0.02;
33
+ mu = zeros(1, N);
34
+ mu(1) = pi_0;
35
+
36
+ EPS_observed = zeros(1, N);
37
+ action_triggered = zeros(1, N);
38
+
39
+ rng(42);
40
+
41
+ for t = 1:N-1
42
+ currentTime = time(t);
43
+
44
+ % These if-else is to determine when to use what value of lambda
45
+ if currentTime >= attack_start && currentTime <= attack_end
46
+ current_lambda = lambda_1; % Active Attack State (\theta_1)
47
+ else
48
+ current_lambda = lambda_0; % Normal Noise State (\theta_0)
49
+ end
50
+
51
+ % Generate Poisson log event with matlab built in
52
+ EPS_observed(t) = poissrnd(current_lambda * dt);
53
+
54
+ % Evaluate z_t with EPS
55
+ if EPS_observed(t) > poissinv(0.95, lambda_0 * dt)
56
+ z_t = 1; % Alert Fired
57
+ else
58
+ z_t = 0; % Quiet State
59
+ end
60
+
61
+ % If_else for updating Step
62
+ if z_t == 1
63
+ num = P_d * mu(t);
64
+ den = (P_d * mu(t)) + (P_fp * (1 - mu(t)));
65
+ else
66
+ num = (1 - P_d) * mu(t);
67
+ den = ((1 - P_d) * mu(t)) + ((1 - P_fp) * (1 - mu(t)));
68
+ end
69
+
70
+
71
+ mu(t+1) = num / den;
72
+
73
+
74
+ if mu(t+1) >= mu_star
75
+ action_triggered(t+1) = 1; % Trigger Automated Containment
76
+ else
77
+ action_triggered(t+1) = 0; % Keep Passive Operational Posture
78
+ end
79
+ end
80
+ EPS_observed(N) = poissrnd(lambda_0 * dt);
81
+
82
+
83
+ figure('Color', [1 1 1], 'Position', [100 100 800 600]);
84
+
85
+
86
+ subplot(2,1,1);
87
+ bar(time, EPS_observed, 'FaceColor', [0.4 0.6 0.8], 'EdgeColor', 'none');
88
+ hold on;
89
+ yline(lambda_0, '--k', 'Baseline Noise (\lambda_0 = 50 EPS)', 'LineWidth', 1.5, 'LabelHorizontalAlignment', 'left');
90
+ yline(lambda_1, '--r', 'Attack Signature (\lambda_1 = 80 EPS)', 'LineWidth', 1.5, 'LabelHorizontalAlignment', 'left');
91
+ xregion(attack_start, attack_end, 'FaceColor', [1 0.8 0.8], 'FaceAlpha', 0.4);
92
+ ylabel('Ingested Telemetry [EPS]');
93
+ title('A. Dynamic SIEM Ingestion Stream (Events Per Second)');
94
+ grid on;
95
+ legend('Observed EPS', 'Location', 'northeast');
96
+
97
+
98
+ subplot(2,1,2);
99
+ plot(time, mu, 'b-', 'LineWidth', 2.5);
100
+ hold on;
101
+ xline_obj = yline(mu_star, '--m', sprintf(' Stackelberg Threshold \\mu^* = %.3f', mu_star), ...
102
+ 'LineWidth', 2, 'LabelHorizontalAlignment', 'left', 'LabelVerticalAlignment', 'bottom');
103
+ xregion(attack_start, attack_end, 'FaceColor', [1 0.8 0.8], 'FaceAlpha', 0.4);
104
+
105
+ trigger_idx = find(action_triggered == 1, 1, 'first');
106
+ if ~isempty(trigger_idx)
107
+ plot(time(trigger_idx), mu(trigger_idx), 'ro', 'MarkerSize', 10, 'MarkerFaceColor', 'r');
108
+ text(time(trigger_idx) + 2, mu(trigger_idx) - 0.08, ...
109
+ sprintf('Automated Containment Triggered (t = %ds)', time(trigger_idx)), ...
110
+ 'FontWeight', 'bold', 'Color', 'r');
111
+ end
112
+
113
+ xlabel('Time [Seconds]');
114
+ ylabel('Posterior Attack Belief \mu(t)');
115
+ title('B. Dynamic Bayesian State Updating & Automated Game Control Execution');
116
+ ylim([0 1.05]);
117
+ grid on;
118
+ legend('Posterior Belief \mu(t)', 'Critical Decision Threshold', 'Location', 'northwest');
Graph_5_paper_2.m ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ %Paper 2 Fig_5
3
+ clear; clc; close all;
4
+
5
+ %% Input data
6
+ T = 100;
7
+ dt = 1;
8
+ time = 0:dt:T;
9
+ N = length(time);
10
+
11
+ attack_start = 15;
12
+ attack_stop = 75;
13
+
14
+
15
+ lambda_0 = 50; % Normal baseline noise
16
+ lambda_1 = 62; % Set reconnaissance to a higher value
17
+
18
+ C_D = 15; % Isolation Cost
19
+ E_L_FAIR = 92.58; % Expected Loss
20
+
21
+ PE_vec = [0.450, 0.739, 0.920];
22
+ scenarios = {'Low Risk P(E)=0.450', 'Baseline P(E)=0.739', 'High Risk P(E)=0.920'};% Different PE values for High, Low and Baselien risk
23
+
24
+ figure('Color', [1 1 1], 'Position', [100 100 800 800]);
25
+
26
+ for s = 1:length(PE_vec)
27
+ P_E = PE_vec(s);
28
+ mu_star = C_D / (P_E * E_L_FAIR); % Threshold: 0.360, 0.219, 0.176
29
+ % The mu_star comes from equation_17
30
+
31
+
32
+ pi0 = 0.02;
33
+ mu = zeros(1, N);
34
+ mu(1) = pi0;
35
+
36
+ rng(42); % seed value
37
+
38
+
39
+ for k = 2:N
40
+ t_curr = time(k);
41
+
42
+ % Poisson arrivals-if-else
43
+ if t_curr >= attack_start && t_curr <= attack_stop
44
+ k_obs = poissrnd(lambda_1 * dt); % Attack stream ( Use this K-obs value with lambda_1 when dealing with attack phase)
45
+ else
46
+ k_obs = poissrnd(lambda_0 * dt); % Baseline stream
47
+ end
48
+ % This comes from the equation 11,14 and 15
49
+ % Poisson Likelihood Ratio
50
+ % L = (lambda_1 / lambda_0)^k * exp(-(lambda_1 - lambda_0))
51
+ L = ((lambda_1 / lambda_0)^k_obs) * exp(-(lambda_1 - lambda_0) * dt);
52
+
53
+ % Updating the Bayesian Update
54
+ prior = mu(k-1);
55
+ posterior = (L * prior) / (L * prior + (1 - prior));
56
+
57
+ % Floor prior to prevent deep underflow before attack
58
+ mu(k) = max(posterior, 0.005);
59
+ end
60
+
61
+ % Find Trigger Point
62
+ trig_idx = find(mu >= mu_star, 1, 'first');
63
+ t_trig = time(trig_idx);
64
+
65
+ % Graphs
66
+ subplot(3, 1, s);
67
+ plot(time, mu, 'b-', 'LineWidth', 2.5); hold on;
68
+ yline(mu_star, '--m', sprintf(' Stackelberg Threshold \\mu^* = %.3f', mu_star), ...
69
+ 'LineWidth', 1.8, 'LabelHorizontalAlignment', 'left');
70
+ xregion(attack_start, attack_stop, 'FaceColor', [1 0.8 0.8], 'FaceAlpha', 0.3);
71
+
72
+ if ~isempty(trig_idx)
73
+ plot(t_trig, mu(trig_idx), 'ro', 'MarkerSize', 9, 'MarkerFaceColor', 'r');
74
+ text(t_trig + 2, mu_star - 0.08, ...
75
+ sprintf('Automated Containment Triggered (t = %ds)', t_trig), ...
76
+ 'FontWeight', 'bold', 'Color', 'r', 'FontSize', 10);
77
+ end
78
+
79
+ ylabel('Posterior Belief \mu(t)');
80
+ title(sprintf('%s | \\mu^* = %.3f', scenarios{s}, mu_star));
81
+ ylim([0 1.05]); grid on;
82
+ if s == 3, xlabel('Time [Seconds]'); end
83
+ end