Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AAGGY
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
23-153
AAGGY
Commits
bce91b95
Commit
bce91b95
authored
Nov 03, 2023
by
Sajana_it20194130
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
5ad2b0c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
DUMP.py
DUMP.py
+45
-0
No files found.
DUMP.py
0 → 100644
View file @
bce91b95
import
joblib
import
re
import
nltk
nltk
.
download
(
'stopwords'
)
from
nltk.corpus
import
stopwords
from
nltk.stem.porter
import
PorterStemmer
from
tkinter
import
messagebox
# Load the dumped models
classifier
=
joblib
.
load
(
'naive_bayes_model.joblib'
)
cv
=
joblib
.
load
(
'count_vectorizer.joblib'
)
# Function to Clean the texts
def
preprocess_text
(
text
):
log
=
re
.
sub
(
'[^a-zA-Z0-9]'
,
' '
,
text
)
log
=
log
.
lower
()
log
=
log
.
split
()
ps
=
PorterStemmer
()
log
=
[
ps
.
stem
(
word
)
for
word
in
log
if
not
word
in
set
(
stopwords
.
words
(
'english'
))]
log
=
' '
.
join
(
log
)
return
log
# New log insert
new_text
=
input
(
"Enter the traffic info: "
)
preprocessed_text
=
preprocess_text
(
new_text
)
# Use the loaded CountVectorizer object to transform the preprocessed text into a bag of words representation
new_text_bow
=
cv
.
transform
([
preprocessed_text
])
.
toarray
()
# Use the loaded GaussianNB object to make predictions on the new log data
predicted_class
=
classifier
.
predict
(
new_text_bow
)
# Display a pop-up message based on the predicted class
if
predicted_class
:
messagebox
.
showinfo
(
"Anomaly Detected"
,
"Anomaly detected in the traffic!"
)
else
:
messagebox
.
showinfo
(
"No Anomaly"
,
"No anomaly detected in the traffic."
)
# Non Malicious Packet Info
# Adjacency Message (Syn)
# 19717 > 6068 [ACK] Seq=1285 Ack=785 Win=3344 Len=0
# Malicious Packet Info
# 80 > 51451 [ACK] Seq=214260 Ack=712 Win=16128 Len=1460 [TCP segment of a reassembled PDU]
# 80 > 49234 [PSH, ACK] Seq=500760 Ack=325 Win=64240 Len=1448 [TCP segment of a reassembled PDU]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment