Exemplo n.º 1
0
def check(url, clf):
    # url=sys.argv[1]
    fT = time.time()
    features_test = features_extraction.main(url)
    feT = time.time()
    features_test = np.array(features_test).reshape((1, -1))
    prT = time.time()
    pred = clf.predict(features_test)
    #     prob=clf.predict_proba(features_test)
    preT = time.time()

    #     pred=[1]
    print("\n")
    print("Feature extraction Time = " + str(feT - fT))
    print("Prediction Time = " + str(preT - prT))
    print("Total Time = " + str(preT - fT))
    print("\n")

    if int(pred[0]) == 1:
        print(url)
        print("This is a safe website.")
        return False
        # return str(url)+" is a safe website."

    elif int(pred[0]) == -1:
        print(url)
        print("This is a phishing website..!")
        return True
Exemplo n.º 2
0
def check_website(request):
    """

    """
    # import ipdb; ipdb.set_trace()

    url = request.GET.get('url')
    #url='https://www.google.com/'
    features_test = features_extraction.main(url)
    # Due to updates to scikit-learn, we now need a 2D array as a parameter to the predict function.
    features_test = np.array(features_test).reshape((1, -1))
    # import ipdb; ipdb.set_trace()
    clf = joblib.load(os.getcwd() + '/backend/classifier/random_forest.pkl')

    pred = clf.predict(features_test)

    # Print the probability of prediction (if needed)
    # prob = clf.predict_proba(features_test)
    # print 'Features=', features_test, 'The predicted probability is - ', prob, 'The predicted label is - ', pred
    #    print "The probability of this site being a phishing website is ", features_test[0]*100, "%"

    if int(pred[0]) == 1:
        # print "The website is safe to browse"
        print("SAFE")
        return HttpResponse("SAFE")
    elif int(pred[0]) == -1:
        print(" PHISING")
        # print "The website has phishing features. DO NOT VISIT!"
        return HttpResponse('Phising')
Exemplo n.º 3
0
def main(url):
    #url = sys.argv[1]

    features_test = features_extraction.main(url)
    # Due to updates to scikit-learn, we now need a 2D array as a parameter to the predict function.
    features_test = np.array(features_test).reshape((1, -1))

    clf = joblib.load('classifier/random_forest.pkl')

    pred = clf.predict(features_test)

    # Print the probability of prediction (if needed)
    # prob = clf.predict_proba(features_test)
    # print 'Features=', features_test, 'The predicted probability is - ', prob, 'The predicted label is - ', pred
    #    print "The probability of this site being a phishing website is ", features_test[0]*100, "%"

    if int(pred[0]) == 1:
        # print "The website is safe to browse"
        print("SAFE")
        return "SAFE"
        
    elif int(pred[0]) == -1:
        # print "The website has phishing features. DO NOT VISIT!"
        print("PHISHING")
        return "MALICIOUS"
Exemplo n.º 4
0
def get_prediction_from_url(test_url):
    features_test = features_extraction.main(test_url)
    # Due to updates to scikit-learn, we now need a 2D array as a parameter to the predict function.
    features_test = np.array(features_test).reshape((1, -1))

    clf = joblib.load(LOCALHOST_PATH + DIRECTORY_NAME +
                      '/classifier/random_forest.pkl')
    print(clf)
Exemplo n.º 5
0
def get_prediction_from_url(test_url,html):
    features_test = features_extraction.main(test_url,html)
    features_test = np.array(features_test).reshape((1, -1))
    #localPath = os.getcwd()
    clf = joblib.load(WORKING_PATH  + '/classifier/random_forest1.pkl')

    pred = clf.predict(features_test)
    return int(pred[0])
Exemplo n.º 6
0
def get_prediction_from_url(test_url):
    features_test = features_extraction.main(test_url)
    features_test = np.array(features_test).reshape((1, -1))

    clf = joblib.load(LOCALHOST_PATH + DIRECTORY_NAME +
                      '/classifier/random_forest.pkl')

    pred = clf.predict(features_test)
    return int(pred[0])
def get_prediction_from_url(test_url):
    features_test = features_extraction.main(test_url)
    # we now need a 2D array as a parameter to the predict function.
    features_test = np.array(features_test).reshape((1, -1))

    clf = joblib.load(LOCALHOST_PATH + '/classifier/finalized_model.sav')

    pred = clf.predict(features_test)
    return int(pred[0])
Exemplo n.º 8
0
def predict(test_url):
    features_test = features_extraction.main(test_url)
    features_test = np.array(features_test).reshape((1, -1))

    clf = joblib.load(MODEL_PATH)

    pred = clf.predict(features_test)
    print(test_url)
    print(pred)
    return int(pred[0])
Exemplo n.º 9
0
def main():
    url = "http://www.spit.ac.in"

    features_test = features_extraction.main(url)
    clf = joblib.load('classifier/extratree.pkl')
    features_test = [features_test]
    pred = clf.predict(features_test)
    prob = clf.predict_proba(features_test)
    # print 'Features=', features_test, 'The predicted probability is - ', prob, 'The predicted label is - ', pred
    #    print "The probability of this site being a phishing website is ", features_test[0]*100, "%"

    if int(pred[0]) == 1:
        # print "The website is safe to browse"
        print("SAFE")
    elif int(pred[0]) == -1:
        # print "The website has phishing features. DO NOT VISIT!"
        print("PHISHING")
def main():
    url = sys.argv[1]

    features_test = features_extraction.main(url)

    clf = joblib.load('classifier/random_forest.pkl')

    pred = clf.predict(features_test)
    prob = clf.predict_proba(features_test)
    # print 'Features=', features_test, 'The predicted probability is - ', prob, 'The predicted label is - ', pred
    #    print "The probability of this site being a phishing website is ", features_test[0]*100, "%"

    if int(pred[0]) == 1:
        # print "The website is safe to browse"
        print "SAFE"
    elif int(pred[0]) == -1:
        # print "The website has phishing features. DO NOT VISIT!"
        print "PHISHING"
Exemplo n.º 11
0
def main():
    url = sys.argv[1]
    features_test = features_extraction.main(url)
    # 2d array per scikit-learn
    features_test = np.array(features_test).reshape((1, -1))
    clf = joblib.load(LOCALHOST_PATH + DIRECTORY_NAME +
                      '/classifier/random_forest_new_4.pkl')
    prediction = clf.predict(features_test)
    prediction_int = int(prediction[0])
    probability = clf.predict_proba(features_test)
    respond_data = {
        "features": features_test.tolist(),
        "probability": probability.tolist(),
        "prediction": prediction_int,
        "url": url
    }
    json_respond_data = json.dumps(respond_data)
    print(json_respond_data)
Exemplo n.º 12
0
def main():
    url = sys.argv[1]
    #url='https://www.google.com/'
    features_test = features_extraction.main(url)
    # Due to updates to scikit-learn, we now need a 2D array as a parameter to the predict function.
    features_test = np.array(features_test).reshape((1, -1))

    clf = joblib.load(
        'C://xampp//htdocs//webc3//classifier//random_forest.pkl')

    pred = clf.predict(features_test)

    # Print the probability of prediction (if needed)
    # prob = clf.predict_proba(features_test)
    # print 'Features=', features_test, 'The predicted probability is - ', prob, 'The predicted label is - ', pred
    #    print "The probability of this site being a phishing website is ", features_test[0]*100, "%"

    if int(pred[0]) == 1:
        # print "The website is safe to browse"
        print("SAFE")
    elif int(pred[0]) == -1:
        # print "The website has phishing features. DO NOT VISIT!"
        print("PHishing")