def process_test_url(url, output_dest): feature = [] url = url.strip() if url != '': print 'working on: ' + url #showoff ret_dict = urlfeature.feature_extract(url) feature.append([url, ret_dict]) resultwriter(feature, output_dest)
def process_test_url(url,output_dest): # i think this takes a single url to extract feature, this is used in gui.py file only feature=[] url=url.strip() if url!='': print ('working on: '+url) #showoff ret_dict=urlfeature.feature_extract(url) feature.append([url,ret_dict]); resultwriter(feature,output_dest)
def process_test_list(file_dest, output_dest): feature = [] with open(file_dest) as file: for line in file: url = line.strip() if url != '': print 'working on: ' + url #showoff ret_dict = urlfeature.feature_extract(url) feature.append([url, ret_dict]) resultwriter(feature, output_dest)
def process_test_list(file_dest,output_dest): # i think this takes whole file of urls without given malicious to extract their feature and doest not provide malicious column like this will take query.txt feature=[] with open(file_dest) as file: for line in file: url=line.strip() if url!='': print ('working on: '+url) #showoff ret_dict=urlfeature.feature_extract(url) feature.append([url,ret_dict]); resultwriter(feature,output_dest)
def process_URL_list(file_dest,output_dest):# i think this takes whole file of urls with given malicious to extract their feature and provide malicious column also like this will take url.txt feature=[] with open(file_dest) as file: for line in file: url=line.split(',')[0].strip() malicious_bool=line.split(',')[1].strip() if url!='': print ('working on: '+url) #showoff ret_dict=urlfeature.feature_extract(url) ret_dict['malicious']=malicious_bool feature.append([url,ret_dict]); resultwriter(feature,output_dest)
def process_URL_list(file_dest, output_dest): feature = [] with open(file_dest) as file: for line in file: url = line.split(',')[0].strip() malicious_bool = line.split(',')[1].strip() if url != '': print('working on: ', url) #showoff ret_dict = urlfeature.feature_extract(url) ret_dict['malicious'] = malicious_bool feature.append([url, ret_dict]) resultwriter(feature, output_dest)
def submit(): if (request.method == 'POST'): features = [] data = request.get_json() print(data) sms = data['msg'] #Check for URL in msg url = '' for w in sms.split(' '): if (w.startswith('https:') or w.startswith('http:') or w.startswith('www')): url = w if url != '': url = str(url) features.append(urlfeature.feature_extract(url)) df = pd.DataFrame(features) ans_np = list(rf_model.predict(df[train_cols])) # print 'URL is: ',url # print '\n ANS is: ',ans[0] ans = int(ans_np[0]) if (ans == 1): features.append({ 'ans': ans, 'flash': 'Site entered is SUSPICIOUS', 'url': url }) elif (ans == 0): features.append({ 'ans': ans, 'flash': 'Site entered is SAFE', 'url': url }) else: features.append({ 'ans': ans, 'flash': 'Site entered is MALICIOUS', 'url': url }) return {'features': features} else: error = 'Please enter a valid URL' return {'error': error}
def process_URL_list(file_dest, output_dest): feature = [] with open(file_dest) as file: for line in file: ##对每一行内容进行划分为链接和标签 content_list = line.split(",") ##url链接 url = content_list[0].strip() ##标签 malicious_bool = content_list[1].strip() if url: print 'working on: ' + url ##url特征提取 ret_dict = urlfeature.feature_extract(url) ###输出恶意代码类型 ret_dict['malicious'] = malicious_bool feature.append([url, ret_dict]) file.close() resultwriter(feature, output_dest)