Ejemplo n.º 1
0
    def test_template_empty_set(self):
        """ Tests grab_online with an empty set as an input. """

        template = set()

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 2
0
    def test_template_empty_set(self):
        """ Tests grab_online with an empty set as an input. """

        template = set()

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 3
0
    def test_template_empty_dict(self):
        """ Tests grab_online with empty dictionary as an input. """

        template = dict()

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 4
0
    def test_template_non_empty_dict(self):
        """ Tests grab_online with a non-empty dictionary as an input. """

        template = {"test": 1, "test2": 2}

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 5
0
    def test_template_non_empty_dict(self):
        """ Tests grab_online with a non-empty dictionary as an input. """

        template = {"test": 1, "test2": 2}

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 6
0
    def test_template_non_empty_list(self):
        """ Tests grab_online with a non-empty list as an input. """

        template = [1, 2, 3]

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 7
0
    def test_template_non_empty_list(self):
        """ Tests grab_online with a non-empty list as an input. """

        template = [1, 2, 3]

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 8
0
    def test_template_empty_dict(self):
        """ Tests grab_online with empty dictionary as an input. """

        template = dict()

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(template)
Ejemplo n.º 9
0
    def test_all_files_locally_present(self):
        """ Tests check_template when all files are locally present. """

        template = "linksys"
        path = phishingpage.get_path(template)

        # download the template
        phishingpage.grab_online(template)

        self.assertEqual(phishingpage.check_template(template), True,
                         "Failed to check valid template with all files!")
        shutil.rmtree(path)
Ejemplo n.º 10
0
    def test_all_files_locally_present(self):
        """ Tests check_template when all files are locally present. """

        template = "linksys"
        path = phishingpage.get_path(template)

        # download the template
        phishingpage.grab_online(template)

        self.assertEqual(phishingpage.check_template(template), True,
                         "Failed to check valid template with all files!")
        shutil.rmtree(path)
Ejemplo n.º 11
0
    def test_template_exists(self):
        """ Tests grab_online given a valid template name as an input. """

        template = "linksys"
        directory = phishingpage.PHISHING_PAGES_DIR
        path = phishingpage.get_path(template)

        phishingpage.grab_online(template)

        if template not in os.listdir(directory):
            self.fail("Failed to create the template folder!")

        shutil.rmtree(path)
Ejemplo n.º 12
0
    def test_template_exists(self):
        """ Tests grab_online given a valid template name as an input. """

        template = "linksys"
        directory = phishingpage.PHISHING_PAGES_DIR
        path = phishingpage.get_path(template)

        phishingpage.grab_online(template)

        if template not in os.listdir(directory):
            self.fail("Failed to create the template folder!")

        shutil.rmtree(path)
Ejemplo n.º 13
0
    def test_some_files_locally_present(self):
        """
        Tests check_template when some of the files are locally present.
        """

        template = "linksys"
        path = phishingpage.get_path(template)

        # download the template
        phishingpage.grab_online(template)

        # remove a file
        os.remove(path + "/index.html")

        self.assertEqual(phishingpage.check_template(template), False,
                         "Failed to check a template with some files!")
        shutil.rmtree(path)
Ejemplo n.º 14
0
    def test_some_files_locally_present(self):
        """
        Tests check_template when some of the files are locally present.
        """

        template = "linksys"
        path = phishingpage.get_path(template)

        # download the template
        phishingpage.grab_online(template)

        # remove a file
        os.remove(path + "/index.html")

        self.assertEqual(phishingpage.check_template(template), False,
                         "Failed to check a template with some files!")
        shutil.rmtree(path)
Ejemplo n.º 15
0
    def test_template_with_some_files(self):
        """
        Tests clean_template when a template with some files is given as an
        input.
        """

        template = "linksys"
        dir_path = phishingpage.PHISHING_PAGES_DIR
        path = phishingpage.get_path(template)
        local_directory_names_1 = []
        local_directory_names_2 = []

        # download the template
        phishingpage.grab_online(template)

        # remove a file
        os.remove(path + "/index.html")

        # loop through the directory content
        for name in os.listdir(dir_path):

            # check to see if it is a file
            if os.path.isdir(os.path.join(dir_path, name)):

                # add it to the list
                local_directory_names_1.append(name)

        phishingpage.clean_template(template)

        # loop through the directory content
        for name in os.listdir(dir_path):

            # check to see if it is a file
            if os.path.isdir(os.path.join(dir_path, name)):

                # add it to the list
                local_directory_names_2.append(name)

        # remove the template from original list
        local_directory_names_1.remove(template)

        self.assertListEqual(local_directory_names_1, local_directory_names_2,
                             "Failed to clean up a template!")
Ejemplo n.º 16
0
    def test_no_files_locally_present(self):
        """
        Tests check_template when only an empty directory is locally
        present.
        """

        template = "linksys"
        path = phishingpage.get_path(template)

        # download the template
        phishingpage.grab_online(template)

        # remove all the files
        os.remove(path + "/index.html")
        os.remove(path + "/Linksys_logo.png")

        self.assertEqual(phishingpage.check_template(template), False,
                         "Failed to check a template with no files!")
        shutil.rmtree(path)
Ejemplo n.º 17
0
    def test_no_files_locally_present(self):
        """
        Tests check_template when only an empty directory is locally
        present.
        """

        template = "linksys"
        path = phishingpage.get_path(template)

        # download the template
        phishingpage.grab_online(template)

        # remove all the files
        os.remove(path + "/index.html")
        os.remove(path + "/Linksys_logo.png")

        self.assertEqual(phishingpage.check_template(template), False,
                         "Failed to check a template with no files!")
        shutil.rmtree(path)
