Spaces:
Running
Running
File size: 11,323 Bytes
bb6d7b4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
import streamlit as st
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import numpy as np
import altair as alt
from datetime import datetime, timedelta
def render_dashboard():
st.title("Dark Web Intelligence Dashboard")
# Date range selector
col1, col2 = st.columns([3, 1])
with col1:
st.markdown("## Overview")
st.markdown("Real-time monitoring of dark web activities, data breaches, and emerging threats.")
with col2:
date_range = st.selectbox(
"Time Range",
["Last 24 Hours", "Last 7 Days", "Last 30 Days", "Last Quarter", "Custom Range"],
index=1
)
# Dashboard metrics row
metric_col1, metric_col2, metric_col3, metric_col4 = st.columns(4)
with metric_col1:
st.metric(
label="Active Threats",
value="27",
delta="4",
delta_color="inverse"
)
with metric_col2:
st.metric(
label="Data Breaches",
value="3",
delta="-2",
delta_color="normal"
)
with metric_col3:
st.metric(
label="Credential Leaks",
value="1,247",
delta="89",
delta_color="inverse"
)
with metric_col4:
st.metric(
label="Threat Score",
value="72/100",
delta="12",
delta_color="inverse"
)
# First row - Threat map and category distribution
row1_col1, row1_col2 = st.columns([2, 1])
with row1_col1:
st.subheader("Global Threat Origin Map")
# World map of threat origins
fig = go.Figure(data=go.Choropleth(
locations=['USA', 'RUS', 'CHN', 'IRN', 'PRK', 'UKR', 'DEU', 'GBR', 'CAN', 'BRA', 'IND'],
z=[25, 42, 37, 30, 28, 18, 15, 20, 12, 14, 23],
colorscale='Reds',
autocolorscale=False,
reversescale=False,
marker_line_color='#2C3E50',
marker_line_width=0.5,
colorbar_title='Threat<br>Index',
))
fig.update_layout(
geo=dict(
showframe=False,
showcoastlines=True,
projection_type='equirectangular',
bgcolor='rgba(26, 26, 26, 0)',
coastlinecolor='#2C3E50',
landcolor='#1A1A1A',
oceancolor='#2C3E50',
),
paper_bgcolor='rgba(26, 26, 26, 0)',
plot_bgcolor='rgba(26, 26, 26, 0)',
margin=dict(l=0, r=0, t=0, b=0),
height=400,
)
st.plotly_chart(fig, use_container_width=True)
with row1_col2:
st.subheader("Threat Categories")
# Threat category distribution
categories = ['Data Breach', 'Ransomware', 'Phishing', 'Malware', 'Identity Theft']
values = [38, 24, 18, 14, 6]
fig = px.pie(
names=categories,
values=values,
hole=0.6,
color_discrete_sequence=['#E74C3C', '#F1C40F', '#3498DB', '#2ECC71', '#9B59B6']
)
fig.update_layout(
paper_bgcolor='rgba(26, 26, 26, 0)',
plot_bgcolor='rgba(26, 26, 26, 0)',
showlegend=True,
legend=dict(
orientation="v",
yanchor="middle",
y=0.5,
xanchor="center",
x=0.5
),
margin=dict(l=0, r=0, t=30, b=0),
height=300,
)
st.plotly_chart(fig, use_container_width=True)
# Second row - Trend and recent activities
row2_col1, row2_col2 = st.columns([3, 2])
with row2_col1:
st.subheader("Threat Activity Trend")
# Generate dates for the past 14 days
dates = [(datetime.now() - timedelta(days=i)).strftime('%Y-%m-%d') for i in range(14, 0, -1)]
# Sample data for threats over time
threat_data = {
'Date': dates,
'High': [12, 10, 15, 11, 14, 16, 18, 20, 17, 12, 14, 13, 19, 22],
'Medium': [23, 25, 22, 20, 24, 25, 26, 24, 22, 21, 23, 25, 28, 27],
'Low': [32, 30, 35, 34, 36, 33, 30, 34, 38, 37, 35, 34, 32, 30]
}
df = pd.DataFrame(threat_data)
# Create stacked area chart
fig = go.Figure()
fig.add_trace(go.Scatter(
x=df['Date'], y=df['High'],
mode='lines',
line=dict(width=0.5, color='#E74C3C'),
stackgroup='one',
name='High'
))
fig.add_trace(go.Scatter(
x=df['Date'], y=df['Medium'],
mode='lines',
line=dict(width=0.5, color='#F1C40F'),
stackgroup='one',
name='Medium'
))
fig.add_trace(go.Scatter(
x=df['Date'], y=df['Low'],
mode='lines',
line=dict(width=0.5, color='#2ECC71'),
stackgroup='one',
name='Low'
))
fig.update_layout(
paper_bgcolor='rgba(26, 26, 26, 0)',
plot_bgcolor='rgba(26, 26, 26, 0)',
legend=dict(
orientation="h",
yanchor="bottom",
y=1.02,
xanchor="right",
x=1
),
margin=dict(l=0, r=0, t=30, b=0),
xaxis=dict(
showgrid=False,
title=None,
tickfont=dict(color='#ECF0F1')
),
yaxis=dict(
showgrid=True,
gridcolor='rgba(44, 62, 80, 0.3)',
title=None,
tickfont=dict(color='#ECF0F1')
),
height=300
)
st.plotly_chart(fig, use_container_width=True)
with row2_col2:
st.subheader("Recent Intelligence Feeds")
# Recent dark web activities
activities = [
{"time": "10 mins ago", "event": "New ransomware group identified", "severity": "High"},
{"time": "43 mins ago", "event": "Database with 50K credentials for sale", "severity": "High"},
{"time": "2 hours ago", "event": "Zero-day exploit being discussed", "severity": "Medium"},
{"time": "3 hours ago", "event": "New phishing campaign detected", "severity": "Medium"},
{"time": "5 hours ago", "event": "PII data from financial institution leaked", "severity": "High"}
]
for activity in activities:
severity_color = "#E74C3C" if activity["severity"] == "High" else "#F1C40F" if activity["severity"] == "Medium" else "#2ECC71"
cols = st.columns([1, 4, 1])
cols[0].caption(activity["time"])
cols[1].markdown(activity["event"])
cols[2].markdown(f"<span style='color:{severity_color}'>{activity['severity']}</span>", unsafe_allow_html=True)
st.markdown("---")
# Third row - Sectors at risk and trending keywords
row3_col1, row3_col2 = st.columns(2)
with row3_col1:
st.subheader("Sectors at Risk")
# Horizontal bar chart for sectors at risk
sectors = ['Healthcare', 'Finance', 'Technology', 'Education', 'Government', 'Manufacturing']
risk_scores = [87, 82, 75, 63, 78, 56]
sector_data = pd.DataFrame({
'Sector': sectors,
'Risk Score': risk_scores
})
fig = px.bar(
sector_data,
x='Risk Score',
y='Sector',
orientation='h',
color='Risk Score',
color_continuous_scale=['#2ECC71', '#F1C40F', '#E74C3C'],
range_color=[50, 100]
)
fig.update_layout(
paper_bgcolor='rgba(26, 26, 26, 0)',
plot_bgcolor='rgba(26, 26, 26, 0)',
margin=dict(l=0, r=0, t=0, b=0),
height=250,
coloraxis_showscale=False,
xaxis=dict(
showgrid=False,
title=None,
tickfont=dict(color='#ECF0F1')
),
yaxis=dict(
showgrid=False,
title=None,
tickfont=dict(color='#ECF0F1')
)
)
st.plotly_chart(fig, use_container_width=True)
with row3_col2:
st.subheader("Trending Keywords")
# Word cloud alternative - trending keywords with frequency
keywords = [
{"word": "ransomware", "count": 42},
{"word": "zero-day", "count": 37},
{"word": "botnet", "count": 31},
{"word": "credentials", "count": 28},
{"word": "bitcoin", "count": 25},
{"word": "exploit", "count": 23},
{"word": "malware", "count": 21},
{"word": "backdoor", "count": 18},
{"word": "phishing", "count": 16},
{"word": "darknet", "count": 15}
]
keyword_data = pd.DataFrame(keywords)
# Calculate sizes for visual representation
max_count = max(keyword_data['count'])
keyword_data['size'] = keyword_data['count'].apply(lambda x: int((x / max_count) * 100) + 70)
# Create a simple horizontal bar to represent frequency
chart = alt.Chart(keyword_data).mark_bar().encode(
x=alt.X('count:Q', title=None),
y=alt.Y('word:N', title=None, sort='-x'),
color=alt.Color('count:Q', scale=alt.Scale(scheme='reds'), legend=None)
).properties(
height=250
)
st.altair_chart(chart, use_container_width=True)
# Fourth row - Latest intelligence reports
st.subheader("Latest Intelligence Reports")
reports = [
{
"title": "Major Healthcare Breach Analysis",
"date": "2025-04-08",
"summary": "Analysis of recent healthcare data breach affecting over 500,000 patient records.",
"severity": "Critical"
},
{
"title": "Emerging Ransomware Group Activities",
"date": "2025-04-07",
"summary": "New ransomware group targeting financial institutions with sophisticated techniques.",
"severity": "High"
},
{
"title": "Credential Harvesting Campaign",
"date": "2025-04-05",
"summary": "Widespread phishing campaign targeting corporate credentials across multiple sectors.",
"severity": "Medium"
}
]
row4_cols = st.columns(3)
for i, report in enumerate(reports):
with row4_cols[i]:
severity_color = "#E74C3C" if report["severity"] == "Critical" else "#F1C40F" if report["severity"] == "High" else "#2ECC71"
st.markdown(f"#### {report['title']}")
st.markdown(f"<span style='color:{severity_color}'>{report['severity']}</span> | {report['date']}", unsafe_allow_html=True)
st.markdown(report["summary"])
st.button("View Full Report", key=f"report_{i}")
|