Spaces:
Runtime error
Runtime error
File size: 7,582 Bytes
f5cf9ac |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
import streamlit as st
import pandas as pd
import numpy as np
import pickle
import base64
import seaborn as sns
import matplotlib.pyplot as plt
import symbol
st.write("""
# WebPhishing Detection App
WebPhishing Detection App adalah sebuah aplikasi untuk mendeteksi sebuah Phishing pada situs web.
Aplikasi ini menggunakan berbagai macam paramater untuk menujukan bahwa situs Phishing atau Normal
""")
url_dataset = f'<a href="phishing.csv">Download Dataset CSV File</a>'
st.markdown(url_dataset, unsafe_allow_html=True)
def user_input_features() :
UsingIP = st.sidebar.selectbox('UsingIP', ('YA', 'Tidak'))
LongURL = st.sidebar.selectbox('LongURL', ('YA', 'Tidak'))
ShortURL = st.sidebar.selectbox('Short URL', ('YA', 'Tidak'))
Symbol = st.sidebar.selectbox('Symbol', ('YA', 'Tidak'))
Redirecting = st.sidebar.selectbox('Redirecting', ('YA', 'Tidak'))
PrefixSuffix = st.sidebar.selectbox('PrefixSuffix', ('YA', 'Tidak'))
SubDomains = st.sidebar.selectbox('SubDomains', ('YA', 'Tidak'))
HTTPS = st.sidebar.selectbox('HTTPS', ('YA', 'Tidak'))
DomainRegLen = st.sidebar.selectbox('DomainRegLen', ('YA', 'Tidak'))
Favicon = st.sidebar.selectbox('Favicon', ('YA', 'Tidak'))
NonStdPort = st.sidebar.selectbox('NonStdPort', ('YA', 'Tidak'))
HTTPSDomainURL = st.sidebar.selectbox('HTTPSDomainURL', ('YA', 'Tidak'))
RequestURL = st.sidebar.selectbox('RequestURL', ('YA', 'Tidak'))
AnchorURL = st.sidebar.selectbox('AnchorURL', ('YA', 'Tidak'))
LinksInScriptTags = st.sidebar.selectbox('LinksInScriptTags', ('YA', 'Tidak'))
ServerFormHandler = st.sidebar.selectbox('ServerFormHandler', ('YA', 'Tidak'))
InfoEmail = st.sidebar.selectbox('InfoEmail', ('YA', 'Tidak'))
AbnormalURL = st.sidebar.selectbox('AbnormalURL', ('YA', 'Tidak'))
WebsiteForwarding = st.sidebar.selectbox('WebsiteForwarding', ('YA', 'Tidak'))
StatusBarCust = st.sidebar.selectbox('StatusBarCust', ('YA', 'Tidak'))
DisableRightClick = st.sidebar.selectbox('DisableRightClick', ('YA', 'Tidak'))
UsingPopupWindow = st.sidebar.selectbox('UsingPopupWindow', ('YA', 'Tidak'))
IframeRedirection = st.sidebar.selectbox('IframeRedirection', ('YA', 'Tidak'))
AgeofDomain = st.sidebar.selectbox('AgeofDomain', ('YA', 'Tidak'))
DNSRecording = st.sidebar.selectbox('DNSRecording', ('YA', 'Tidak'))
WebsiteTraffic = st.sidebar.selectbox('WebsiteTraffic', ('YA', 'Tidak'))
PageRank = st.sidebar.selectbox('PageRank', ('YA', 'Tidak'))
GoogleIndex = st.sidebar.selectbox('GoogleIndex', ('YA', 'Tidak'))
LinksPointingToPage = st.sidebar.selectbox('LinksPointingToPage', ('YA', 'Tidak'))
StatsReport = st.sidebar.selectbox('StatsReport', ('YA', 'Tidak'))
# phishingYT01 = 1
#if(phishingYT == 'Left') :
#phishingYT01 = 0
usingip = -1
if(UsingIP == 'YA') :
usingip = 1
longurl = -1
if(LongURL == 'YA') :
longurl =1
shorturl = -1
if(ShortURL == 'YA') :
shorturl =1
symbol = -1
if(Symbol == 'YA') :
symbol =1
redirecting = -1
if(Redirecting == 'YA') :
redirecting =1
subdomains = -1
if(SubDomains == 'YA') :
subdomains =1
prefixsuffix = -1
if(PrefixSuffix == 'YA') :
prefixsuffix =1
https = -1
if(HTTPS == 'YA') :
https =1
domainreglen = -1
if(DomainRegLen == 'YA') :
domainreglen =1
favicon = -1
if(Favicon == 'YA') :
favicon =1
nonstdport = -1
if(NonStdPort == 'YA') :
nonstdport =1
httpsdomainurl = -1
if(HTTPSDomainURL == 'YA') :
httpsdomainurl =1
requesturl = -1
if(RequestURL == 'YA') :
requesturl =1
anchorurl = -1
if(AnchorURL == 'YA') :
anchorurl =1
linksinscripttags = -1
if(LinksInScriptTags == 'YA') :
linksinscripttags =1
serverformhandler = -1
if(ServerFormHandler == 'YA') :
serverformhandler =1
infoemail = -1
if(InfoEmail == 'YA') :
infoemail =1
abnormalurl = -1
if(AbnormalURL == 'YA') :
abnormalurl =1
websiteforwarding = 0
if(WebsiteForwarding == 'Tidak') :
websiteforwarding = 0
statusbarcust = -1
if(StatusBarCust == 'YA') :
statusbarcust =1
disablerightclick = -1
if(DisableRightClick == 'YA') :
disablerightclick =1
usingpopupwindow = -1
if(UsingPopupWindow == 'YA') :
usingpopupwindow =1
iframeredirection = -1
if(IframeRedirection == 'YA') :
iframeredirection =1
ageofdomain = -1
if(AgeofDomain == 'YA') :
ageofdomain =1
dnsrecording = -1
if(DNSRecording == 'YA') :
dnsrecording =1
websitetraffic = -1
if(WebsiteTraffic == 'YA') :
websitetraffic =1
pagerank= -1
if(PageRank== 'YA') :
pagerank =1
googleindex = -1
if(GoogleIndex == 'YA') :
googleindex =1
linkspointingtopage= -1
if(LinksPointingToPage== 'YA') :
linkspointingtopage =1
statsreport= -1
if(StatsReport== 'YA') :
statsreport =1
#data = {'phishingYT':[phishingYT01],
data = {
'UsingIP':[usingip],
'LongURL':[longurl],
'ShortURL':[shorturl],
'Symbol@':[symbol],
'Redirecting//':[redirecting],
'SubDomains':[subdomains],
'PrefixSuffix-':[prefixsuffix],
'HTTPS':[https],
'DomainRegLen':[domainreglen],
'Favicon':[favicon],
'NonStdPort':[nonstdport],
'HTTPSDomainURL':[httpsdomainurl],
'RequestURL':[requesturl],
'AnchorURL':[anchorurl],
'LinksInScriptTags':[linksinscripttags],
'ServerFormHandler':[serverformhandler ],
'InfoEmail':[infoemail],
'AbnormalURL':[abnormalurl],
'WebsiteForwarding':[websiteforwarding],
'StatusBarCust':[statusbarcust],
'DisableRightClick':[disablerightclick],
'UsingPopupWindow':[usingpopupwindow],
'IframeRedirection':[iframeredirection],
'AgeofDomain':[ageofdomain],
'DNSRecording':[dnsrecording],
'WebsiteTraffic':[websitetraffic],
'PageRank':[pagerank],
'GoogleIndex':[googleindex],
'LinksPointingToPage':[linkspointingtopage],
'StatsReport':[statsreport]}
features = pd.DataFrame(data)
return features
input_df = user_input_features()
phishing_raw = pd.read_csv('phishing.csv')
phishing_raw.fillna(0, inplace=True)
phishing = phishing_raw.drop(columns=['class'])
df = pd.concat([input_df, phishing],axis=0)
df = df[:1] # Selects only the first row (the user input data)
df.fillna(0, inplace=True)
features = ['UsingIP', 'LongURL', 'ShortURL', 'Symbol@', 'Redirecting//',
'PrefixSuffix-', 'SubDomains', 'HTTPS', 'DomainRegLen', 'Favicon',
'NonStdPort', 'HTTPSDomainURL', 'RequestURL', 'AnchorURL',
'LinksInScriptTags', 'ServerFormHandler', 'InfoEmail', 'AbnormalURL',
'WebsiteForwarding', 'StatusBarCust', 'DisableRightClick',
'UsingPopupWindow', 'IframeRedirection', 'AgeofDomain', 'DNSRecording',
'WebsiteTraffic', 'PageRank', 'GoogleIndex', 'LinksPointingToPage',
'StatsReport']
df = df[features]
st.subheader('User Input features')
st.write(df)
load_clf = pickle.load(open('PhishingDETECT_clf.pkl', 'rb'))
detection = load_clf.predict(df)
if(detection < 0) :
detection = 0
detection_proba = load_clf.predict_proba(df)
phishing_labels = np.array(['Normal', 'Phishing'])
st.subheader('Detection')
st.write(phishing_labels[detection])
st.subheader('Detection Probability')
df_prob = pd.DataFrame(data=detection_proba, index=['Probability'], columns=phishing_labels)
st.write(df_prob) |