Spaces:
Runtime error
Runtime error
Upload 8 files
Browse files- PhishingDETECT_clf.pkl +3 -0
- Procfile +1 -0
- app.py +221 -0
- phishing.csv +0 -0
- requirements.txt +6 -0
- setup.sh +13 -0
PhishingDETECT_clf.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8b8004814e65f5c160eede9f3f64f2c44b4931442bebacde0dd7ab777386424c
|
| 3 |
+
size 10866069
|
Procfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
web: sh setup.sh && streamlit run app.py
|
app.py
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pickle
|
| 5 |
+
import base64
|
| 6 |
+
import seaborn as sns
|
| 7 |
+
import matplotlib.pyplot as plt
|
| 8 |
+
|
| 9 |
+
import symbol
|
| 10 |
+
|
| 11 |
+
st.write("""
|
| 12 |
+
# WebPhishing Detection App
|
| 13 |
+
|
| 14 |
+
WebPhishing Detection App adalah sebuah aplikasi untuk mendeteksi sebuah Phishing pada situs web.
|
| 15 |
+
Aplikasi ini menggunakan berbagai macam paramater untuk menujukan bahwa situs Phishing atau Normal
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
""")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
url_dataset = f'<a href="phishing.csv">Download Dataset CSV File</a>'
|
| 22 |
+
st.markdown(url_dataset, unsafe_allow_html=True)
|
| 23 |
+
|
| 24 |
+
def user_input_features() :
|
| 25 |
+
UsingIP = st.sidebar.selectbox('UsingIP', ('YA', 'Tidak'))
|
| 26 |
+
LongURL = st.sidebar.selectbox('LongURL', ('YA', 'Tidak'))
|
| 27 |
+
ShortURL = st.sidebar.selectbox('Short URL', ('YA', 'Tidak'))
|
| 28 |
+
Symbol = st.sidebar.selectbox('Symbol', ('YA', 'Tidak'))
|
| 29 |
+
Redirecting = st.sidebar.selectbox('Redirecting', ('YA', 'Tidak'))
|
| 30 |
+
PrefixSuffix = st.sidebar.selectbox('PrefixSuffix', ('YA', 'Tidak'))
|
| 31 |
+
SubDomains = st.sidebar.selectbox('SubDomains', ('YA', 'Tidak'))
|
| 32 |
+
HTTPS = st.sidebar.selectbox('HTTPS', ('YA', 'Tidak'))
|
| 33 |
+
DomainRegLen = st.sidebar.selectbox('DomainRegLen', ('YA', 'Tidak'))
|
| 34 |
+
Favicon = st.sidebar.selectbox('Favicon', ('YA', 'Tidak'))
|
| 35 |
+
NonStdPort = st.sidebar.selectbox('NonStdPort', ('YA', 'Tidak'))
|
| 36 |
+
HTTPSDomainURL = st.sidebar.selectbox('HTTPSDomainURL', ('YA', 'Tidak'))
|
| 37 |
+
RequestURL = st.sidebar.selectbox('RequestURL', ('YA', 'Tidak'))
|
| 38 |
+
AnchorURL = st.sidebar.selectbox('AnchorURL', ('YA', 'Tidak'))
|
| 39 |
+
LinksInScriptTags = st.sidebar.selectbox('LinksInScriptTags', ('YA', 'Tidak'))
|
| 40 |
+
ServerFormHandler = st.sidebar.selectbox('ServerFormHandler', ('YA', 'Tidak'))
|
| 41 |
+
InfoEmail = st.sidebar.selectbox('InfoEmail', ('YA', 'Tidak'))
|
| 42 |
+
AbnormalURL = st.sidebar.selectbox('AbnormalURL', ('YA', 'Tidak'))
|
| 43 |
+
WebsiteForwarding = st.sidebar.selectbox('WebsiteForwarding', ('YA', 'Tidak'))
|
| 44 |
+
StatusBarCust = st.sidebar.selectbox('StatusBarCust', ('YA', 'Tidak'))
|
| 45 |
+
DisableRightClick = st.sidebar.selectbox('DisableRightClick', ('YA', 'Tidak'))
|
| 46 |
+
UsingPopupWindow = st.sidebar.selectbox('UsingPopupWindow', ('YA', 'Tidak'))
|
| 47 |
+
IframeRedirection = st.sidebar.selectbox('IframeRedirection', ('YA', 'Tidak'))
|
| 48 |
+
AgeofDomain = st.sidebar.selectbox('AgeofDomain', ('YA', 'Tidak'))
|
| 49 |
+
DNSRecording = st.sidebar.selectbox('DNSRecording', ('YA', 'Tidak'))
|
| 50 |
+
WebsiteTraffic = st.sidebar.selectbox('WebsiteTraffic', ('YA', 'Tidak'))
|
| 51 |
+
PageRank = st.sidebar.selectbox('PageRank', ('YA', 'Tidak'))
|
| 52 |
+
GoogleIndex = st.sidebar.selectbox('GoogleIndex', ('YA', 'Tidak'))
|
| 53 |
+
LinksPointingToPage = st.sidebar.selectbox('LinksPointingToPage', ('YA', 'Tidak'))
|
| 54 |
+
StatsReport = st.sidebar.selectbox('StatsReport', ('YA', 'Tidak'))
|
| 55 |
+
|
| 56 |
+
# phishingYT01 = 1
|
| 57 |
+
#if(phishingYT == 'Left') :
|
| 58 |
+
#phishingYT01 = 0
|
| 59 |
+
|
| 60 |
+
usingip = -1
|
| 61 |
+
if(UsingIP == 'YA') :
|
| 62 |
+
usingip = 1
|
| 63 |
+
longurl = -1
|
| 64 |
+
if(LongURL == 'YA') :
|
| 65 |
+
longurl =1
|
| 66 |
+
shorturl = -1
|
| 67 |
+
if(ShortURL == 'YA') :
|
| 68 |
+
shorturl =1
|
| 69 |
+
symbol = -1
|
| 70 |
+
if(Symbol == 'YA') :
|
| 71 |
+
symbol =1
|
| 72 |
+
redirecting = -1
|
| 73 |
+
if(Redirecting == 'YA') :
|
| 74 |
+
redirecting =1
|
| 75 |
+
subdomains = -1
|
| 76 |
+
if(SubDomains == 'YA') :
|
| 77 |
+
subdomains =1
|
| 78 |
+
prefixsuffix = -1
|
| 79 |
+
if(PrefixSuffix == 'YA') :
|
| 80 |
+
prefixsuffix =1
|
| 81 |
+
https = -1
|
| 82 |
+
if(HTTPS == 'YA') :
|
| 83 |
+
https =1
|
| 84 |
+
domainreglen = -1
|
| 85 |
+
if(DomainRegLen == 'YA') :
|
| 86 |
+
domainreglen =1
|
| 87 |
+
favicon = -1
|
| 88 |
+
if(Favicon == 'YA') :
|
| 89 |
+
favicon =1
|
| 90 |
+
nonstdport = -1
|
| 91 |
+
if(NonStdPort == 'YA') :
|
| 92 |
+
nonstdport =1
|
| 93 |
+
httpsdomainurl = -1
|
| 94 |
+
if(HTTPSDomainURL == 'YA') :
|
| 95 |
+
httpsdomainurl =1
|
| 96 |
+
requesturl = -1
|
| 97 |
+
if(RequestURL == 'YA') :
|
| 98 |
+
requesturl =1
|
| 99 |
+
anchorurl = -1
|
| 100 |
+
if(AnchorURL == 'YA') :
|
| 101 |
+
anchorurl =1
|
| 102 |
+
linksinscripttags = -1
|
| 103 |
+
if(LinksInScriptTags == 'YA') :
|
| 104 |
+
linksinscripttags =1
|
| 105 |
+
serverformhandler = -1
|
| 106 |
+
if(ServerFormHandler == 'YA') :
|
| 107 |
+
serverformhandler =1
|
| 108 |
+
infoemail = -1
|
| 109 |
+
if(InfoEmail == 'YA') :
|
| 110 |
+
infoemail =1
|
| 111 |
+
abnormalurl = -1
|
| 112 |
+
if(AbnormalURL == 'YA') :
|
| 113 |
+
abnormalurl =1
|
| 114 |
+
websiteforwarding = 0
|
| 115 |
+
if(WebsiteForwarding == 'Tidak') :
|
| 116 |
+
websiteforwarding = 0
|
| 117 |
+
statusbarcust = -1
|
| 118 |
+
if(StatusBarCust == 'YA') :
|
| 119 |
+
statusbarcust =1
|
| 120 |
+
disablerightclick = -1
|
| 121 |
+
if(DisableRightClick == 'YA') :
|
| 122 |
+
disablerightclick =1
|
| 123 |
+
usingpopupwindow = -1
|
| 124 |
+
if(UsingPopupWindow == 'YA') :
|
| 125 |
+
usingpopupwindow =1
|
| 126 |
+
iframeredirection = -1
|
| 127 |
+
if(IframeRedirection == 'YA') :
|
| 128 |
+
iframeredirection =1
|
| 129 |
+
ageofdomain = -1
|
| 130 |
+
if(AgeofDomain == 'YA') :
|
| 131 |
+
ageofdomain =1
|
| 132 |
+
dnsrecording = -1
|
| 133 |
+
if(DNSRecording == 'YA') :
|
| 134 |
+
dnsrecording =1
|
| 135 |
+
websitetraffic = -1
|
| 136 |
+
if(WebsiteTraffic == 'YA') :
|
| 137 |
+
websitetraffic =1
|
| 138 |
+
pagerank= -1
|
| 139 |
+
if(PageRank== 'YA') :
|
| 140 |
+
pagerank =1
|
| 141 |
+
googleindex = -1
|
| 142 |
+
if(GoogleIndex == 'YA') :
|
| 143 |
+
googleindex =1
|
| 144 |
+
linkspointingtopage= -1
|
| 145 |
+
if(LinksPointingToPage== 'YA') :
|
| 146 |
+
linkspointingtopage =1
|
| 147 |
+
statsreport= -1
|
| 148 |
+
if(StatsReport== 'YA') :
|
| 149 |
+
statsreport =1
|
| 150 |
+
|
| 151 |
+
#data = {'phishingYT':[phishingYT01],
|
| 152 |
+
|
| 153 |
+
data = {
|
| 154 |
+
'UsingIP':[usingip],
|
| 155 |
+
'LongURL':[longurl],
|
| 156 |
+
'ShortURL':[shorturl],
|
| 157 |
+
'Symbol@':[symbol],
|
| 158 |
+
'Redirecting//':[redirecting],
|
| 159 |
+
'SubDomains':[subdomains],
|
| 160 |
+
'PrefixSuffix-':[prefixsuffix],
|
| 161 |
+
'HTTPS':[https],
|
| 162 |
+
'DomainRegLen':[domainreglen],
|
| 163 |
+
'Favicon':[favicon],
|
| 164 |
+
'NonStdPort':[nonstdport],
|
| 165 |
+
'HTTPSDomainURL':[httpsdomainurl],
|
| 166 |
+
'RequestURL':[requesturl],
|
| 167 |
+
'AnchorURL':[anchorurl],
|
| 168 |
+
'LinksInScriptTags':[linksinscripttags],
|
| 169 |
+
'ServerFormHandler':[serverformhandler ],
|
| 170 |
+
'InfoEmail':[infoemail],
|
| 171 |
+
'AbnormalURL':[abnormalurl],
|
| 172 |
+
'WebsiteForwarding':[websiteforwarding],
|
| 173 |
+
'StatusBarCust':[statusbarcust],
|
| 174 |
+
'DisableRightClick':[disablerightclick],
|
| 175 |
+
'UsingPopupWindow':[usingpopupwindow],
|
| 176 |
+
'IframeRedirection':[iframeredirection],
|
| 177 |
+
'AgeofDomain':[ageofdomain],
|
| 178 |
+
'DNSRecording':[dnsrecording],
|
| 179 |
+
'WebsiteTraffic':[websitetraffic],
|
| 180 |
+
'PageRank':[pagerank],
|
| 181 |
+
'GoogleIndex':[googleindex],
|
| 182 |
+
'LinksPointingToPage':[linkspointingtopage],
|
| 183 |
+
'StatsReport':[statsreport]}
|
| 184 |
+
|
| 185 |
+
features = pd.DataFrame(data)
|
| 186 |
+
return features
|
| 187 |
+
|
| 188 |
+
input_df = user_input_features()
|
| 189 |
+
|
| 190 |
+
phishing_raw = pd.read_csv('phishing.csv')
|
| 191 |
+
phishing_raw.fillna(0, inplace=True)
|
| 192 |
+
phishing = phishing_raw.drop(columns=['class'])
|
| 193 |
+
df = pd.concat([input_df, phishing],axis=0)
|
| 194 |
+
|
| 195 |
+
df = df[:1] # Selects only the first row (the user input data)
|
| 196 |
+
df.fillna(0, inplace=True)
|
| 197 |
+
|
| 198 |
+
features = ['UsingIP', 'LongURL', 'ShortURL', 'Symbol@', 'Redirecting//',
|
| 199 |
+
'PrefixSuffix-', 'SubDomains', 'HTTPS', 'DomainRegLen', 'Favicon',
|
| 200 |
+
'NonStdPort', 'HTTPSDomainURL', 'RequestURL', 'AnchorURL',
|
| 201 |
+
'LinksInScriptTags', 'ServerFormHandler', 'InfoEmail', 'AbnormalURL',
|
| 202 |
+
'WebsiteForwarding', 'StatusBarCust', 'DisableRightClick',
|
| 203 |
+
'UsingPopupWindow', 'IframeRedirection', 'AgeofDomain', 'DNSRecording',
|
| 204 |
+
'WebsiteTraffic', 'PageRank', 'GoogleIndex', 'LinksPointingToPage',
|
| 205 |
+
'StatsReport']
|
| 206 |
+
|
| 207 |
+
df = df[features]
|
| 208 |
+
|
| 209 |
+
st.subheader('User Input features')
|
| 210 |
+
st.write(df)
|
| 211 |
+
load_clf = pickle.load(open('PhishingDETECT_clf.pkl', 'rb'))
|
| 212 |
+
detection = load_clf.predict(df)
|
| 213 |
+
if(detection < 0) :
|
| 214 |
+
detection = 0
|
| 215 |
+
detection_proba = load_clf.predict_proba(df)
|
| 216 |
+
phishing_labels = np.array(['Normal', 'Phishing'])
|
| 217 |
+
st.subheader('Detection')
|
| 218 |
+
st.write(phishing_labels[detection])
|
| 219 |
+
st.subheader('Detection Probability')
|
| 220 |
+
df_prob = pd.DataFrame(data=detection_proba, index=['Probability'], columns=phishing_labels)
|
| 221 |
+
st.write(df_prob)
|
phishing.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
matplotlib==3.4.3
|
| 2 |
+
numpy==1.20.3
|
| 3 |
+
pandas==1.3.4
|
| 4 |
+
seaborn==0.11.2
|
| 5 |
+
streamlit==1.11.0
|
| 6 |
+
sklearn
|
setup.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mkdir -p ~/.streamlit/
|
| 2 |
+
|
| 3 |
+
echo "\
|
| 4 |
+
[general]\n\
|
| 5 |
+
email = \"your-email@domain.com\"\n\
|
| 6 |
+
" > ~/.streamlit/credentials.toml
|
| 7 |
+
|
| 8 |
+
echo "\
|
| 9 |
+
[server]\n\
|
| 10 |
+
headless = true\n\
|
| 11 |
+
enableCORS=false\n\
|
| 12 |
+
port = $PORT\n\
|
| 13 |
+
" > ~/.streamlit/config.toml
|