File size: 1,400 Bytes
ee64b99
 
 
b3240eb
ee64b99
 
 
b3240eb
1a45114
 
b3240eb
 
 
 
 
 
ee64b99
58bcc6b
3aa5b89
804adda
b3240eb
ee64b99
b3240eb
 
 
 
 
 
 
 
 
ee64b99
b3240eb
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
import streamlit as st
from sentence_transformers import CrossEncoder

# Title and instructions
st.title("Typosquatting Detection App")
st.write("Enter two domains to check if one is a typosquatted variant of the other.")

# Model selection
model_choice = st.selectbox("Choose a model for detection:", ["CE-typosquat-detect-Canine", "CE-typosquat-detect"])

# Load model after selection
if model_choice:
    model_path = f"./{model_choice}"
    model = CrossEncoder(model_path)

# User inputs for domains and threshold
domain = st.text_input("Enter the legitimate domain name:")
typosquat = st.text_input("Enter the potentially typosquatted domain name:")
threshold = st.slider("Set detection threshold", 0.0, 1.0, 0.5)

# Typosquatting detection on button click
if st.button("Check Typosquatting"):
    if domain and typosquat:
        inputs = [(typosquat, domain)]
        prediction = model.predict(inputs)[0]
        
        # Display result
        if prediction > threshold:
            st.success(f"The model predicts that '{typosquat}' is likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
        else:
            st.warning(f"The model predicts that '{typosquat}' is NOT likely a typosquatted version of '{domain}' with a score of {prediction:.4f}.")
    else:
        st.error("Please enter both a legitimate domain and a potentially typosquatted domain.")