def test_equal_shingle_vectors(self): webpage1 = Webpage('cluster1', '<html></html>') webpage2 = Webpage('cluster2', '<html><head></head></html>') v4 = ShingleVector(webpage1, [0, 0, 0, 0, 0, 1, 2, 4]) v5 = ShingleVector(webpage2, [0, 0, 0, 0, 0, 1, 2, 4]) # TODO decidere se va bene che siano uguali (in teoria si) self.assertEqual(v4, v5)
def __init__(self, iface, wlan=None): Deauth.__init__(self) Eviltwin.__init__(self) DnsServer.__init__(self) SiteHandler.__init__(self) NetworkManager.__init__(self) InterfaceManager.__init__(self, iface) self.iface = iface self.wlan = wlan if wlan else iface self.out = '.data-01.out' self.csv = 'data-01.csv' self.cap = 'data-01.cap' self.ap = None self.atk = False self.alive = True self._exit = False self.bssid = None self.essid = None self.loadAp = True self.channel = None self.handshake = None self.monitorNetwork = False
def load_webpage(self, filename): webpage_file = open(filename, "r", encoding="utf-8") #NB: questa regola di estrazione del nome va bene per tutti e tre i dataset name = filename[(filename.rfind('/') + 1):filename.rfind('.')] webpage = Webpage(name, webpage_file.read()) webpage_file.close() return webpage
def test_basic_webpage(self): basic_page = Webpage( "boh", "<html><head></head><body>hello world</body></html>") expected_shingle = Shingle( "boh", [["html", "head"], ["head", "head"], ["head", "body"], ["body", "body"], ["body", "html"]]) shingle = extract_shingle_set(basic_page, 2) self.assertEqual(shingle[0].getContent(), ["html", "head"]) self.assertEqual(shingle[1].getContent(), ["head", "head"]) self.assertEqual(shingle[2].getContent(), ["head", "body"]) self.assertEqual(shingle[3].getContent(), ["body", "body"]) self.assertEqual(shingle[4].getContent(), ["body", "html"])
def test_window_equal_than_page(self): page = Webpage("boh", "<html><body></body></html>") shingle = extract_shingle_set(page, 4) self.assertEqual(len(shingle), 1)
def test_void_webpage(self): void_page = Webpage("", "") shingle = extract_shingle_set(void_page, 5) self.assertEqual(len(shingle), 0)
def setUp(self): self.basic_page = Webpage( "boh", "<html><head></head><body>hello world</body></html>") self.shingle_set = extract_shingle_set(self.basic_page, 2) self.shingle_vector = create_shingle_vector(self.shingle_set)