Example #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)
    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)
    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)
    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)
Example #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)
Example #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)
    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)
Example #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)
    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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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!")
Example #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)
Example #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)
Example #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!")
Example #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)
Example #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#@!#")
Example #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("")
Example #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")
Example #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("")
Example #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)
Example #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")
Example #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... ')
Example #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)
Example #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#@!#")
Example #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... ')
Example #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)