Exemple #1
0
 def test_dork_page_regeneration(self):
     """Objective: Test if the dork pages get regenerated.
     Input: The list of previously generated dork pages.
     Expected Results: A new list of dork pages.
     Notes: A productive system generates new pages in a configurable interval."""
     dirname = 'modules/handlers/emulators/dork_list/pages/'
     gen_dork_list.regular_generate_dork(0, dirname)
     old_list = gen_dork_list.get_old_dork_pages_list(dirname)
     print "There are %s previously generated dork pages" % len(old_list),
     old_sample_file = choice(old_list)
     print "For example:", old_sample_file.rsplit('/', 1)[1]
     gen_dork_list.regular_generate_dork(0, dirname)
     print "Done generating new dork pages.",
     print "Old dork pages has been removed."
     new_list = gen_dork_list.get_old_dork_pages_list(dirname)
     overlap = set(new_list).intersection(old_list)
     self.assertTrue(len(overlap) == 0)
     print "There are", len(overlap), "overlapping dork pages",
     print "which equates our expectation."
Exemple #2
0
 def test_dork_page(self):
     """Objective: Tests if the attack surface generation works.
     Input: Data from the dork database.
     Expected Results: HTML pages ready to be served to the adversary.
     Notes: This test covers the generation of the HTML pages from the dork database. The page number is proportional to database entries."""
     print "Starting dork page test."
     gen_dork_list.regular_generate_dork(0)
     print "Done creating dork pages."
     dirname = 'modules/handlers/emulators/dork_list/pages/'
     self.assertTrue(
             len(gen_dork_list.get_old_dork_pages_list(dirname)) > 0
             )
     print "Number of created HTML pages:",
     print len(gen_dork_list.get_old_dork_pages_list(dirname)),
     print "equates our expectation."
     print "Sample page can be found in:", dirname
     gen_dork_list.remove_old_dork_pages(
                         gen_dork_list.get_old_dork_pages_list(dirname)
                         )
Exemple #3
0
 def test_dork_links(self):
     """Objective: Test if a random link from the dork page exists in the database.
     Input: A random link from a created dork page.
     Expected Results: The path of the link should be at least once in the db.
     Notes: Links have the parameters truncated, so multiple entries are likely."""
     dirname = 'modules/handlers/emulators/dork_list/pages/'
     sample_file = choice(gen_dork_list.get_old_dork_pages_list(dirname))
     print "Randomly selected dork page:", sample_file.rsplit('/', 1)[1]
     with open(sample_file, 'r') as sample_data:
         data = fromstring(sample_data)
     links = data.cssselect('a')
     test_link_path = choice(links).get('href')
     print "Randomly selected path:", test_link_path
     data = self.db.select_entry(test_link_path)
     print "Done searching for the entry."
     self.assertTrue(len(data) > 0)
     print "The dork db returned:",
     print str(len(data)), "entries,",
     print "which equates our expectation."
Exemple #4
0
 def test_dork_page_content(self):
     """Objective: Testing the attack surfaces content.
     Input: An attack surface sample. The structure is defined in a template.
     Expected Results: The attack surface should be a HTML page containing text and links.
     Notes: We extract and count the elements in the HTML document."""
     dirname = 'modules/handlers/emulators/dork_list/pages/'
     gen_dork_list.regular_generate_dork(0)
     sample_file = choice(gen_dork_list.get_old_dork_pages_list(dirname))
     with open(sample_file, 'r') as sample_data:
         data = fromstring(sample_data)
         #print tostring(data)
     self.assertTrue(len(data.cssselect('a')) > 0)
     self.assertTrue(len(data.cssselect('title')) > 0)
     self.assertTrue(len(data.cssselect('form')) > 0)
     print "The content analysis of a random HTML page returned:"
     print len(data.cssselect('a')), 'links (<a href=""></a>)',
     print len(data.cssselect('title')), 'page title (<title />)',
     print len(data.cssselect('form')), 'form field (<form />)'
     print "which equates our expectation."