コード例 #1
0
def build_pages(id_):
    """Walk user through building multiple new page documents.

    :return a page object
    """
    pages = list()
    logging.info("Getting Page Metadata")

    # Looks through to get the number of pages as a number with error checking
    num_pages = get_number("    How many pages do you need?")

    for page_num in range(int(num_pages)):
        logging.info(f"Building Page {page_num + 1}")
        temp_page = Page()
        auto_forward = yes_no_prompt("    Will this page auto forward?")
        temp_page.capture_credentials = False
        temp_page.capture_passwords = False

        if auto_forward == "yes":
            setattr(temp_page, "name", f"{id_}-{page_num+1}-AutoForward")
            temp_page.html = AUTO_FORWARD
            temp_page.redirect_url = get_input("    URL to Redirect to:")

        else:
            temp_page.name = f"{id_}-{page_num+1}-Landing"
            forward = yes_no_prompt("    Will this page forward after action? (yes/no)")
            if forward == "yes":
                temp_page.redirect_url = get_input("    URL to Redirect to:")

            # Receives the file name and checks if it exists.
            while True:
                try:
                    landing_file_name = get_input("Landing Page File name:")
                    # Drops .html if included so it can always be added as fail safe.
                    landing_file_name = landing_file_name.split(".", 1)[0]

                    with open(landing_file_name + ".html") as landingFile:
                        temp_page.html = landingFile.read()

                    break
                except EnvironmentError:
                    logging.critical(
                        f"ERROR- Landing Page File not found: {landing_file_name}.html"
                    )
                    print("Please try again...")

        # Debug page information
        logging.debug(f"Page Name: {temp_page.name}")
        logging.debug(f"Redirect ULR: {temp_page.redirect_url}")
        logging.debug(f"Capture Credentials: {temp_page.capture_credentials}")
        logging.debug(f"Capture Passwords: {temp_page.capture_passwords}")

        temp_page = review_page(temp_page)
        pages.append(temp_page)

    return pages
コード例 #2
0
ファイル: builder.py プロジェクト: samuelriesz/gophish-tools
def select_group(assessment):
    """Select a group."""
    # Select Group:
    if len(assessment.groups) == 1:  # If only one auto sets.
        logging.info("Group auto set to {}".format(assessment.groups[0].name))
        group_name = assessment.groups[0].name
    else:  # Allows user to choose from multiple groups;
        while True:
            try:
                display_list_groups(assessment)
                group_name = assessment.groups[
                    get_number("    Select Group for this Campaign?") - 1].name
                break
            except IndexError:
                logging.error("ERROR: Invalid selection, try again.")

    return group_name
コード例 #3
0
ファイル: builder.py プロジェクト: samuelriesz/gophish-tools
def select_page(assessment):
    """Select a page."""
    if len(assessment.pages) == 1:  # If only one auto sets.
        logging.info("Page auto set to {}".format(assessment.pages[0].name))
        page_name = assessment.pages[0].name
    else:  # Allows user to choose from multiple pages
        while True:
            try:
                print("\n")
                display_list_pages(assessment)
                page_name = assessment.pages[
                    get_number("    Select the Page for this Campaign?") -
                    1].name
                break
            except IndexError:
                logging.error("ERROR: Invalid selection, try again.")

    return page_name
コード例 #4
0
ファイル: builder.py プロジェクト: samuelriesz/gophish-tools
def build_assessment(assessment_id):
    """Walk user through building a new assessment document.

    :return an assessment object
    """
    logging.info("Building Assessment")
    # Initializes assessment object with ID and timezone
    assessment = Assessment(id=assessment_id, timezone=set_time_zone())

    # Uses prompt to set Assessment and target domains while not allowing blank input
    assessment.domain = get_input(
        "    Assessment Domain (subdomain.domain.tld):")
    assessment.target_domains = (get_input(
        "    Targeted domain(s) separated by spaces:").lower().split(" "))

    # Uses functions to build out aspects of assessment.
    assessment.pages = build_pages(assessment.id)
    assessment.groups = build_groups(assessment.id, assessment.target_domains)

    template_smtp = SMTP()
    template_smtp.name = assessment.id + "-SP"

    # Sets up smtp host info to be pre-populated.
    template_smtp.host = prompt("Enter SMTP Host: ",
                                default=template_smtp.host,
                                validator=BlankInputValidator())

    # Bandit complains about the input() function, but it is safe to
    # use in Python 3, which is required by this project.
    template_smtp.username = input("SMTP User: "******"SMTP Password: "******"Building Campaigns")
    num_campaigns = get_number("    How many Campaigns?")
    for campaign_number in range(0, num_campaigns):
        campaign_data = build_campaigns(assessment, campaign_number + 1,
                                        template_smtp)
        assessment.campaigns.append(campaign_data)

        set_date("start_date", assessment, campaign_data.launch_date)
        set_date("end_date", assessment, campaign_data.complete_date)

    return assessment
コード例 #5
0
def select_campaign(campaigns):
    """Return the ID of a selected campaign."""
    print("Please select a Campaign ID:")
    print("\tID: Name")

    for id, name in campaigns.items():
        print(f"\t {id}: {name}")

    print("")

    while True:
        inputId = get_number("ID: ")
        if inputId in campaigns:
            break
        else:
            logging.warning("Bad Campaign ID")
            print("Try again...")

    return inputId
コード例 #6
0
def reschedule(assessment):
    """Reschedule assessment dates."""
    logging.info("Determining where to start rescheduling...")
    assessment.reschedule = True
    display_assessment_dates(assessment)
    assessment.start_campaign = get_number(
        "Select a Campaign to start rescheduling at:")

    for campaign in assessment.campaigns:
        if int(campaign.name[len(campaign.name) -
                             1]) >= assessment.start_campaign:
            campaign = change_dates(campaign, assessment.timezone)
            assessment.campaigns[assessment.start_campaign - 1] = campaign
            set_date("start_date", assessment, campaign.launch_date)
            set_date("end_date", assessment, campaign.complete_date)

    logging.info("Dates have been changed...")
    display_assessment_dates(assessment)

    return assessment
コード例 #7
0
ファイル: builder.py プロジェクト: samuelriesz/gophish-tools
def build_groups(id, target_domains):
    """Build groups."""
    logging.info("Getting Group Metadata")
    groups = list()

    # Looks through to get the number of groups as a number with error checking
    num_groups = get_number("    How many groups do you need?")

    if num_groups > 1:
        logging.warning("NOTE: Please load each group as a different CSV")

    labels = yes_no_prompt("    Are there customer labels?")

    for group_num in range(int(num_groups)):
        logging.info(f"Building Group {group_num + 1}")

        new_group = Group(name=f"{id}-G{str(group_num + 1)}")

        new_group.targets = build_emails(target_domains, labels)

        logging.info(f"Group Ready: {new_group.name}")
        groups.append(new_group)

    return groups