Esempio n. 1
0
 def OnPressEnter(self,event):
     # self.labelVariable.set( self.entryVariable.get()+" (You pressed ENTER)" )
     url = self.entryVariable.get()
     try:
         processed_url = process_url(url).values()
         (pred, conf) = self.voter.vote(processed_url)
         url_class = "Malicious" if pred == 1 else "Benign"
         self.labelVariable.set("URL Classified as {}, Confidence: {:.4f}%".format(url_class, conf * 100))
     except:
         self.labelVariable.set("Not a valid URL")
     self.entry.focus_set()
     self.entry.selection_range(0, Tkinter.END)
Esempio n. 2
0
def create_dataset(urls, label):
    X, y = [], []
    for url in urls:
        url_dict = process_url(url)
        values = []
        for value in url_dict.itervalues():
            values.append(value)
            # print value
            # print item.value
        X.append(values)
        y.append(label)
    return np.array(X), np.array(y)
Esempio n. 3
0
def create_dataset(urls, label):
    X, y = [], []
    for url in urls:
        url_dict = process_url(url)
        values = []
        for value in url_dict.itervalues():
            values.append(value)
            # print value
            # print item.value
        X.append(values)
        y.append(label)
    return np.array(X), np.array(y)
Esempio n. 4
0
 def OnPressEnter(self, event):
     # self.labelVariable.set( self.entryVariable.get()+" (You pressed ENTER)" )
     url = self.entryVariable.get()
     try:
         processed_url = process_url(url).values()
         (pred, conf) = self.voter.vote(processed_url)
         url_class = "Malicious" if pred == 1 else "Benign"
         self.labelVariable.set(
             "URL Classified as {}, Confidence: {:.4f}%".format(
                 url_class, conf * 100))
     except:
         self.labelVariable.set("Not a valid URL")
     self.entry.focus_set()
     self.entry.selection_range(0, Tkinter.END)
Esempio n. 5
0
    # train = dataset.from_npy(path, 'train.npy')
    # train_X, train_y = train[:, :-1], train[:, -1]
    # voter.fit(train_X, train_y)

    # save_voter(voter, path)

    voter = load_voter(path)
    test = dataset.from_npy(path, 'test.npy')
    test_X, test_y = test[:, :-1], test[:, -1]
    voter.confusion_matrix(test_X, test_y)

    # for clf in voter._classifiers:
    #     print type(clf).__name__
    #     cm = confusion_matrix(test_y, clf.predict(test_X))
    #     plot_confusion_matrix(cm)
    #     plt.draw()
    #
    test_urls = [
        'https://www.youtube.com/watch?v=4WM6hB7l4Lc&list=PLQVvvaa0QuDd0flgGphKCej-9jp-QdzZ3&index=12&feature=iv&src_vid=81ZGOib7DTk&annotation_id=annotation_1856532697',
        'http://ld.mediaget.com/index.php?l=ru&fu=http:/www.playground.ru/download/?cheat=grand_theft_auto_4_gta_iv_episodes_from_liberty_city_eflc_sohranenie_100-41709&r=playground.ru&f=grand_theft_auto_4_gta_iv_episodes_from_liberty_city_eflc__&%23x421;&%23x43e;&%23x445;&%23x440;&%23x430;&%23x43d;&%23x435;&%23x43d;&%23x438;&%23x435;_100%25',
        'https://raw.github.com/inquisb/shellcodeexec/master/windows/shellcodeexec.x32.exe',
        'http://www.ezthemes.com/site_advertisers/extrafindWD.exe'
    ]
    for test_url in test_urls:
        processed_url = process_url(test_url).values()
        print voter.vote(processed_url)
        # break
        # winner, conf = voter.vote(processed_url)
        # print 'Classification:', 'Malicious' if winner == 1 else 'Benign', 'Confidence:', conf * 100
    #
    # plt.show()
    #
    # train = dataset.from_npy(path, 'train.npy')
    # train_X, train_y = train[:, :-1], train[:, -1]
    # voter.fit(train_X, train_y)

    # save_voter(voter, path)

    voter = load_voter(path)
    test = dataset.from_npy(path, 'test.npy')
    test_X, test_y = test[:, :-1], test[:, -1]
    voter.confusion_matrix(test_X, test_y)

    # for clf in voter._classifiers:
    #     print type(clf).__name__
    #     cm = confusion_matrix(test_y, clf.predict(test_X))
    #     plot_confusion_matrix(cm)
    #     plt.draw()
    #
    test_urls = [
        'https://www.youtube.com/watch?v=4WM6hB7l4Lc&list=PLQVvvaa0QuDd0flgGphKCej-9jp-QdzZ3&index=12&feature=iv&src_vid=81ZGOib7DTk&annotation_id=annotation_1856532697',
        'http://ld.mediaget.com/index.php?l=ru&fu=http:/www.playground.ru/download/?cheat=grand_theft_auto_4_gta_iv_episodes_from_liberty_city_eflc_sohranenie_100-41709&r=playground.ru&f=grand_theft_auto_4_gta_iv_episodes_from_liberty_city_eflc__&%23x421;&%23x43e;&%23x445;&%23x440;&%23x430;&%23x43d;&%23x435;&%23x43d;&%23x438;&%23x435;_100%25',
        'https://raw.github.com/inquisb/shellcodeexec/master/windows/shellcodeexec.x32.exe',
        'http://www.ezthemes.com/site_advertisers/extrafindWD.exe']
    for test_url in test_urls:
        processed_url = process_url(test_url).values()
        print voter.vote(processed_url)
        # break
        # winner, conf = voter.vote(processed_url)
        # print 'Classification:', 'Malicious' if winner == 1 else 'Benign', 'Confidence:', conf * 100
    #
    # plt.show()