钓鱼网站检测 repo复现
寫在前面
糾結要起個什么樣的文章標題…這篇帖子不會寫的太硬核,就是想稍微理一下我自己的思路。
最近看了入侵檢測和釣魚檢測的論文。入侵檢測給我的感覺是系統太大了,而且從199幾年就開始用機器學習做了??我的天哪…加上聽另外一個同學說這個方向都被做爛了,覺得很有道理。看了幾天論文之后,在打算復現論文時候因為沒有找到打標簽的數據集,就順理成章地先把這個方向放下了。草率如我:)
釣魚網站/郵件檢測沒看多少,emm…不過至少這個方向應該是比入侵檢測做的人少的…而且感覺上這個小一點,看論文里說應該是數據集是比較好找的,而且不會像入侵檢測的數據集那么老,都是上個世紀的??
在Github上找到一個倉庫,是論文的復現(雖然那個論文質量不是很好?),就大概看了一下,簡單復現了一下。
https://github.com/rohitnaik246/Malicious-Web-Content-Detection-Using-Machine-Learning
論文內容
論文用了UCI中的釣魚網站數據集。數據集是以arff的格式給出來的,在文件里介紹了涉及到的字段。
使用的分類器是隨機森林。在數據集給出的特征中選擇了部分(手動)。最后論文的結果是以Chrome擴展的形式展現的。就是當用戶訪問一個網址時候,會通過擴展來檢查一下,這個網址的特征是通過repo中的feature_extraction.py文件提取的。
整體思路很簡單,因為沒有真正用機器學習寫過程序,所以就復現一下感受一波。
# test.py import numpy from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score, classification_report import jobliblables = [] file = open("Training Dataset.arff").read() data_list = file.split('\r\n') data = numpy.array(data_list) data1 = [i.split(',') for i in data] data1 = data1[0 : -1] # ? what's the meaning? seems meaningless for i in data1:lables.append(i[30]) data1 = numpy.array(data1) features = data1[:, :-1]features = features[:, [0, 1, 2, 3, 4, 5, 6, 8, 9, 11, 12, 13, 14, 15, 16, 17, 22, 23, 24, 25, 27, 29]] features = numpy.array(features).astype(numpy.float)features_test = features[10000:] lables_test = lables[10000:]clf = joblib.load('random_forest.pkl')whole = len(features_test) i = 0 right_count = 0 pred = clf.predict(features_test) print 'The accuracy is:', accuracy_score(lables_test, pred)訓練的代碼和repo里一樣,測試的話就用了訓練集中第10000個數據后面的1000多個數據。測試結果96%多的準確率。
之后
(當然這都是我自己的計劃,還沒有跟老師討論,不知道這個方向是否ok?)
數據集中的30個特征
@attribute having_IP_Address { -1,1 } --> 使用ip地址(可能是16進制表示的)而不是域名進行訪問的url @attribute URL_Length { 1,0,-1 } --> url的長度,該數據集認為url長度大于54則是釣魚網站(因為太長可能是被用來隱藏真正的惡意部分) @attribute Shortining_Service { 1,-1 } --> 是否使用了短網址服務,可以參考:https://www.jianshu.com/p/43eea66a2235 @attribute having_At_Symbol { 1,-1 } --> url中是否包含"@"(@字符前的所有內容都會被忽略,用以隱藏后面的真正惡意部分) @attribute double_slash_redirecting { -1,1 } --> url中是否有"//",這個在瀏覽器中測試了一下并沒有重定向 @attribute Prefix_Suffix { -1,1 } --> url的域名部分是否有"-" @attribute having_Sub_Domain { -1,0,1 } --> 域名部分中"."的個數 @attribute SSLfinal_State { -1,1,0 } --> 是否使用了HTTPS @attribute Domain_registeration_length { -1,1 } --> 域名注冊時長 @attribute Favicon { 1,-1 } --> 是否從其他域名下引入圖標 @attribute port { 1,-1 } --> 端口打開情況 @attribute HTTPS_token { -1,1 } --> url的域名部分是否包含"https" @attribute Request_URL { 1,-1 } --> 請求其他域下url的比例 @attribute URL_of_Anchor { -1,0,1 } --> a標簽的鏈接 @attribute Links_in_tags { 1,-1,0 } --> <Meta>, <Script> 和<Link>標簽中的鏈接 @attribute SFH { -1,1,0 } --> 應該是表格提交的url @attribute Submitting_to_email { -1,1 } --> 是否將用戶輸入的頁面信息通過郵件轉發 @attribute Abnormal_URL { -1,1 } --> host name是否包含在url中(要從whois中解析) @attribute Redirect { 0,1 } --> 重定向次數 @attribute on_mouseover { 1,-1 } --> 判斷mouseover事件是否修改了status bar @attribute RightClick { 1,-1 } --> 是否禁止了鼠標右鍵 @attribute popUpWidnow { 1,-1 } --> 是否在彈框中輸入用戶信息 @attribute Iframe { 1,-1 } --> 是否使用iframe @attribute age_of_domain { -1,1 } --> 域名使用了多久 @attribute DNSRecord { -1,1 } --> 域名有無DNS記錄 @attribute web_traffic { -1,0,1 } --> Alexa排名 @attribute Page_Rank { -1,1 } --> PageRank @attribute Google_Index { 1,-1 } --> Google Index @attribute Links_pointing_to_page { 1,0,-1 } --> 指向該頁面的網頁數量 @attribute Statistical_report { -1,1 } --> 是否在像PhishTank這樣的釣魚網站數據庫中其中有一些感覺很草率…還是說機器學習的數據集就是這樣定義的??
比如:SSLfinal_State,有很多網站是正常網站,但是并沒有使用https…
還有url長度…
還有//,測試發現https://www.baidu.com//https://mgtv.com這樣形式的url會導致重定向到https://mgtv.com…
2019.05.15更新
最近看了兩篇和釣魚檢測相關的碩士論文…整理一些內容吧。
用到的特征集合
emm…先在本地整理一波。再上傳吧。
釣魚相關網站和組織
總結
以上是生活随笔為你收集整理的钓鱼网站检测 repo复现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python WIFI密码破解程序
- 下一篇: 用springboot jpa 报:No