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
d9c90ff6
Commit
d9c90ff6
authored
Nov 03, 2023
by
Sajana_it20194130
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
81cdf8d9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
DUMP.py
DUMP.py
+56
-0
No files found.
DUMP.py
0 → 100644
View file @
d9c90ff6
import
joblib
import
re
import
nltk
import
numpy
as
np
nltk
.
download
(
'stopwords'
)
from
nltk.corpus
import
stopwords
from
nltk.stem.porter
import
PorterStemmer
from
tkinter
import
messagebox
# Load the dumped models
regressor
=
joblib
.
load
(
'random_forest_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
# Mapping of predictions to respective types
prediction_types
=
{
0
:
"Normal"
,
1
:
"Wrong Setup"
,
2
:
"DDOS"
,
3
:
"Data type probing"
,
4
:
"Scan Attack"
,
5
:
"Man in the Middle"
}
# New traffic insert
new_text
=
input
(
"Enter the IoT Traffic: "
)
preprocessed_text
=
preprocess_text
(
new_text
)
# Use the loaded CountVectorizer object to transform the preprocessed text into a bag of words representation
new_data_transformed
=
cv
.
transform
([
preprocessed_text
])
.
toarray
()
# Make predictions using the loaded model
predictions
=
regressor
.
predict
(
new_data_transformed
)
rounded_predictions
=
np
.
round
(
predictions
)
predicted_type
=
prediction_types
[
int
(
rounded_predictions
[
0
])]
# Print the predictions
print
(
rounded_predictions
)
# Display a pop-up message with the predicted type
message
=
f
"The predicted traffic type is: {predicted_type}"
messagebox
.
showinfo
(
"Prediction"
,
message
)
#0- 2020 12:37:22.736684743 IST$54$50:02:91:69:66:71$98:22:ef:d5:cc:2f$192.168.0.35$192.168.0.121$6$40$0$49279$80$49279 → 80 [FIN
#1- 2020 12:37:22.860634861 IST$269$50:02:91:69:66:71$98:22:ef:d5:cc:2f$192.168.0.35$192.168.0.121$6$255$215$56127$80$GET /ids/server.php?data=60.00 HTTP/1.1
#2- 2020 13:04:23.345843354 IST$98$64:6e:69:dc:d7:c9$98:22:ef:d5:cc:2f$192.168.0.183$192.168.0.121$1$84$$$$Echo (ping) request id=0x55ce
#3- 2020 12:37:41.624289372 IST$42$98:22:ef:d5:cc:2f$ac:bc:32:c0:21:4b$$$$$$$$Who has 192.168.0.198? Tell 192.168.0.121
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