コード例 #1
0
    def test_list_input(self):
        """ Tests get_path with a list as an input. """

        template_name = []

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.get_path(template_name)
コード例 #2
0
    def test_dict_input(self):
        """ Tests get_path with a dictionary as an input. """

        template_name = dict()

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.get_path(template_name)
コード例 #3
0
    def test_list_input(self):
        """ Tests get_path with a list as an input. """

        template_name = []

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.get_path(template_name)
コード例 #4
0
    def test_dict_input(self):
        """ Tests get_path with a dictionary as an input. """

        template_name = dict()

        with self.assertRaises(phishingpage.ArgumentIsNotAString):
            phishingpage.get_path(template_name)
コード例 #5
0
    def test_valid_string_input(self):
        """ Tests get_path with a valid string as an input. """

        template_name = "minimal"
        correct = "phishing-pages/minimal"

        self.assertEqual(phishingpage.get_path(template_name), correct,
                         "Failed to return proper value!")
コード例 #6
0
    def test_valid_string_input(self):
        """ Tests get_path with a valid string as an input. """

        template_name = "minimal"
        correct = "phishing-pages/minimal"

        self.assertEqual(phishingpage.get_path(template_name), correct,
                         "Failed to return proper value!")
コード例 #7
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)
コード例 #8
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)
コード例 #9
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)
コード例 #10
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)
コード例 #11
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)
コード例 #12
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)
コード例 #13
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!")
コード例 #14
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)
コード例 #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!")
コード例 #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)
コード例 #17
0
ファイル: wifiphisher.py プロジェクト: forid786/wifiphisher
            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... ')
    # Get the right interfaces
    inet_iface = get_internet_interface()
    if not args.jamminginterface:
コード例 #18
0
            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... ')
    # Get the right interfaces
    inet_iface = get_internet_interface()
    if not args.jamminginterface: