Malicious URL Detection Based On Machine Learning

Transcription

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 11, No. 1, 2020Malicious URL Detection based on Machine LearningCho Do Xuan1, Hoa Dinh Nguyen1Tisenko Victor Nikolaevich3Information Security dept, Posts and TelecommunicationsInstitute of Technology, Hanoi, Vietnam1, 2Information Assurance dept, FPT University, Hanoi,Vietnam1Systems of automatic DesignPeter the Great St. Petersburg Polytechnic UniversityRussia, St.PetersburgPolytechnicheskaya, 29Abstract—Currently, the risk of network informationinsecurity is increasing rapidly in number and level of danger.The methods mostly used by hackers today is to attack end-toend technology and exploit human vulnerabilities. Thesetechniques include social engineering, phishing, pharming, etc.One of the steps in conducting these attacks is to deceive userswith malicious Uniform Resource Locators (URLs). As a results,malicious URL detection is of great interest nowadays. Therehave been several scientific studies showing a number of methodsto detect malicious URLs based on machine learning and deeplearning techniques. In this paper, we propose a malicious URLdetection method using machine learning techniques based onour proposed URL behaviors and attributes. Moreover, bigdatatechnology is also exploited to improve the capability of detectionmalicious URLs based on abnormal behaviors. In short, theproposed detection system consists of a new set of URLs featuresand behaviors, a machine learning algorithm, and a bigdatatechnology. The experimental results show that the proposedURL attributes and behavior can help improve the ability todetect malicious URL significantly. This is suggested that theproposed system may be considered as an optimized and friendlyused solution for malicious URL detection.Keywords—URL; malicious URL detection; feature extraction;feature selection; machine learningI.INTRODUCTIONUniform Resource Locator (URL) is used to refer toresources on the Internet. In [1], Sahoo et al. presented aboutthe characteristics and two basic components of the URL as:protocol identifier, which indicates what protocol to use, andresource name, which specifies the IP address or the domainname where the resource is located. It can be seen that eachURL has a specific structure and format. Attackers often try tochange one or more components of the URL's structure todeceive users for spreading their malicious URL. MaliciousURLs are known as links that adversely affect users. TheseURLs will redirect users to resources or pages on whichattackers can execute codes on users' computers, redirect usersto unwanted sites, malicious website, or other phishing site, ormalware download. Malicious URLs can also be hidden indownload links that are deemed safe and can spread quicklythrough file and message sharing in shared networks. Someattack techniques that use malicious URLs include [2, 3, 4]:Drive-by Download, Phishing and Social Engineering, andSpam.According to statistics presented in [5], in 2019, the attacksusing spreading malicious URL technique are ranked firstamong the 10 most common attack techniques. Especially,according to this statistic, the three main URL spreadingtechniques, which are malicious URLs, botnet URLs, andphishing URLs, increase in number of attacks as well as dangerlevel.From the statistics of the increase in the number ofmalicious URL distributions over the consecutive years, it isclear that there is a need to study and apply techniques ormethods to detect and prevent these malicious URLs.Regarding the problem of detecting malicious URLs, thereare two main trends at present as malicious URL detectionbased on signs or sets of rules, and malicious URL detectionbased on behavior analysis techniques [1, 2]. The method ofdetecting malicious URLs based on a set of markers or rulescan quickly and accurately detect malicious URLs. However,this method is not capable of detecting new malicious URLsthat are not in the set of predefined signs or rules. The methodof detecting malicious URLs based on behavior analysistechniques adopt machine learning or deep learning algorithmsto classify URLs based on their behaviors. In this paper,machine learning algorithms are utilized to classify URLsbased on their attributes. The paper also includes a new URLattribute extraction method.In our research, machine learning algorithms are used toclassify URLs based on the features and behaviors of URLs.The features are extracted from static and dynamic behaviorsof URLs and are new to the literature. Those newly proposedfeatures are the main contribution of the research. Machinelearning algorithms are a part of the whole malicious URLdetection system. Two supervised machine learning algorithmsare used, Support vector machine (SVM) and Random forest(RF).The paper is organized as follows. Section II reviews somerecent works in the literature on malicious URL detection. Theproposed malicious URLs detection system using machinelearning is presented in Section III. In this section, the newfeatures for URLs detection process are also described indetails. Experimental results and discussions are provided inSection IV. The paper is concluded by Section V.II. RELATED WORKSA. Signature based Malicious URL DetectionStudies on malicious URL detection using the signaturesets had been investigated and applied long time ago [6, 7, 8].Most of these studies often use lists of known malicious URLs.Whenever a new URL is accessed, a database query is148 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 11, No. 1, 2020executed. If the URL is blacklisted, it is considered asmalicious, and then, a warning will be generated; otherwiseURLs will be considered as safe. The main disadvantage of thisapproach is that it will be very difficult to detect new maliciousURLs that are not in the given list.B. Machine Learning based Malicious URL DetectionThere are three types of machine learning algorithms thatcan be applied on malicious URL detection methods, includingsupervised learning, unsupervised learning, and semisupervised learning. And the detection methods are based onURL behaviors.In [1], a number of malicious URL systems based onmachine learning algorithms have been investigated. Thosemachine learing algorithms include SVM, Logistic Regression,Nave Bayes, Decision Trees, Ensembles, Online Learning, ect.In this paper, the two algorithms, RF and SVM, are used. Theaccuracy of these two algorithms with different parameterssetups will be presented in the experimental results.The behaviors and characteristics of URLs can be dividedinto two main groups, static and dynamic. In their studies [9,10, 11] authors presented methods of analyzing and extractingstatic behavior of URLs, including Lexical, Content, Host, andPopularity-based. The machine learning algorithms used inthese studies are Online Learning algorithms and SVM.Malicious URL detection using dynamic actions of URLs ispresented in [12, 13]. In this paper, URL attributes areextracted based on both static and dynamic behaviors. Someattribute groups are investigated, including Character andsemantic groups; Abnormal group in websites and Host-basedgroup; Correlated group.C. Malicious URL Detection Tools URL Void: URL Void is a URL checking programusing multiple engines and blacklists of domains. Someexamples of URL Void are Google SafeBrowsing,Norton SafeWeb and MyWOT. The advantage of theVoid URL tool is its compatibility with many differentbrowsers as well as it can support many other testingservices. The main disadvantage of the Void URL toolis that the malicious URL detection process reliesheavily on a given set of signatures. UnMask Parasites: Unmask Parasites is a URL testingtool by downloading provided links, parsing HypertextMarkup Language (HTML) codes, especially externallinks, iframes and JavaScript. The advantage of thistool is that it can detect iframe fast and accurately.However, this tool is only useful if the user hassuspected something strange happening on their sites. Dr.Web Anti-Virus Link Checker: Dr.Web Anti-VirusLink Checker is an add-on for Chrome, Firefox, Opera,and IE to automatically find and scan malicious contenton a download link on all social networking links suchas Facebook, Vk.com, Google . Comodo Site Inspector: This is a malware and securityhole detection tool. This helps users check URLs orenables webmasters to set up daily checks bydownloading all the specified sites. and run them in asandbox browser environment. Some other tools: Among aforementioned typical tools,there are some other URL checking tools, such asUnShorten.it, VirusTotal, Norton Safe Web,SiteAdvisor (by McAfee), Sucuri, Browser Defender,Online Link Scan, and Google Safe BrowsingDiagnostic.From the analysis and evaluation of malicious URLdetection tools presented above, it is found that the majority ofcurrent malicious URL detection tools are signature-basedURL detection systems. Therefore, the effectiveness of thesetools is limited.III. MALICIOUS URL DETECTING USING MACHINELEARNINGA. The ModelFig. 1 presents the proposed malicious URL detectionsystem using machine learning. The malicious URL detectionmodel using machine learning contains two stages: training anddetection. Training stage: To detect malicious URLs, it isnecessary to collect both malicious URLs and cleanURLs. Then, all the malicious and clean URLs arecorrectly labeled and proceeded to attribute extraction.These attributes will be the best basis for determiningwhich URLs are clean and which are malicious. Detailsof these attributes will be presented in details in thispaper. Finally, this dataset is divided into 2 subsets:training data used for training machine learningalgorithms, and testing data used for testing process. Ifthe classification performance of the machine learningmodel is good (high classification accuracy), the modelwill be used in the detection phase. Detection phase: The detection phase is performed oneach input URL. First, the URL will go throughattribute extraction process. Next, these attributes areinput to the classifier to classify whether the URL isclean or malicious.B. URL Attribute Extraction and SelectionIn [1], the authors listed some main attribute groups formalicious URL detection as follows.Lexical features: these features include URL length, maindomain length, maximum token domain length, path averagelength, average token length in domain.Host-based Features: these features are extracted from thehost characteristics of the URLs. These attributes indicate thelocation of malicious servers, the identity of malicious servers,the degree of impact of several host-based features thatcontribute the URL's malicious level.Content-based Features: these features are acquired when awhole web page is downloaded. The workload of these featuresis quite heavy, since a lot of information needs to be extracted,and there may be security concerns about accessing that URL.However, with more information available about a particular149 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 11, No. 1, 2020site, it is expected to create a better prediction model. Thecontent-based features of a website can be extracted primarilyfrom its HTML content and the use of JavaScript.Above are the three main attribute groups commonly usedby researchers to detect malicious URLs. However, each studyhas its own decision on suitable attributes and characteristicsfor each particular experimental dataset. In this paper, the useof all three attribute groups is recommended. However, in eachattribute group some new attributes and characteristics of theURL to optimize the ability to detect malicious URLs areproposed. The new attributes for malicious URL detection inthis research are listed in Tables I, II, and III.Detection stageTraining stageURLURLFeature extractionFeature extraction, LabelingClassificationMachine learningalgorithmTrainingSafe URLMalicious URLFig. 1. Malicious URL Detection Model using Machine Learning.TABLE. I.NoFeatureData typeDescription1NumDotsnumericNumber of character '.' in URL2SubdomainLevelnumericNumber of subdomain levels3PathLevelnumericThe depth of URL4UrlLengthnumericThe length of URL5NumDashnumericNumber of the dash character '-'6NumDashInHostnamenumericNumber of dash character in the hostname7AtSymbolbooleanThere exists a character '@' in URL8TildeSymbolbooleanThere exists a character ' ' in URL9NumUnderscorenumericNumber of the underscore character10NumPercentnumericNumber of the character '%'11NumQueryComponentsnumericNumber of the query components12NumAmpersandnumericNumber of the character '&'13NumHashnumericNumber of the character '#'NumNumericCharsnumericNumber of the numeric character15NoHttpsbooleanCheck if there exists a HTTPS in website URL16IpAddressbooleanCheck if the IP address is used in the hostname of the website URL17DomainInSubdomainsbooleanCheck if TLD or ccTLD is used as a part of the subdomain in website URL18DomainInPathsbooleanCheck if TLD or ccTLD is used in the link of website URL19HttpsInHostnamebooleanCheck if HTTPS is disordered in the hostname of website URL20HostnameLengthnumericLength of hostname21PathLengthnumericLength of the link path22QueryLengthnumericLength of the numeric25EmbeddedBrandNamebooleanThere exists a slash '//' in the link pathNumber of sensitive words (i.e., “secure”, “account”, “webscr”, “login”, “ebayisapi”,“sign in”, “banking”, “confirm”) in websiteThere exists a brand name in the domain26PctExtHyperlinks*floatThe percentage of external hyper links in the HTML source code of website14Feature groupLIST OF URL FEATURES IN LEXICAL FEATURE GROUPLexical group150 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 11, No. 1, 2020TABLE. II.NoFeatureData tion*booleanPercentage of URL external resource in HTML source codes of websiteCheck if favicon is installed from a hostname different from the URLhostname of websiteCheck if actions in the form containing the contend of URL without HTTPSprotocolCheck if the action form contains a relative URL31ExtFormAction*booleanCheck if the action form contains an external eanCheck if the action form contains an abnormal URL.Percentage of hyperlinks containing an empty value, an auto-redirectingvalue, such as “#”, URL of current website, or some abnormal values such as“file://E:/”Check if the most frequent hostname in the HTML source code does notmatch the URL of website.Check if HTML source code contains a JavaScript command on MouseOverto display a fake URL in the status barCheck if HTML source code contains a JavaScript command to turn off theright click of the mouseCheck if HTML source code contains a JavaScript command to start a popupwindowCheck if HTML source code contains “mailto” in the HTML39IframeOrFramebooleanCheck if iframe or frame is used in HTML source codes40MissingTitlebooleanCheck if the title tag is empty in HTML source codes41src eval cntintNumber of function eval () in HTML source codes42src escape cntintNumber of function escape () in HTML source codes43src exec cntsrc search cntintNumber of function exec() in HTML source codesintNumber of function search() HTML source codes45ImagesOnlyInForm*boolean46rank countryBooleanCheck if actions in the form of HTML source code does not contain text, butonly imagesCurrent country rank of website URL is in top 1 million of Alexa47rank hostBooleanThe rank of the host website URL is in top 1 million of Alexa48AgeDomainintThe age of domain since it is registered36Feature groupLIST OF URL FEATURE IN THE HOST-BASED FEATURE GROUPHost-basedfeature group44TABLE. III.NoFeatureData typeDescription49UrlLengthRT*-1, 0, 1Correlated length of URL50PctExtResourceUrlsRT*-1, 0, 1Correlated percentage of external URLAbnormalExtFormActionR*-1, 0, 1Correlated abnormal actions in formExtMetaScriptLinkRT*-1, 0, 1Correlated meta script link53SubdomainLevelRT*-1, 0, 1Correlated sub-domain level54PctExtNullSelfRedirectHyperlinksRT *-1, 0, 1Correlated null self-redirect hyperlinks5152Feature groupLIST OF URL FEATURES IN CORRELATED FEATURE GROUPcorrelatedfeature groupAll attributes marked “*” in Tables I, II, III are newlyextracted and selected in this research. Besides, in previousresearches, authors tend to use feature extraction and selectionmethod based on a group of predefined features. However,those recommended features are specialized and not popular.As a results, it is usually difficult to implement those featuresin other works, and to re-evaluate the detection performance ofthose features. In this work, we try to combine basic features toformulate new ones.C. Machine Learning Algorithm SelectionThe application of machine learning algorithms in detectingmalicious URLs has been studied and applied widely [1]. Inthis paper, two commonly used supervised machine learningalgorithms, RF and SVM [14, 15], are used.In this research, machine learning algorithms are the lastpuzzle to complete our proposed malicious URL detectionsystem. Those algorithms are suitable to utilized the usefulnessof our new features selected for malicious URL detection. Themachine learning algorithms are already well investigated inthe literature. In this work, SVM and RF are selected as anexample to illustrate the good performance of the wholedetection system, and are not our main focus. Readers areencouraged to implement some other algorithms such as NaïveBayes, Decision trees, k-nearest neighbors, neural networks,etc.In order to explore the effectiveness of using these twoalgorithms, different adjustments of parameters areimplemented.151 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 11, No. 1, 2020IV. EXPERIMENTAL RESULTSprecision A. Dataset and Experiment Environments1) Experiment dataset: The experimental dataset formalicious URL detection model includes: 470.000 URLscollected from [16, 17, 18, 19], of which about 70.000 URLsare malicious and 400.000 URLs are safe. All these URLs arechecked by Virus Total tool to verify the labels of each URL.The complete dataset is stored using CSV format. Each URLsample has a label "bad" for malicious and "good" for safe.Details of the data are as follows: Phishtank [16]: Phishtank is a service Websitededicated for sharing phishing URLs. Suspicious URLscan be sent to Phishtank for verification. The data inPhishtank is updated hourly. URLhaus [17]: URLhaus is a project from abuse.chaiming at sharing malicious URLs being used formalicious software distribution. Alexa [18]: Is a database ranking all websites accordingto their usefulness. Malicious n Non-Malicious URL [19]: is a data sourcewith more than 400,000 labeled URL. In this database,82% of all URLs are safe, while remaining 18% ofURLs are malicious.2) Experimental setup: The dataset of both safe andmalicious URLs mentioned above is divided into 2 subsets.About 80% of the dataset, 470.000 URLs (400.000 safe URLs,70.000 malicious URL), is used for training, and about 20% ofthe dataset, about 10.000 URLs (5.000 malicious URLs, 5.000safe URLs), is used for testing. The experiment is repeatedmany times with both SVM and RF algorithm. Differentparameter settings are used in different runs.3) Experiment dataset Setup environment: Python version 3.6; Spark version2.3.0; Hadoop version 2.7; Java (JDK) 8; Ubuntu 18.04. Hardware: RAM 16GB; Intel(R) Xeon(R) CPU E52640 v3 @ 2.60GHz.B. Results and Discussions1) Evaluation metrics: Accuracy: the percentage ofcorrect decisions among all testing samplesacc TP TN 100%TP TN FP FN(1)where: TP- True positive is the number of malicious URLscorrectly labeled; FN - False negative is the number ofmalicious URLs misclassified as safe; TN- True negative is thenumber of safe URL correctly labeled; FP - False positive isthe number of safe URLs misclassified as malicious.Confusion matrix: is a two-way Table IV representing howmany samples are classified into which label accordingly.Precision: is the percentage of malicious URLs correctlylabeled (TP) among all malicious URLs labeled by theclassifier (TP FP).TP 100%TP FP(2)Recall: is the percentage of malicious URLs correctlylabeled (TP) among all malicious URLs of the testing data(TP FN).Re call TP 100%TP FN(3)F1-score: is the harmonic mean of precision and recall.High F1 value means the classifier is good.F1 2 precision Re callprecision Re call(4)FPR (False prediction rate) is calculated as:FRP FP 100%FP TN(5)2) Results Training performanceTo evaluate the training performance of the machinelearning algorithm, both two data subsets are used individually.Each of these data subsets has different data size as well asdifferent distribution of data labels, which may result indifferent training performances. The results are presented inTable V.Experimental results show that the RF with 100 trees givesthe best predictive result. In return, the training time of the RFis slightly longer than SVM, but the testing time is not muchdifferent. The accuracy of the second dataset is reduced due tothe unbalance between safe and malicious URLs of the data.As expected, RF algorithm, with its fast speed and highaccuracy, is very suitable for classification problem. Besides,in our research, when machine learning algorithms arecombined with spark libraries, the training and testing time canbe reduced significantly. SparkML Machine Learning is alibrary package that provides and supports many machinelearning algorithms such as SVM, RF, Naïve Bayes,Regression, Clustering, Collaborative Filtering, . It is asuitable tool for applying machine learning algorithms withfast and accurate processing speed on large datasets. Testing results: In this paper, additional small testingdataset, with 107 safe URLs and 118 malicious URLs,is used to evaluate the performance of the best machinelearning algorithm discussed above, RF (100). Theresults are presented in Table VI.Confusion matrix parameters:12.037%; TN: 87.963%; FN: 7.826%TABLE. IV.TP:92.174%;FPR:CONFUSION MATRIXClassified malicious URLClassified safe URLReal malicious URLsTPFNReal safe URLsFPTN152 P a g ewww.ijacsa.thesai.org

(IJACSA) International Journal of Advanced Computer Science and Applications,Vol. 11, No. 1, 2020TABLE. V.Dataset10.000 URLs470.000 URLsTRAINING PERFORMANCE OF MALICIOUS URL DETECTION SYSTEMAlgorithm and parametersAccuracy (%)Precision (%)Recall (%)Training time (s)Testing time (s)SVM (100 iterations)93.3994.6792.512.320.01SVM (10 iterations)93.3594.8492.713.110.01RF (10 trees)99.1098.4397.452.780.01RF (100 trees)99.7798.7597.853.340.01SVM (100 iterations)90.7093.4388.45272.972.12SVM (10 iterations)91.0793.7588.85280.332.31RF (10 trees)95.4590.2195.12372.972.02RF (100 trees)96.2891.4494.42480.332.30TABLE. VI.Real safe URL (107)Real malicious URL (118)[7]TESTING RESULTSPredicted safeURL969Predicted malicious URL[8]11109V. CONCLUSIONS[9]In this paper, a method for malicious URL detection usingmachine learning is presented. The empirical results inTables V and VI have shown the effectiveness of the proposedextracted attributes. In this study, we do not use specialattributes, nor do we seek to create huge datasets to improvethe accuracy of the system as many other traditionalpublications. Here, the combination between easy-to-calculateattributes and big data processing technologies to ensure thebalance of the two factors is the processing time and accuracyof the system. The results of this research can be applied andimplemented in information security technologies ininformation security systems. The results of this article havebeen used to build a free tool [20] to detect malicious URLs onweb browsers.[1][2][3][4][5][6]REFERENCESD. Sahoo, C. Liu, S.C.H. Hoi, “Malicious URL Detection using MachineLearning: A Survey”. CoRR, abs/1701.07179, 2017.M. Khonji, Y. Iraqi, and A. Jones, “Phishing detection: a literaturesurvey,” IEEE Communications Surveys & Tutorials, vol. 15, no. 4, pp.2091–2121, 2013.M. Cova, C. Kruegel, and G. Vigna, “Detection and analysis of drivebydownload attacks and malicious javascript code,” in Proceedings of the19th international conference on World wide web. ACM, 2010, pp. 281–290.R. Heartfield and G. Loukas, “A taxonomy of attacks and a survey ofdefence mechanisms for semantic social engineering attacks,” ACMComputing Surveys (CSUR), vol. 48, no. 3, p. 37, /docs/reports/istr-242019-en.pdf [Last accessed 10/2019].S. Sheng, B. Wardman, G. Warner, L. F. Cranor, J. Hong, and C. Zhang,“An empirical analysis of phishing blacklists,” in Proceedings of SixthConference on Email and Anti-Spam (CEAS), . Seifert, I. Welch, and P. Komisarczuk, “Identification of maliciousweb pages with static heuristics,” in Telecommunication Networks andApplications Conference, 2008. ATNAC 2008. Australasian. IEEE,2008, pp. 91–96.S. Sinha, M. Bailey, and F. Jahanian, “Shades of grey: On theeffectiveness of reputation-based “blacklists”,” in Malicious andUnwanted Software, 2008. MALWARE 2008. 3rd InternationalConference on. IEEE, 2008, pp. 57–64.J. Ma, L. K. Saul, S. Savage, and G. M. Voelker, “Identifying suspiciousurls: an application of large-scale online learning,” in Proceedings of the26th Annual International Conference on Machine Learning. ACM,2009, pp. 681–688.B. Eshete, A. Villafiorita, and K. Weldemariam, “Binspect: Holisticanalysis and detection of malicious web pages,” in Security and Privacyin Communication Networks. Springer, 2013, pp. 149–166.S. Purkait, “Phishing counter measures and their effectiveness– literaturereview,” Information Management & Computer Security, vol. 20, no. 5,pp. 382–420, 2012.Y. Tao, “Suspicious url and device detection by log mining,” Ph.D.dissertation, Applied Sciences: School of Computing Science, 2014.G. Canfora, E. Medvet, F. Mercaldo, and C. A. Visaggio, “Detection ofmalicious web pages using system calls sequences,” in Availability,Reliability, and Security in Information Systems. Springer, 2014, pp.226–238.Leo Breiman.: Random Forests. Machine Learning 45 (1), pp. 5- 32,(2001).Thomas G. Dietterich. Ensemble Methods in Machine Learning.International Workshop on Multiple Classifier Systems, pp 1-15,Cagliari, Italy, 2000.Developer Information. https://www.phishtank.com/developer info.php.[Last accessed 11/2019].URLhaus Database Dump. https://urlhaus.abuse.ch/downloads/csv/.[Ngày truy nhập 11/2019].Dataset URL. http://downloads.majestic.com/majestic million.csv. [Lastaccessed 10/2019].Malicious n Non-MaliciousURL. csv. [Last accessed d/13G Ndr4hMFx qWyTEjHuOyJmHFWD0Gud/view?fbclid JADfli64-g. [Last accessed 12/2019].153 P a g ewww.ijacsa.thesai.org

browsers as well as it can support many other testing services. The main disadvantage of the Void URL tool is that the malicious URL detection process relies heavily on a given set of signatures. UnMask Parasites: Unmask Parasites is a URL testing tool by downloading provided links, parsing Hypertext