Skip to content

Commit fee1ae4

Browse files
author
Michael Skelton
committed
Fuzzy wuzzy logic taken from concept to production
1 parent 7454647 commit fee1ae4

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

fuzzy_logic_concept.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/core/virtual_host_scanner.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import hashlib
44
import pandas as pd
55
from lib.core.discovered_host import *
6-
from fuzzywuzzy import fuzz
6+
77

88

99
class virtual_host_scanner(object):
@@ -121,8 +121,4 @@ def likely_matches(self):
121121
segmented_data = dataframe.groupby("val_col").filter(lambda x: len(x) <= self.unique_depth)
122122
matches = ((segmented_data["key_col"].values).tolist())
123123

124-
return matches
125-
126-
def fuzzy_logic(self):
127-
# for host in self.hosts:
128-
return
124+
return matches

lib/helpers/output_helper.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from lib.core.discovered_host import *
22
from lib.helpers.file_helper import *
33
import time
4+
from fuzzywuzzy import fuzz
5+
import itertools
6+
import numpy as np
7+
48

59
class output_helper(object):
610
def __init__(self, scanner):
@@ -30,17 +34,24 @@ def output_normal_likely(self):
3034

3135

3236
def output_fuzzy(self):
33-
output = "\n[+] Match similarity using fuzzy logic:".format(depth)
34-
37+
output = "\n[+] Match similarity using fuzzy logic:"
38+
request_hashes = {}
39+
40+
for host in self.scanner.hosts:
41+
request_hashes[host.hash] = host.content
42+
43+
for a, b in itertools.combinations(request_hashes.keys(), 2):
44+
output += "\n\t[>] {} is {}% similar to {}".format(a, fuzz.ratio(request_hashes[a], request_hashes[b]), b)
45+
3546
return output
3647

3748

3849
def output_normal_detail(self):
3950
output = "\n\n[+] Full scan results"
4051

41-
for p in self.scanner.hosts:
42-
output += "\n\n{} (Code: {}) hash: {}".format(str(p.hostname), str(p.response_code), str(p.hash))
43-
for key in p.keys: output += "\n\t{}".format(key)
52+
for host in self.scanner.hosts:
53+
output += "\n\n{} (Code: {}) hash: {}".format(str(host.hostname), str(host.response_code), str(host.hash))
54+
for key in host.keys: output += "\n\t{}".format(key)
4455

4556
return output
4657

0 commit comments

Comments
 (0)