I have a code for url malicious detection, but i want this code rewritten for SQL injection detection, pls can any one in the house help. The code is here below, thanks
import pandas as pd
import numpy as np
import random
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
urls_data = pd.read_csv(x93data.csvx94)
type(urls_data)
urls_data.head()
def makeTokens(f):
tkns_BySlash = str(f.encode(x91utf-8x92)).split(x92/x92)
total_Tokens = []
for i in tkns_BySlash:
tokens = str(i).split(x92-x92)
tkns_ByDot = []
for j in range(0, len(tokens)):
temp_Tokens = str(tokens[j]).split(x92.x92)
tkns_ByDot = tkns_ByDot + temp_Tokens
total_Tokens = total_Tokens + tokens + tkns_ByDot
total_Tokens = list(set(total_Tokens))
if x91comx92 in total_Tokens:
total_Tokens.remove(x91comx92)
return total_Tokens
y = urls_data[x93labelx94]
url_list = urls_data[x93urlx94]
vectorizer = TfidfVectorizer(tokenizer=makeTokens)
x = vectorizer.fit_transform(url_list)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42)
logit = LogisticRegression()
logit.fit(x_train, y_train)
print ("Accuracy ", logit.score(x_test, y_test))
x_predict = [x93
404 Not Found,
x93
]Radsport Voggel
x_predict = vectorizer.transform(x_predict)
New_predict = logit.predict(x_predict)
print(New_predict)
برچسب:
نویسنده: آیلین رضوانی
تاريخ: شنبه
18 آذر
1396 ساعت: 4:01