Skip to content

Commit

Permalink
Merge pull request #50 from cisagov/issue-35/update-GoPhish-to-Gophish
Browse files Browse the repository at this point in the history
Update all instances of GoPhish to Gophish
  • Loading branch information
jsf9k committed Oct 22, 2021
2 parents aaab61d + 67ba0c6 commit bc24ff9
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 82 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
![Docker Image Size](https://img.shields.io/docker/image-size/cisagov/gophish-tools)

This repository contains a set of scripts that can be used by phishing
campaign assessors to simplify the process of managing GoPhish campaigns.
campaign assessors to simplify the process of managing Gophish campaigns.

## Scripts ##

- `gophish-cleaner` - Removes an assessment or elements of an assessment
in GoPhish.
- `gophish-complete` - Completes a campaign in GoPhish and/or outputs a
GoPhish campaign summary.
- `gophish-export` - Exports all the data from an assessment within GoPhish
in Gophish.
- `gophish-complete` - Completes a campaign in Gophish and/or outputs a
Gophish campaign summary.
- `gophish-export` - Exports all the data from an assessment within Gophish
into a single JSON file. In addition, user report JSONs for each campaign in
an assessment will also be generated.
- `gophish-import` - Imports an assessment JSON file into GoPhish.
- `gophish-test` - Sends a duplicate assessment from GoPhish to custom
- `gophish-import` - Imports an assessment JSON file into Gophish.
- `gophish-test` - Sends a duplicate assessment from Gophish to custom
targets as a test.
- `pca-wizard` - Creates an assessment JSON file via an interactive "wizard".
- `pca-wizard-templates` - Generates templates for files needed when creating
Expand Down Expand Up @@ -96,14 +96,14 @@ An example assessment JSON can be found [here](src/assessment/sample_assessment.
|------|-------------|:----:|:-------:|:--------:|
| id | Assessment identifier. (e.g. "RV0000") | string | | yes |
| timezone | Timezone name based on [pytz](http://pytz.sourceforge.net/) timezones. (e.g. "US/Eastern") | string | | yes |
| domain | Assessment domain for GoPhish public interface. (e.g. "domain.tld") | string | | yes |
| domain | Assessment domain for Gophish public interface. (e.g. "domain.tld") | string | | yes |
| target_domain | Approved target domains where all email recipients must reside. (e.g. ["target1.tld", "target2.tld"]) | list(string) | | yes |
| start_date | Assessment start date in 24-hr ISO format with offset. (e.g. "2020-01-01T14:00:00-04:00") | string | | yes |
| end_date | Assessment end date in 24-hr ISO format with offset. (e.g. "2020-01-06T15:30:00-04:00") | string | | yes |
| reschedule | Indicates if the assessment json is a rescheduled assessment. | boolean | | yes |
| start_campaign | The campaign that the assessment should start at. | integer | `1` | no |
| groups | Consolidated list of email recipients grouped to receive campaigns, [example](#group-dictionary). | list(dict) | | yes |
| pages | GoPhish landing pages, [example](#page-dictionary). | list(dict) | | yes |
| pages | Gophish landing pages, [example](#page-dictionary). | list(dict) | | yes |
| campaigns | Assessment campaigns, [example](#campaign-dictionary). | list(dict) | | yes |

### Group Dictionary ###
Expand All @@ -130,8 +130,8 @@ with the command `pca-wizard-templates --targets`.
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-------:|:--------:|
| name | Page name in the format of `{assessment identifier}-{integer}-{descriptor}` (e.g. "RV0000-1-AutoForward"). | string | | yes |
| capture_credentials | Capture all non-password input with GoPhish. Supports forwarding after submit action. | boolean | | yes |
| capture_passwords | Capture password input by the user, but note that captured input is **stored in plain text as of GoPhish version 0.9.0.** | boolean | `False` | no |
| capture_credentials | Capture all non-password input with Gophish. Supports forwarding after submit action. | boolean | | yes |
| capture_passwords | Capture password input by the user, but note that captured input is **stored in plain text as of Gophish version 0.9.0.** | boolean | `False` | no |
| html | Content of the landing page in HTML format. | string | | yes |

### Campaign Dictionary ###
Expand All @@ -145,7 +145,7 @@ with the command `pca-wizard-templates --targets`.
| page_name | Landing page name as defined in the assessment json. | string | | yes |
| group_name | Group name as defined in the assessment json. | string | | yes |
| template | Email template for the campaign, [example](#email-template-dictionary). | dict | | yes |
| smtp | GoPhish sending profile, [example](#smtp-dictionary). | dict | | yes |
| smtp | Gophish sending profile, [example](#smtp-dictionary). | dict | | yes |

### Email Template Dictionary ###

Expand All @@ -165,9 +165,9 @@ with the command `pca-wizard-templates --emails`.
|------|-------------|:----:|:-------:|:--------:|
| name | Sending profile name in the format of `{assessment identifier}-SP-{integer}` (e.g. "RV0000-SP-1"). | string | | yes |
| from_address | From email address with display name, required format: `{display name}<{sending email address}>`. (e.g. "John Doe\<john.doe@domain.tld\>") | string | | yes |
| host | Email server for GoPhish to send email through. | string | "postfix:587" | no |
| interface_type | Type of interface GoPhish will use with mail server. | string | "SMTP" | no |
| ignore_cert | Indicate if GoPhish should ignore certs with mail server. | boolean | `True` | no |
| host | Email server for Gophish to send email through. | string | "postfix:587" | no |
| interface_type | Type of interface Gophish will use with mail server. | string | "SMTP" | no |
| ignore_cert | Indicate if Gophish should ignore certs with mail server. | boolean | `True` | no |

## User Report Field Dictionary ##

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_version(version_file):
name="gophish-tools",
# Versions should comply with PEP440
version=get_version("src/_version.py"),
description="Helpful tools for interacting with GoPhish",
description="Helpful tools for interacting with Gophish",
long_description=readme(),
long_description_content_type="text/markdown",
# Landing page for CISA's cybersecurity mission
Expand Down
2 changes: 1 addition & 1 deletion src/assessment/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def import_email(assessment, campaign_number, template_smtp):

continue

# Finalize SMTP profile, push to GoPhish for check.
# Finalize SMTP profile, push to Gophish for check.
# TODO Need to valid this formatting.
temp_smtp.from_address = import_temp["from_address"]

Expand Down
8 changes: 4 additions & 4 deletions src/tools/connect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module to create a GoPhish API connection."""
"""Module to create a Gophish API connection."""

# Third-Party Libraries
from gophish import Gophish
Expand All @@ -7,7 +7,7 @@


def connect_api(api_key, server):
"""Create a GoPhish API connection."""
"""Create a Gophish API connection."""
api = Gophish(api_key, host=server, verify=False)

# Sets up connection and test that it works.
Expand All @@ -22,7 +22,7 @@ def connect_api(api_key, server):
raise Exception(f"Error Connecting: {message}")

except ConnectionError:
raise Exception("Networking Error, unable to reach GoPhish.")
raise Exception("Networking Error, unable to reach Gophish.")

except Exception:
raise Exception("Cannot connect to GoPhish.")
raise Exception("Cannot connect to Gophish.")
8 changes: 4 additions & 4 deletions src/tools/gophish_cleaner.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Remove an assessment or elements of an assessment in GoPhish.
"""Remove an assessment or elements of an assessment in Gophish.
Usage:
gophish-cleaner (--assessment | --campaigns | --groups | --pages | --smtp | --templates) [--log-level=LEVEL] ASSESSMENT_ID SERVER API_KEY
gophish-cleaner (-h | --help)
gophish-cleaner --version
Options:
API_KEY GoPhish API key.
API_KEY Gophish API key.
ASSESSMENT_ID ID of the assessment to remove data from.
SERVER Full URL to GoPhish server.
SERVER Full URL to Gophish server.
-a --assessment Remove all data for the specified assessment.
-c --campaigns Remove all campaigns from the specified assessment.
-g --groups Remove all users and groups from the specified assessment.
Expand Down Expand Up @@ -39,7 +39,7 @@

from ._version import __version__

# Disable "Insecure Request" warning: GoPhish uses a self-signed certificate
# Disable "Insecure Request" warning: Gophish uses a self-signed certificate
# as default for https connections, which can not be verified by a third
# party; thus, an SSL insecure request warning is produced.
requests.packages.urllib3.disable_warnings()
Expand Down
24 changes: 12 additions & 12 deletions src/tools/gophish_complete.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Complete a campaign in GoPhish and/or output a GoPhish campaign summary.
"""Complete a campaign in Gophish and/or output a Gophish campaign summary.
Usage:
gophish-complete [--campaign=NAME] [--summary-only] [--log-level=LEVEL] SERVER API_KEY
gophish-complete (-h | --help)
gophish-complete --version
Options:
API_KEY GoPhish API key.
SERVER Full URL to GoPhish server.
-c --campaign=NAME GoPhish campaign name.
-s --summary-only Output a summary of a GoPhish campaign.
API_KEY Gophish API key.
SERVER Full URL to Gophish server.
-c --campaign=NAME Gophish campaign name.
-s --summary-only Output a summary of a Gophish campaign.
-h --help Show this screen.
--version Show version.
-l --log-level=LEVEL If specified, then the log level will be set to
Expand Down Expand Up @@ -38,7 +38,7 @@

from ._version import __version__

# Disable "Insecure Request" warning: GoPhish uses a self-signed certificate
# Disable "Insecure Request" warning: Gophish uses a self-signed certificate
# as default for https connections, which can not be verified by a third
# party; thus, an SSL insecure request warning is produced.
requests.packages.urllib3.disable_warnings()
Expand Down Expand Up @@ -72,7 +72,7 @@ def get_campaigns(api, assessment_id=""):
provided, then only the campaigns for that assessment will be returned.
Args:
api (GoPhish API): Connection to GoPhish server via the API.
api (Gophish API): Connection to Gophish server via the API.
assessment_id (string): Assessment identifier to get campaigns from.
Raises:
Expand Down Expand Up @@ -117,15 +117,15 @@ def select_campaign(campaigns):


def complete_campaign(api_key, server, campaign_id):
"""Complete a campaign in GoPhish.
"""Complete a campaign in Gophish.
Args:
api_key (string): GoPhish API key.
server (string): Full URL to GoPhish server.
campaign_id (int): GoPhish campaign id.
api_key (string): Gophish API key.
server (string): Full URL to Gophish server.
campaign_id (int): Gophish campaign id.
Raises:
UserWarning: GoPhish is unsuccessful in completing the campaign.
UserWarning: Gophish is unsuccessful in completing the campaign.
"""
url = f"{server}/api/campaigns/{campaign_id}/complete?api_key={api_key}"

Expand Down
28 changes: 14 additions & 14 deletions src/tools/gophish_export.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Export all the data from an assessment within GoPhish into a single JSON file.
"""Export all the data from an assessment within Gophish into a single JSON file.
Usage:
gophish-export [--log-level=LEVEL] ASSESSMENT_ID SERVER API_KEY
gophish-export (-h | --help)
gophish-export --version
Options:
API_KEY GoPhish API key.
API_KEY Gophish API key.
ASSESSMENT_ID ID of the assessment to export data from.
SERVER Full URL to GoPhish server.
SERVER Full URL to Gophish server.
-h --help Show this screen.
--version Show version.
-l --log-level=LEVEL If specified, then the log level will be set to
Expand All @@ -35,17 +35,17 @@

from ._version import __version__

# Disable "Insecure Request" warning: GoPhish uses a self-signed certificate
# Disable "Insecure Request" warning: Gophish uses a self-signed certificate
# as default for https connections, which can not be verified by a third
# party; thus, an SSL insecure request warning is produced.
requests.packages.urllib3.disable_warnings()


def assessment_exists(api, assessment_id):
"""Check if GoPhish has at least one campaign for designated assessment.
"""Check if Gophish has at least one campaign for designated assessment.
Args:
api (GoPhish API): Connection to GoPhish server via the API.
api (Gophish API): Connection to Gophish server via the API.
assessment_id (string): Assessment identifier to get campaigns from.
Returns:
Expand All @@ -68,7 +68,7 @@ def export_targets(api, assessment_id):
sha256 hash of the target's email and assessment id with any labels.
Args:
api (GoPhish API): Connection to GoPhish server via the API.
api (Gophish API): Connection to Gophish server via the API.
assessment_id (string): Assessment identifier to get campaigns from.
Returns:
Expand Down Expand Up @@ -107,7 +107,7 @@ def export_targets(api, assessment_id):

def get_group_ids(api, assessment_id):
"""Return a list of group IDs for all groups starting with specified assessment_id."""
rawGroup = api.groups.get() # Holds raw list of campaigns from GoPhish.
rawGroup = api.groups.get() # Holds raw list of campaigns from Gophish.
groups = list() # Holds list of campaign IDs that match the assessment.

for group in rawGroup:
Expand All @@ -122,7 +122,7 @@ def export_campaigns(api, assessment_id):
"""Add all the campaigns' data for an assessment to a list.
Args:
api (GoPhish API): Connection to GoPhish server via the API.
api (Gophish API): Connection to Gophish server via the API.
assessment_id (string): Assessment identifier to get campaigns from.
Returns:
Expand All @@ -141,7 +141,7 @@ def export_campaigns(api, assessment_id):

def get_campaign_ids(api, assessment_id):
"""Return a list of campaign IDs for all campaigns starting with specified assessment_id."""
rawCampaigns = api.campaigns.get() # Holds raw list of campaigns from GoPhish.
rawCampaigns = api.campaigns.get() # Holds raw list of campaigns from Gophish.
campaigns = list() # Holds list of campaign IDs that match the assessment.

for campaign in rawCampaigns:
Expand All @@ -156,7 +156,7 @@ def get_campaign_data(api, campaign_id):
"""Return campaign metadata for the given campaign ID."""
campaign = dict()

# Pulls the campaign data as dict from GoPhish.
# Pulls the campaign data as dict from Gophish.
rawCampaign: dict = api.campaigns.get(campaign_id).as_dict()

campaign["id"] = rawCampaign["name"]
Expand All @@ -167,14 +167,14 @@ def get_campaign_data(api, campaign_id):

campaign["subject"] = rawCampaign["template"]["subject"]

# Get the template ID from the GoPhish template name.
# Get the template ID from the Gophish template name.
campaign["template"] = (
api.templates.get(rawCampaign["template"]["id"]).as_dict()["name"].split("-")[2]
)

campaign["clicks"] = get_click_data(api, campaign_id)

# Get the e-mail send status from GoPhish.
# Get the e-mail send status from Gophish.
campaign["status"] = get_email_status(api, campaign_id)

return campaign
Expand Down Expand Up @@ -418,6 +418,6 @@ def main() -> None:
write_campaign_summary(api, args["ASSESSMENT_ID"])
else:
logging.error(
'Assessment "%s" does not exist in GoPhish.', args["ASSESSMENT_ID"]
'Assessment "%s" does not exist in Gophish.', args["ASSESSMENT_ID"]
)
sys.exit(1)
22 changes: 11 additions & 11 deletions src/tools/gophish_import.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Import an assessment JSON file into GoPhish.
"""Import an assessment JSON file into Gophish.
Usage:
gophish-import [--log-level=LEVEL] [--reschedule] ASSESSMENT_FILE SERVER API_KEY
gophish-import (-h | --help)
gophish-import --version
Options:
API_KEY GoPhish API key.
API_KEY Gophish API key.
ASSESSMENT_FILE Name of the JSON file containing assessment data.
SERVER Full URL to GoPhish server.
SERVER Full URL to Gophish server.
-r --reschedule Adjust the current schedule of an assessment with the new schedule in the ASSESSMENT_FILE.
-h --help Show this screen.
--version Show version.
Expand All @@ -33,7 +33,7 @@

from ._version import __version__

# Disable "Insecure Request" warning: GoPhish uses a self-signed certificate
# Disable "Insecure Request" warning: Gophish uses a self-signed certificate
# as default for https connections, which can not be verified by a third
# party; thus, an SSL insecure request warning is produced.
requests.packages.urllib3.disable_warnings()
Expand All @@ -58,8 +58,8 @@ def load_landings(api, assessment):
logging.debug("Redirect URL: %s", new_page.redirect_url)

"""
Catches when a page has already been loaded into GoPhish.
Finds the current GoPhish page ID so it can be deleted
Catches when a page has already been loaded into Gophish.
Finds the current Gophish page ID so it can be deleted
prior to re-loading the new page.
"""
while True:
Expand Down Expand Up @@ -106,8 +106,8 @@ def load_groups(api, assessment):
new_group.targets.append(target)

"""
Catches when a Group has already been loaded into GoPhish.
Finds the current GoPhish group ID so it can be deleted
Catches when a Group has already been loaded into Gophish.
Finds the current Gophish group ID so it can be deleted
prior to re-loading the new group.
"""
while True:
Expand Down Expand Up @@ -155,8 +155,8 @@ def build_campaigns(api, assessment):
)

"""
Catches when Template has already been loaded into GoPhish.
Finds the current GoPhish template ID so it can be deleted
Catches when Template has already been loaded into Gophish.
Finds the current Gophish template ID so it can be deleted
prior to re-loading the new template.
"""
while True:
Expand Down Expand Up @@ -306,7 +306,7 @@ def main() -> None:
# Load Landing page
assessment["pages"] = load_landings(api, assessment)

# Load Groups into GoPhish, returns group numbers correlated to Group number
# Load Groups into Gophish, returns group numbers correlated to Group number
assessment["groups"] = load_groups(api, assessment)

# Load Campaigns
Expand Down

0 comments on commit bc24ff9

Please sign in to comment.