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
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
import time
|
| 5 |
+
import numpy as np
|
| 6 |
+
import seaborn as sns
|
| 7 |
+
from streamlit_extras.colored_header import colored_header
|
| 8 |
+
from streamlit_extras.card import card
|
| 9 |
+
from streamlit_extras.badges import badge
|
| 10 |
+
from streamlit_extras.metric_cards import style_metric_cards
|
| 11 |
+
from streamlit_extras.dataframe_explorer import dataframe_explorer ,generate_fake_dataframe
|
| 12 |
+
from streamlit_extras.mention import mention
|
| 13 |
+
from streamlit_extras.chart_container import chart_container
|
| 14 |
+
from streamlit_extras.grid import grid
|
| 15 |
+
from streamlit_extras.row import row
|
| 16 |
+
import tensorflow as tf
|
| 17 |
+
import pygame
|
| 18 |
+
from io import StringIO
|
| 19 |
+
|
| 20 |
+
APP_TITLE="SAVE_ME"
|
| 21 |
+
alert_sound_path = "Danger Alarm Sound Effect.mp3"
|
| 22 |
+
pygame.mixer.init()
|
| 23 |
+
|
| 24 |
+
APP_LOGO="matrix-hacker-background.jpg"
|
| 25 |
+
st.set_page_config(layout="wide", page_title=APP_TITLE, page_icon=APP_LOGO,initial_sidebar_state="expanded")
|
| 26 |
+
|
| 27 |
+
@st.cache_data
|
| 28 |
+
def loadDataframe(path):
|
| 29 |
+
return pd.read_csv(path)
|
| 30 |
+
|
| 31 |
+
@st.cache_data
|
| 32 |
+
def loadModel():
|
| 33 |
+
return tf.keras.models.load_model("security.h5")
|
| 34 |
+
def play_alert_sound():
|
| 35 |
+
pygame.mixer.music.load(alert_sound_path)
|
| 36 |
+
pygame.mixer.music.play()
|
| 37 |
+
|
| 38 |
+
def displayTextSlowly(text):
|
| 39 |
+
for word in text.split("/"):
|
| 40 |
+
yield word+" "
|
| 41 |
+
time.sleep(0.02)
|
| 42 |
+
tf.keras.models.load_model("security.h5")
|
| 43 |
+
|
| 44 |
+
#fonction de simulation f'intruisions
|
| 45 |
+
def simulate_intrusion():
|
| 46 |
+
col1, col2 = st.columns(2)
|
| 47 |
+
# action= (x > 0.5).astype(int).flatten()
|
| 48 |
+
# data["Action"]= action
|
| 49 |
+
# st.dataframe(data)
|
| 50 |
+
with col1:
|
| 51 |
+
bytes_sent = st.number_input("Bytes Sent", min_value=0, value=1)
|
| 52 |
+
bytes_received = st.number_input("Bytes Received", min_value=0, value=1)
|
| 53 |
+
elapsed_time = st.number_input("Elapsed Time (sec)", min_value=0, value=1)
|
| 54 |
+
|
| 55 |
+
with col2:
|
| 56 |
+
pkts_sent = st.number_input("Packets Sent", min_value=0, value=1)
|
| 57 |
+
pkts_received = st.number_input("Packets Received", min_value=0, value=12)
|
| 58 |
+
|
| 59 |
+
input_data = {
|
| 60 |
+
"Bytes Sent": [bytes_sent if bytes_sent else 0],
|
| 61 |
+
"Bytes Received": [bytes_received if bytes_received else 0],
|
| 62 |
+
"Elapsed Time (sec)": [elapsed_time if elapsed_time else 0],
|
| 63 |
+
"pkts_sent": [pkts_sent if pkts_sent else 0],
|
| 64 |
+
"pkts_received": [pkts_received if pkts_received else 0]
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
return pd.DataFrame(input_data, index=[0])
|
| 68 |
+
parameters = {
|
| 69 |
+
"Action": {
|
| 70 |
+
"description": """
|
| 71 |
+
**Description:** C'est la décision finale de votre modèle, indiquant s'il considère le trafic comme une intrusion ou non.
|
| 72 |
+
**Valeurs possibles:** 'Intrusion' ou 'Non Intrusion'.
|
| 73 |
+
**Rôle:** Ce paramètre est crucial car il représente la sortie du modèle après toutes les analyses.
|
| 74 |
+
""",
|
| 75 |
+
"image": "hackers-film-ddos-attack-threat-video.jpg"
|
| 76 |
+
},
|
| 77 |
+
"Bytes Sent": {
|
| 78 |
+
"description": """
|
| 79 |
+
**Description:** Nombre total d'octets envoyés par l'entité au cours de la connexion.
|
| 80 |
+
**Rôle:** Permet d'évaluer la quantité de données envoyées et peut être un indicateur du comportement du réseau.
|
| 81 |
+
""",
|
| 82 |
+
"image": "blue-optic-fiber-with-ethernet-cables.jpg"
|
| 83 |
+
},
|
| 84 |
+
"Bytes Received": {
|
| 85 |
+
"description": """
|
| 86 |
+
**Description:** Nombre total d'octets reçus par l'entité au cours de la connexion.
|
| 87 |
+
**Rôle:** Comme pour les octets envoyés, ce paramètre aide à comprendre la quantité de données reçues et peut signaler des anomalies.
|
| 88 |
+
""",
|
| 89 |
+
"image": "computer-hacker-hooded-shirt-typing-software-algorithms-stealing-data-from-computer-network-laptop.jpg"
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
params ={
|
| 93 |
+
"pkts_sent": {
|
| 94 |
+
"description": """
|
| 95 |
+
**Description:** Nombre total de paquets envoyés durant la connexion.
|
| 96 |
+
**Rôle:** Le volume de paquets envoyés peut aider à identifier les comportements suspects ou anormaux.
|
| 97 |
+
""",
|
| 98 |
+
"image": "password-with-hand-holding-tweezers-binary-code.jpg"
|
| 99 |
+
},
|
| 100 |
+
"pkts_received": {
|
| 101 |
+
"description": """
|
| 102 |
+
**Description:** Nombre total de paquets reçus durant la connexion.
|
| 103 |
+
**Rôle:** Comme pour les paquets envoyés, ce paramètre est important pour détecter les anomalies en fonction du volume des données reçues.
|
| 104 |
+
""",
|
| 105 |
+
"image": "hackers-film-ddos-attack-threat-video.jpg" # Replace with the actual image path
|
| 106 |
+
},
|
| 107 |
+
"Elapsed Time (sec)": {
|
| 108 |
+
"description": """
|
| 109 |
+
**Description:** Temps écoulé en secondes durant la connexion ou l'événement observé.
|
| 110 |
+
**Rôle:** Mesure la durée de l'activité, utile pour détecter les anomalies temporelles.
|
| 111 |
+
""",
|
| 112 |
+
"image": "html-css-collage-concept-with-hacker.jpg" # Replace with the actual image path
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
#preparation des constantes
|
| 116 |
+
MODEL= loadModel()
|
| 117 |
+
DATA= loadDataframe("finalDf.csv")
|
| 118 |
+
MenuNavigation = ["🏠Accueil", "📈Analyse","📊Visualisation", "🤺Simulation", "📞Contact"]
|
| 119 |
+
DESCRIPTION = """
|
| 120 |
+
<h2 style='color: #7D7D7D;'>Système de Détection d'Intrusion Basé sur l'Apprentissage Profond</h2>
|
| 121 |
+
<p>Dans un monde numérique en constante évolution, les menaces en ligne deviennent de plus en plus sophistiquées. Les systèmes de détection d'intrusion traditionnels peuvent ne pas suffire pour contrer ces attaques avancées. C'est pourquoi nous avons développé un système de détection d'intrusion (IDS) <strong>révolutionnaire</strong> basé sur l'apprentissage profond, offrant une sécurité renforcée et une détection précise des anomalies.</p>
|
| 122 |
+
|
| 123 |
+
<p>L'apprentissage profond est une branche de l'intelligence artificielle qui utilise des réseaux neuronaux artificiels pour analyser des données complexes. Contrairement aux méthodes de détection classiques, l'apprentissage profond permet à notre système d'identifier des modèles et des anomalies dans vos données de réseau avec une précision inégalée. Grâce à des algorithmes sophistiqués et à une formation sur des volumes massifs de données, notre IDS peut détecter des comportements suspects et des attaques potentiellement dangereuses que d'autres systèmes pourraient manquer.</p>
|
| 124 |
+
"""
|
| 125 |
+
st.sidebar.image(APP_LOGO, width=255)
|
| 126 |
+
|
| 127 |
+
chooseMenu= st.sidebar.selectbox("Où allons 🚔 nous Aujourd'hui? ",MenuNavigation)
|
| 128 |
+
if chooseMenu== MenuNavigation[0]:
|
| 129 |
+
st.markdown("<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'><u>{} </u></h1>".format(APP_TITLE),unsafe_allow_html=True)
|
| 130 |
+
st.markdown("<p style='text-align:center; color: gray;'><i>Securité Sécurisée</i></p>", unsafe_allow_html=True)
|
| 131 |
+
st.markdown("<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'>{}: La meilleure approche pour votre sécurité</h1>".format(APP_TITLE),unsafe_allow_html=True)
|
| 132 |
+
col1,col2= st.columns((1,2))
|
| 133 |
+
with col1:
|
| 134 |
+
st.image("html-css-collage-concept-with-hacker.jpg")
|
| 135 |
+
with col2:
|
| 136 |
+
st.write(DESCRIPTION, unsafe_allow_html=True)
|
| 137 |
+
st.markdown("<h1 style='text-align:center; text-transform: uppercase; text-tranform:underline; color: #005580'>LES PARAMETRES DE NOTRE MODEL</h1>",unsafe_allow_html=True)# affiche des titres html
|
| 138 |
+
col1, col2 = st.columns(2)
|
| 139 |
+
|
| 140 |
+
with col1:
|
| 141 |
+
for param, info in parameters.items():
|
| 142 |
+
col1x, col2x = st.columns([1, 3]) # Define columns with relative widths
|
| 143 |
+
with col1x:
|
| 144 |
+
st.image(info['image'],use_column_width=True) # width as needed
|
| 145 |
+
with col2x:
|
| 146 |
+
st.markdown(f"""
|
| 147 |
+
### Paramètre: **{param}**
|
| 148 |
+
{info['description']}
|
| 149 |
+
""", unsafe_allow_html=True)
|
| 150 |
+
with col2:
|
| 151 |
+
# params st.write("Additional information or space.")
|
| 152 |
+
for param, info in params.items():
|
| 153 |
+
col1x, col2x = st.columns([1, 3]) # Define columns with relative widths
|
| 154 |
+
with col1x:
|
| 155 |
+
st.image(info['image'], use_column_width=True) # Adjust width as needed
|
| 156 |
+
with col2x:
|
| 157 |
+
st.markdown(f"""
|
| 158 |
+
### Paramètre: **{param}**
|
| 159 |
+
{info['description']}
|
| 160 |
+
""", unsafe_allow_html=True)
|
| 161 |
+
elif chooseMenu==MenuNavigation[4]:
|
| 162 |
+
st.markdown("<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'>Mon Profil</h1>",unsafe_allow_html=True)# affiche des titres html
|
| 163 |
+
col1, col2= st.columns((6,15))
|
| 164 |
+
with col1:
|
| 165 |
+
st.image("minee.jpg", width=385)
|
| 166 |
+
|
| 167 |
+
with col2:
|
| 168 |
+
cols1,cols2= st.columns((1,1))
|
| 169 |
+
st.markdown("""
|
| 170 |
+
<div style='display:flex; flex-direction:row;'>
|
| 171 |
+
<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'>Nom:</h1>
|
| 172 |
+
<h1 style='text-align:left;color: gray; text-transform: uppercase; text-tranform:underline,'>Elie Makoda Kowo</h1>
|
| 173 |
+
</div>
|
| 174 |
+
""",unsafe_allow_html=True)
|
| 175 |
+
st.markdown("""
|
| 176 |
+
<div style='display:flex; flex-direction:row;'>
|
| 177 |
+
<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'>Email:</h1>
|
| 178 |
+
<h1 style='text-align:left;color: gray; text-tranform:underline,'><a href='mailto:eliemakodakowo@gmail.com' style='color:gray;'> eliemakodakowo@gmail.com</a></h1>
|
| 179 |
+
</div>
|
| 180 |
+
""",unsafe_allow_html=True)
|
| 181 |
+
st.markdown("""
|
| 182 |
+
<div style='display:flex; flex-direction:row;'>
|
| 183 |
+
<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'>Contact:</h1>
|
| 184 |
+
<h1 style='text-align:left;color: gray; text-tranform:underline,'><a href='tel:+237 698982479' style='color:gray;'>+237 674349356 / +237 698982479</a></h1>
|
| 185 |
+
</div>
|
| 186 |
+
""",unsafe_allow_html=True)
|
| 187 |
+
|
| 188 |
+
st.markdown("""
|
| 189 |
+
<div style='display:flex; flex-direction:row;'>
|
| 190 |
+
<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'>Level:</h1>
|
| 191 |
+
<h1 style='text-align:left;color: gray; text-tranform:underline,'>Bachelor 3 Artificial Intelligence & Big Data</h1>
|
| 192 |
+
</div>
|
| 193 |
+
""",unsafe_allow_html=True)
|
| 194 |
+
st.markdown("<h1 style='color: #005580; text-align:center; text-transform: uppercase; text-tranform:underline,'>Competences</h1>",unsafe_allow_html=True)# affiche des titres html
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
coll1, coll2, coll3=st.columns((6,5,4))
|
| 198 |
+
with coll1:
|
| 199 |
+
card(
|
| 200 |
+
title="Programmation Web",
|
| 201 |
+
text="React , Django, Spring , Php",
|
| 202 |
+
url="https://github.com/eliemakoda?tab=repositories",
|
| 203 |
+
)
|
| 204 |
+
with coll2:
|
| 205 |
+
card(
|
| 206 |
+
title="Programmation DeskTop",
|
| 207 |
+
text="Java, C_Sharp",
|
| 208 |
+
url="https://github.com/eliemakoda?tab=repositories",
|
| 209 |
+
)
|
| 210 |
+
with coll3:
|
| 211 |
+
card(
|
| 212 |
+
title="Programmation Mobile",
|
| 213 |
+
text="React Native ",
|
| 214 |
+
url="https://github.com/eliemakoda?tab=repositories",
|
| 215 |
+
)
|
| 216 |
+
colls1, colls2=st.columns((8,8))
|
| 217 |
+
with colls1:
|
| 218 |
+
card(
|
| 219 |
+
title="Machine & Deep Learning",
|
| 220 |
+
text="Tensorflow ,Pycaret, Sklearn, ProphetNeural... ",
|
| 221 |
+
url="https://github.com/eliemakoda?tab=repositories",
|
| 222 |
+
)
|
| 223 |
+
with colls2:
|
| 224 |
+
card(
|
| 225 |
+
title="Data Analysis",
|
| 226 |
+
text="Seaborn , Tableau , PowerBi , Matplotlib, Numpy Pandas... ",
|
| 227 |
+
url="https://github.com/eliemakoda?tab=repositories",
|
| 228 |
+
)
|
| 229 |
+
#Data analysis
|
| 230 |
+
elif chooseMenu== MenuNavigation[1]:
|
| 231 |
+
col1, col2, col3, col4 ,col5= st.columns(5)
|
| 232 |
+
sumByte= np.sum(DATA["Bytes Sent"])+np.sum( DATA["Bytes Received"])
|
| 233 |
+
col1.metric(label="Nombre De Données", value=DATA.shape[0], delta=5000)
|
| 234 |
+
col2.metric(label="Nombre Moyens de Paquets ", value=int((DATA.pkts_sent.sum()+ DATA.pkts_received.sum())/DATA.shape[0]), delta=100)
|
| 235 |
+
col3.metric(label="Nombre Moyen de Bytes", value=int(sumByte/DATA.shape[0]), delta=10000)
|
| 236 |
+
col4.metric(label="Moyenne du temps des requêtes", value=int(DATA["Elapsed Time (sec)"].sum()/DATA.shape[0]), delta=1000)
|
| 237 |
+
col5.metric(label="Maximum de Paquets", value=max(DATA.pkts_sent.astype(int)+ DATA.pkts_received.astype(int)), delta=82)
|
| 238 |
+
style_metric_cards()
|
| 239 |
+
st.title("Filtrez le dataFrame", help="la dataframe contient les colonnes telles que: 'Bytes Sent','Bytes Received', 'Elapsed Time (sec)','pkts_sent','pkts_received'", anchor="desc")
|
| 240 |
+
filtered_DataFrame= dataframe_explorer(DATA, case=False)
|
| 241 |
+
st.dataframe(filtered_DataFrame, use_container_width=True)
|
| 242 |
+
mention(
|
| 243 |
+
label="Vue Statistique du jeu de données",
|
| 244 |
+
# icon="streamlit", # Some icons are available... like Streamlit!
|
| 245 |
+
url="#desc",
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
st.dataframe(DATA.drop("Action",axis=1).describe(), use_container_width=True, hide_index=False)
|
| 249 |
+
# fig, ax = plt.subplots(figsize=(10, 8))
|
| 250 |
+
# sns.heatmap(DATA.drop("Action",axis=1).corr(), annot=True, fmt=".2f", cmap='coolwarm', ax=ax)
|
| 251 |
+
# ax.set_title('Matrice de corrélation des variables')
|
| 252 |
+
# st.pyplot(fig=fig, use_container_width=False)
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
elif chooseMenu== MenuNavigation[2]:
|
| 256 |
+
st.markdown("<h1 style='text-align:center;color: gray; text-transform: uppercase; text-tranform:underline; color: #005580'>Observons Nos données Avec les Graphes</h1>",unsafe_allow_html=True)# affiche des titres html
|
| 257 |
+
my_grid = grid(2, [2, 4, 1], 1, 4, vertical_align="bottom")
|
| 258 |
+
|
| 259 |
+
# Row 1:
|
| 260 |
+
# my_grid.dataframe(DATA, use_container_width=True)
|
| 261 |
+
my_grid.line_chart(DATA.drop(["Bytes Sent","Bytes Received","Action","Elapsed Time (sec)"], axis=1), use_container_width=True)
|
| 262 |
+
|
| 263 |
+
my_grid.line_chart(DATA[["pkts_sent", "pkts_received"]], use_container_width=True)
|
| 264 |
+
col1, col2= st.columns(2)
|
| 265 |
+
with col1:
|
| 266 |
+
st.write(DATA.drop("Action", axis=1).describe())
|
| 267 |
+
with col2:
|
| 268 |
+
mask = np.triu(np.ones_like(DATA.drop("Action", axis=1).corr(), dtype=bool))
|
| 269 |
+
f, ax = plt.subplots(figsize=(3,4))
|
| 270 |
+
cmap = sns.diverging_palette(230, 20, as_cmap=True)
|
| 271 |
+
sns.heatmap(DATA.drop("Action", axis=1).corr(), mask=mask, cmap=cmap, vmax=.2, center=0,
|
| 272 |
+
square=True, linewidths=.3, cbar_kws={"shrink": .4})
|
| 273 |
+
st.pyplot(f, use_container_width=False)
|
| 274 |
+
|
| 275 |
+
st.title("Variable Vs Action")
|
| 276 |
+
varMenu = ['Bytes Sent', 'Bytes Received', 'Elapsed Time (sec)', 'pkts_sent', 'pkts_received']
|
| 277 |
+
colx = st.selectbox("Exprimer", varMenu)
|
| 278 |
+
|
| 279 |
+
fig, ax = plt.subplots(figsize=(4, 2))
|
| 280 |
+
|
| 281 |
+
sns.histplot(data=DATA[DATA[colx]<100], x=colx, hue="Action", bins=12, kde=True, palette=["red", "green"], ax=ax)
|
| 282 |
+
|
| 283 |
+
ax.set_title(f'Distribution de {colx} VS Action')
|
| 284 |
+
|
| 285 |
+
st.pyplot(fig, use_container_width=False)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
elif chooseMenu==MenuNavigation[3]:
|
| 290 |
+
st.markdown("<h1 style='text-align:center;color: #005580; text-transform: uppercase; text-tranform:underline,'>SIMULATION DE VOS REQUETES </h1>",unsafe_allow_html=True)# affiche des titres html
|
| 291 |
+
file= st.sidebar.file_uploader("Importez un fichier de Prediction ")
|
| 292 |
+
if file:
|
| 293 |
+
dat= pd.read_csv(file)
|
| 294 |
+
y_pred= MODEL.predict(dat)
|
| 295 |
+
dat["Action"] = (y_pred > 0.5).astype(int).flatten()
|
| 296 |
+
dat["Action"]=dat["Action"].apply(lambda x: "Intrusion" if x == 0 else "No Intrusion")
|
| 297 |
+
varMenu = ['Bytes Sent', 'Bytes Received', 'Elapsed Time (sec)', 'pkts_sent', 'pkts_received']
|
| 298 |
+
with chart_container(dat):
|
| 299 |
+
st.write("Hello Un Graphe ")
|
| 300 |
+
st.area_chart(dat[varMenu])
|
| 301 |
+
elif st.sidebar.checkbox("Utiliser Notre Fichier"):
|
| 302 |
+
dat= pd.read_csv("testDAta.csv")
|
| 303 |
+
y_pred= MODEL.predict(dat)
|
| 304 |
+
dat["Action"] = (y_pred > 0.5).astype(int).flatten()
|
| 305 |
+
x=dat["Action"].apply(lambda x: "Intrusion" if x == 0 else "No Intrusion")
|
| 306 |
+
varMenu = ['Bytes Sent', 'Bytes Received', 'Elapsed Time (sec)', 'pkts_sent', 'pkts_received']
|
| 307 |
+
with chart_container(dat):
|
| 308 |
+
dat["Action"]=x
|
| 309 |
+
dat.set_index=[0]
|
| 310 |
+
st.write("Hello Un Graphe ")
|
| 311 |
+
st.area_chart(dat[varMenu])
|
| 312 |
+
# st.write(dat.head())
|
| 313 |
+
else:
|
| 314 |
+
data_Input= simulate_intrusion()
|
| 315 |
+
y_pred = MODEL.predict(data_Input)
|
| 316 |
+
y_pred_class = (y_pred > 0.5).astype(int).flatten()
|
| 317 |
+
target= ["Intruision" if y_pred_class==0 else "No Intruision"]
|
| 318 |
+
data_Input["Action"]=target[0]
|
| 319 |
+
if y_pred_class==0:
|
| 320 |
+
play_alert_sound()
|
| 321 |
+
st.dataframe(data_Input,use_container_width=True)
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
# st.write(tmp1)
|
| 328 |
+
# input_data = {
|
| 329 |
+
# "Bytes Sent": [bytes_sent if bytes_sent else 0],
|
| 330 |
+
# "Bytes Received": [bytes_received if bytes_received else 0],
|
| 331 |
+
# "Elapsed Time (sec)": [elapsed_time if elapsed_time else 0],
|
| 332 |
+
# "pkts_sent": [pkts_sent if pkts_sent else 0],
|
| 333 |
+
# "pkts_received": [pkts_received if pkts_received else 0]
|
| 334 |
+
# }
|