def phishng_detection(urlname): checkprediction = inputScript.main(urlname) prediction = classifier.predict(checkprediction) if (prediction == 1): return("URL may be a phishing attack!") else: return("URL seems safe")
def make_predict(): #error checking data = request.get_json(force=True) #extract url from request url_to_be_predicted = data['url'] url = str(url_to_be_predicted) #load the pickle file classifier = joblib.load('final_models/rf_final.pkl') #checking and predicting try: checkprediction = inputScript.main(url) prediction = int(classifier.predict(checkprediction)) print(prediction) result = {"prediction": prediction} except Exception as e: #print("Error") result = {"prediction": -9999} #print(prediction) #prediction = prediction + 1 return jsonify(result)
def send(): if (request.method == 'POST'): url = request.form['url'] cp = inputScript.main(url) pos = percentageSafety(cp) try: if (requests.get(url).status_code == 200): URLStatus = 'Online' else: URLStatus = 'Offline' except: URLStatus = "Unknown" GlobalRank, NationRank, NationName = pagerank(url) checkprediction = np.reshape(cp, (1, -1)) prediction = classifier.predict(checkprediction) if (prediction < -0.5): PTResult = "Safe" elif (prediction > 0.5): PTResult = "Unsafe" else: PTResult = "Suspicious" return render_template('result.html', URL=url, STATUS=URLStatus, PHISHSTATUS=PTResult, PercentageOfSafety=pos, GLOBALRANK=GlobalRank, NATIONNAME=NationName, NATIONRANK=NationRank) return render_template('index.html')
def start(x): # load the pickle file if x == '1': # Random Forest classifier = joblib.load('rf_final.pkl') elif x == '2': # SVM classifier = joblib.load('svm_final.pkl') elif x == '3': # LogisticRegression classifier = joblib.load('logisticR_final.pkl') else: print("Please choose a valid option") x = input( "Enter the method you want to use:\n1.RandomForest\n2.Support Vector Machine\n3.Logistic Regression\n" ) start(x) # input url url = input("Enter Website URL: ") # checking and predicting checkprediction = inputScript.main(url) prediction = classifier.predict(checkprediction) if prediction == 1: print("\nPhishing Website Detected\n") print("Can't open website") else: print("\nNo Phishing Website Detected\n") print("Opening Website..........") webbrowser.open_new(url) y = input("Would you like to continue:\nY\nN\n") cont(y)
def result(): urlname = request.args['name'] result = inputScript.main(urlname) prediction = classifier.predict(result) if (prediction == 1): return ("Phishing URL") else: return ("Safe URL")
def y_predict(): ''' For rendering results on HTML GUI ''' url = request.form['website URL'] checkprediction = inputScript.main(url) prediction = model.predict(checkprediction) print(prediction) output = prediction[0] if (output == 1): pred = "The Website is Legitimate" else: pred = "This is a Phishing Website,your data may fall into high risk" return render_template('LR.html', prediction_text='{}'.format(pred))
def processing(): text = request.form['name'] if text: checkprediction = inputScript.main(text) prediction = classifier.predict(checkprediction) if prediction[0] == -1: c = "Legit" d = 'name' else: c = "Phishing" d = 'namered' return jsonify({d: c}) else: return jsonify({"error": "Missing data!"})
def y_predict(): ''' For rendering results on HTML GUI ''' url = request.form['URL'] checkprediction = inputScript.main(url) prediction = model.predict(checkprediction) print(prediction) output = prediction[0] if (output == 1): pred = "Your are safe!! This is a Legitimate Website." else: pred = "You are on the wrong site. Be cautious!" return render_template('final.html', prediction_text='{}'.format(pred), url=url)
def CHECK(): link = url.get('1.0', 'end-1c') checkprediction = inputScript.main(link) # load the pickle file classifier = joblib.load('final_models/svm_final1.pkl') # checking and predicting prediction = classifier.predict(checkprediction) print(prediction) if prediction == 1: yes = tk.Label( root, text="! Web Site Looks Phishing Site, Browse at your OWN RISK !", background="red", foreground="white", font=('times', 18, 'italic'), width=60) yes.place(x=300, y=350) button2 = tk.Button(root, command=BROWSE, foreground="white", background="black", font=("Times New Roman", 14, "italic"), text="Browse Anyway", width=14, height=1) button2.place(x=600, y=400) else: no = tk.Label(root, text="! Site Seems Safe Site !", background="green", foreground="white", font=('times', 18, ' italic '), width=60) no.place(x=300, y=350) button2 = tk.Button(root, command=BROWSE, foreground="white", background="black", font=("Times New Roman", 14, "italic"), text="Browse", width=14, height=1) button2.place(x=600, y=400)
def send(): if (request.method == 'POST'): url = request.form['url'] cp = inputScript.main(url) pos = percentageSafety(cp) try: if (requests.get(url).status_code == 200): URLStatus = 'Online' else: URLStatus = 'Offline' except: URLStatus = "Unknown" GlobalRank, NationRank, NationName = pagerank(url) checkprediction = np.reshape(cp, (1, -1)) prediction = classifier.predict(checkprediction) if (prediction < 0.1): PTResult = "Safe" pos = (pos + 100) / 2 elif (prediction > 0.6): PTResult = "Phishing" try: """ Checking if model prediction is true or not """ p = phishtank.PhishTank() result = p.check(url) if result.in_database: if result.valid: PTResult = "Phishing" else: PTResult = "Safe" else: PTResult = "Safe" except: PTResult = "Phishing" else: PTResult = "Suspicious" return render_template('result.html', URL=url, STATUS=URLStatus, PHISHSTATUS=PTResult, PercentageOfSafety=pos, GLOBALRANK=GlobalRank, NATIONNAME=NationName, NATIONRANK=NationRank) return render_template('index.html')
def make_prediction(): classifier = joblib.load('rf_final.pkl') if request.method=='POST': url = request.form['url'] if not url: return render_template('home.html', label = 'Please input url') elif(not(regex.search(r'^(http|ftp)s?://', url))): return render_template('home.html', label = 'Please input full url, for exp- https://facebook.com') checkprediction = inputScript.main(url) prediction = classifier.predict(checkprediction) if prediction[0]==1 : label = 'website is not legitimate' elif prediction[0]==-1: label ='website is legitimate' return render_template('home.html', label=label)
# -*- code: utf-8 -*- #importing libraries from sklearn.externals import joblib import inputScript #load the pickle file classifier = joblib.load('final_models/rf_final.pkl') #input url print("enter url") url = input() #checking and predicting checkprediction = inputScript.main(url) prediction = classifier.predict(checkprediction) print(prediction)
file.close() if(len(urlList)==0): print ("Email has no URL") return None else: return urlList #checking and predicting if (extractURL('email.txt') == None): print("Email does not contain a URL") else: urlValue = [] urlValue = extractURL('email.txt') length = len(urlValue) for i in range(length): checkprediction = inputScript.main(urlValue[i]) <<<<<<< HEAD white_black_test = WhiteBlackApp(urlValue[i], self.domain) white_black_results = white_black_test.run() if white_black_results[0]: ======= prediction = classifier.predict(checkprediction) #print (prediction) if (prediction == 1): >>>>>>> b57b169535b57c497d9e244b4ddd8785e0632966 print("Email contains URL that may be a phishing attack: " + urlValue[i]) elif white_black_results[1]: print("Email contains URL that seems safe: " + urlValue[i]) prediction = classifier.predict(checkprediction) else: if (prediction == 1):
port=3307) # print(mydb) # specify a cursor cursor = db.cursor() # get the url from db url = "SELECT website_url FROM phishing WHERE type=''" cursor.execute(url) result = cursor.fetchall() for row in result: website = row[0] # print(website) # checking and predicition checkprediction = inputScript.main(website) prediction = classifier.predict(checkprediction) if (prediction == 1): type_result = "THE SITE A PHISHING SITE :'{" else: type_result = "The site is not a phishing site :)" #updating db type_update = 'UPDATE phishing SET type="' + type_result + '" WHERE website_url= "' + website + '"' try: cursor.execute(type_update) db.commit() except: db.rollback() # close connection
#create a list that contains each word in each line wordsInLine = line.split(' ') #For each word try to split it with : for word in wordsInLine: tempWord = word.split(":") #Check to see if the word is a URL if len(tempWord) == 2: if tempWord[0] == "http" or tempWord[0] == "https": urlList.append(word) file.close() return urlList[0] def phishng_detection(urlname): checkprediction = inputScript.main(urlname) prediction = classifier.predict(checkprediction) if (prediction == 1): return("URL may be a phishing attack!") else: return("URL seems safe") #checking and predicting checkprediction = inputScript.main(extractURL('email.txt')) prediction = classifier.predict(checkprediction) if (prediction == 1): print("Email contains URL that may be a phishing attack!") else: print("Email contains URL that seems safe")