allTokens = [] weakTokens = [] tokenDatabase = [] insecureForms = [] print(' %s Phase: Crawling %s[%s1/6%s]%s' % (lightning, green, end, green, end)) dataset = photon(target, headers, level, threadCount) allForms = dataset[0] print('\r%s Crawled %i URL(s) and found %i form(s).%-10s' % (info, dataset[1], len(allForms), ' ')) print(' %s Phase: Evaluating %s[%s2/6%s]%s' % (lightning, green, end, green, end)) evaluate(allForms, weakTokens, tokenDatabase, allTokens, insecureForms) if weakTokens: print('%s Weak token(s) found' % good) for weakToken in weakTokens: url = list(weakToken.keys())[0] token = list(weakToken.values())[0] print('%s %s %s' % (info, url, token)) if insecureForms: print('%s Insecure form(s) found' % good) for insecureForm in insecureForms: url = list(insecureForm.keys())[0] action = list(insecureForm.values())[0]['action'] form = action.replace(target, '') if form:
def solve_problem(image, features, topic): """ ------------------------------------------------------------ STEP 2. Predict the Feature 1. Crop the features as collection of images 2. Feed feature images to the model 3. Get predicted value for each feature ------------------------------------------------------------ """ # Get all features as an image feature_col = get_features_as_img(image, features) feature_col = np.array(feature_col) # Formatting the input feature_col = feature_col.reshape(feature_col.shape + (1, )) feature_col = feature_col.astype(np.float32) input_shape = list(feature_col.shape) # Load the TFLite model and allocate tensors interpreter = tf.lite.Interpreter(model_path="core/model/" + MODEL_ARCHITECTURE) interpreter.resize_tensor_input(0, input_shape, strict=True) interpreter.allocate_tensors() # Get input and output tensors input_details = interpreter.get_input_details() output_details = interpreter.get_output_details() # Feed the data into the model interpreter.set_tensor(input_details[0]['index'], feature_col) interpreter.invoke() # Get predicted value features_prob = interpreter.get_tensor(output_details[0]['index']) features_pred = [] for index in range(len(feature_col)): predicted_feat = np.argmax(features_prob[index]) features_pred.append(predicted_feat) # Assign the predicted value to each component for index in range(len(features)): features[index]["symbol_id"] = features_pred[index].item() features[index]["symbol"] = math_symbol[features_pred[index]]["symbol"] # Display predicted features from model in terminal if DISPLAY_PREDICTED_FEATURES: print("--------------------------------------------------------------") print("Predicted Features :") print(features_pred) print("--------------------------------------------------------------") """ ------------------------------------------------------------ STEP 3. Turn Features Into Mathematical Terms 1. Get the position order of each features 2. Turn those features into mathematical terms ------------------------------------------------------------ """ # Get position order for each feature features = arrange_position(features) # Turn features into mathematical terms terms = get_math_terms(features, topic) display_terms = terms.copy() """ ------------------------------------------------------------ STEP 4. Evaluate the Problem ------------------------------------------------------------ """ # Choose the topic and evaluate the problem result = evaluate(terms, topic) """ ------------------------------------------------------------ STEP 5. Display the Question and Answer ------------------------------------------------------------ """ # Display the question and answer qna_dict = display_qna(display_terms, result, topic) return qna_dict