Ejemplo n.º 18
0
    def test_template_with_some_files(self):
        """
        Tests clean_template when a template with some files is given as an
        input.
        """

        template = "linksys"
        dir_path = phishingpage.PHISHING_PAGES_DIR
        path = phishingpage.get_path(template)
        local_directory_names_1 = []
        local_directory_names_2 = []

        # download the template
        phishingpage.grab_online(template)

        # remove a file
        os.remove(path + "/index.html")

        # loop through the directory content
        for name in os.listdir(dir_path):

            # check to see if it is a file
            if os.path.isdir(os.path.join(dir_path, name)):

                # add it to the list
                local_directory_names_1.append(name)

        phishingpage.clean_template(template)

        # loop through the directory content
        for name in os.listdir(dir_path):

            # check to see if it is a file
            if os.path.isdir(os.path.join(dir_path, name)):

                # add it to the list
                local_directory_names_2.append(name)

        # remove the template from original list
        local_directory_names_1.remove(template)

        self.assertListEqual(local_directory_names_1, local_directory_names_2,
                             "Failed to clean up a template!")
Ejemplo n.º 19
0
    def test_template_float(self):
        """ Tests grab_online with a float as an input. """

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(2.4)
Ejemplo n.º 20
0
    def test_template_special_character(self):
        """ Tests grab_online with special string characters as an input. """

        with self.assertRaises(phishingpage.TemplateNotAvailable):
            phishingpage.grab_online("fdsjkjl#@!#")
Ejemplo n.º 21
0
    def test_template_empty(self):
        """ Tests grab_online with an empty string as an input. """

        with self.assertRaises(phishingpage.TemplateNotAvailable):
            phishingpage.grab_online("")
Ejemplo n.º 22
0
    def test_template_not_exists(self):
        """ Tests grab_online with non-existence template as an input. """

        with self.assertRaises(phishingpage.TemplateNotAvailable):
            phishingpage.grab_online("randomnumber")
Ejemplo n.º 23
0
    def test_template_empty(self):
        """ Tests grab_online with an empty string as an input. """

        with self.assertRaises(phishingpage.TemplateNotAvailable):
            phishingpage.grab_online("")
Ejemplo n.º 24
0
    def test_template_float(self):
        """ Tests grab_online with a float as an input. """

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(2.4)
Ejemplo n.º 25
0
    def test_template_not_exists(self):
        """ Tests grab_online with non-existence template as an input. """

        with self.assertRaises(phishingpage.TemplateNotAvailable):
            phishingpage.grab_online("randomnumber")
Ejemplo n.º 26
0
        if not phishingpage.check_template(TEMPLATE_NAME):

            # clean up the previous download
            phishingpage.clean_template(TEMPLATE_NAME)

            # get user's response
            response = raw_input("Template is available online. Do you want"\
            " to download it now? [y/n] ")

            # in case the user agrees to download
            if response == "Y" or response == "y":
                # display download info to the user
                print "[" + G + "+" + W + "] Downloading the template..."

                # download the content
                phishingpage.grab_online(TEMPLATE_NAME)

    # set the path for the template
    TEMPLATE_PATH = phishingpage.get_path(TEMPLATE_NAME)

    # TODO: We should have more checks here:
    # Is anything binded to our HTTP(S) ports?
    # Maybe we should save current iptables rules somewhere
    reset_interfaces()
    # Exit if less than two wireless interfaces exist in the system
    if len(get_interfaces()['all']) <= 0:
        sys.exit('[' + R + '-' + W + '] No wireless interfaces ' \
               + 'found. Closing... ')
    elif len(get_interfaces()['all']) == 1:
        sys.exit('[' + R + '-' + W + '] Only one wireless interface ' \
               + 'found. Closing... ')
Ejemplo n.º 27
0
    def test_template_none(self):
        """ Tests grab_online with None type as an input. """

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(None)
Ejemplo n.º 28
0
    def test_template_special_character(self):
        """ Tests grab_online with special string characters as an input. """

        with self.assertRaises(phishingpage.TemplateNotAvailable):
            phishingpage.grab_online("fdsjkjl#@!#")
Ejemplo n.º 29
0
        if not phishingpage.check_template(TEMPLATE_NAME):

            # clean up the previous download
            phishingpage.clean_template(TEMPLATE_NAME)

            # get user's response
            response = raw_input("Template is available online. Do you want"\
            " to download it now? [y/n] ")

            # in case the user agrees to download
            if response == "Y" or response == "y":
                # display download info to the user
                print "[" + G + "+" + W + "] Downloading the template..."

                # download the content
                phishingpage.grab_online(TEMPLATE_NAME)

    # set the path for the template
    TEMPLATE_PATH = phishingpage.get_path(TEMPLATE_NAME)

    # TODO: We should have more checks here:
    # Is anything binded to our HTTP(S) ports?
    # Maybe we should save current iptables rules somewhere
    reset_interfaces()
    # Exit if less than two wireless interfaces exist in the system
    if len(get_interfaces()['all']) <= 0:
        sys.exit('[' + R + '-' + W + '] No wireless interfaces ' \
               + 'found. Closing... ')
    elif len(get_interfaces()['all']) == 1:
        sys.exit('[' + R + '-' + W + '] Only one wireless interface ' \
               + 'found. Closing... ')
Ejemplo n.º 30
0
    def test_template_none(self):
        """ Tests grab_online with None type as an input. """

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.grab_online(None)