Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,34 @@
|
|
1 |
import streamlit as st
|
2 |
from sentence_transformers import CrossEncoder
|
3 |
|
4 |
-
#
|
5 |
st.title("Typosquatting Detection App")
|
6 |
st.write("Enter two domains to check if one is a typosquatted variant of the other.")
|
7 |
|
|
|
8 |
model_choice = st.selectbox("Choose a model for detection:", ["CE-typosquat-detect-Canine", "CE-typosquat-detect"])
|
9 |
-
model_path = f"./{model_choice}"
|
10 |
-
model = CrossEncoder(model_path)
|
11 |
|
12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
13 |
domain = st.text_input("Enter the legitimate domain name:")
|
14 |
typosquat = st.text_input("Enter the potentially typosquatted domain name:")
|
15 |
st.write("Recommended threshold for detection is 0.3.")
|
16 |
threshold = st.slider("Set detection threshold", 0.0, 1.0, 0.3)
|
17 |
|
18 |
-
# Typosquatting detection
|
19 |
if st.button("Check Typosquatting"):
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
26 |
else:
|
27 |
-
st.
|
|
|
1 |
import streamlit as st
|
2 |
from sentence_transformers import CrossEncoder
|
3 |
|
4 |
+
# Title and instructions
|
5 |
st.title("Typosquatting Detection App")
|
6 |
st.write("Enter two domains to check if one is a typosquatted variant of the other.")
|
7 |
|
8 |
+
# Model selection
|
9 |
model_choice = st.selectbox("Choose a model for detection:", ["CE-typosquat-detect-Canine", "CE-typosquat-detect"])
|
|
|
|
|
10 |
|
11 |
+
# Load model after selection
|
12 |
+
if model_choice:
|
13 |
+
model_path = f"./{model_choice}"
|
14 |
+
model = CrossEncoder(model_path)
|
15 |
+
|
16 |
+
# User inputs for domains and threshold
|
17 |
domain = st.text_input("Enter the legitimate domain name:")
|
18 |
typosquat = st.text_input("Enter the potentially typosquatted domain name:")
|
19 |
st.write("Recommended threshold for detection is 0.3.")
|
20 |
threshold = st.slider("Set detection threshold", 0.0, 1.0, 0.3)
|
21 |
|
22 |
+
# Typosquatting detection on button click
|
23 |
if st.button("Check Typosquatting"):
|
24 |
+
if domain and typosquat:
|
25 |
+
inputs = [(typosquat, domain)]
|
26 |
+
prediction = model.predict(inputs)[0]
|
27 |
+
|
28 |
+
# Display result
|
29 |
+
if prediction > threshold:
|
30 |
+
st.success(f"The model predicts that '{typosquat}' is likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
|
31 |
+
else:
|
32 |
+
st.warning(f"The model predicts that '{typosquat}' is NOT likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
|
33 |
else:
|
34 |
+
st.error("Please enter both a legitimate domain and a potentially typosquatted domain.")
|