Documentation ¶
Overview ¶
Package models implements the types and structs needed in gophish.
Index ¶
- Constants
- Variables
- func DeleteCampaign(id int64) error
- func DeleteGroup(g *Group) error
- func DeletePage(id int64, uid int64) error
- func DeleteSMTP(id int64, uid int64) error
- func DeleteTemplate(id int64, uid int64) error
- func PostCampaign(c *Campaign, uid int64) error
- func PostGroup(g *Group) error
- func PostPage(p *Page) error
- func PostSMTP(s *SMTP) error
- func PostTemplate(t *Template) error
- func PutGroup(g *Group) error
- func PutPage(p *Page) error
- func PutSMTP(s *SMTP) error
- func PutTemplate(t *Template) error
- func PutUser(u *User) error
- func Setup() error
- type Attachment
- type Campaign
- type Event
- type Flash
- type Group
- type GroupTarget
- type Page
- type Response
- type Result
- type SMTP
- type SendTestEmailRequest
- type Target
- type Template
- type User
Constants ¶
const ( CAMPAIGN_IN_PROGRESS string = "In progress" CAMPAIGN_QUEUED string = "Queued" CAMPAIGN_EMAILS_SENT string = "Emails Sent" CAMPAIGN_COMPLETE string = "Completed" EVENT_SENT string = "Email Sent" EVENT_SENDING_ERROR string = "Error Sending Email" EVENT_OPENED string = "Email Opened" EVENT_CLICKED string = "Clicked Link" EVENT_DATA_SUBMIT string = "Submitted Data" STATUS_SUCCESS string = "Success" STATUS_SENDING string = "Sending" STATUS_UNKNOWN string = "Unknown" ERROR string = "Error" )
Variables ¶
var ErrCampaignNameNotSpecified = errors.New("Campaign name not specified")
ErrCampaignNameNotSpecified indicates there was no template given by the user
var ErrEmailNotSpecified = errors.New("No email address specified")
ErrNoEmailSpecified is thrown when no email is specified for the Target
var ErrFromAddressNotSpecified = errors.New("No From Address specified")
ErrFromAddressNotSpecified is thrown when there is no "From" address specified in the SMTP configuration
var ErrGroupNameNotSpecified = errors.New("Group name not specified")
ErrGroupNameNotSpecified is thrown when a group name is not specified
var ErrGroupNotFound = errors.New("Group not found")
ErrGroupnNotFound indicates a group specified by the user does not exist in the database
var ErrGroupNotSpecified = errors.New("No groups specified")
ErrGroupNotSpecified indicates there was no template given by the user
var ErrHostNotSpecified = errors.New("No SMTP Host specified")
ErrHostNotSpecified is thrown when there is no Host specified in the SMTP configuration
var ErrNoTargetsSpecified = errors.New("No targets specified")
ErrNoTargetsSpecified is thrown when no targets are specified by the user
var ErrPageNameNotSpecified = errors.New("Page Name not specified")
ErrPageNameNotSpecified is thrown if the name of the landing page is blank.
var ErrPageNotFound = errors.New("Page not found")
ErrPageNotFound indicates a page specified by the user does not exist in the database
var ErrPageNotSpecified = errors.New("No landing page specified")
ErrPageNotSpecified indicates a landing page was not provided for the campaign
var ErrSMTPNotFound = errors.New("Sending profile not found")
ErrSMTPNotFound indicates a sending profile specified by the user does not exist in the database
var ErrSMTPNotSpecified = errors.New("No sending profile specified")
ErrSMTPNotSpecified indicates a sending profile was not provided for the campaign
var ErrTemplateMissingParameter = errors.New("Need to specify at least plaintext or HTML content")
ErrTemplateMissingParameter is thrown when a needed parameter is not provided
var ErrTemplateNameNotSpecified = errors.New("Template name not specified")
ErrTemplateNameNotSpecified is thrown when a template name is not specified
var ErrTemplateNotFound = errors.New("Template not found")
ErrTemplateNotFound indicates the template specified does not exist in the database
var ErrTemplateNotSpecified = errors.New("No email template specified")
ErrTemplateNotSpecified indicates there was no template given by the user
var ErrUsernameTaken = errors.New("username already taken")
ErrUsernameTaken is thrown when a user attempts to register a username that is taken.
Logger is a global logger used to show informational, warning, and error messages
Functions ¶
func DeleteCampaign ¶
DeleteCampaign deletes the specified campaign
func DeleteGroup ¶
DeleteGroup deletes a given group by group ID and user ID
func DeletePage ¶
DeletePage deletes an existing page in the database. An error is returned if a page with the given user id and page id is not found.
func DeleteSMTP ¶ added in v0.1.2
DeleteSMTP deletes an existing SMTP in the database. An error is returned if a SMTP with the given user id and SMTP id is not found.
func DeleteTemplate ¶
DeleteTemplate deletes an existing template in the database. An error is returned if a template with the given user id and template id is not found.
func PostCampaign ¶
PostCampaign inserts a campaign and all associated records into the database.
func PostTemplate ¶
PostTemplate creates a new template in the database.
func PutPage ¶
PutPage edits an existing Page in the database. Per the PUT Method RFC, it presumes all data for a page is provided.
func PutSMTP ¶ added in v0.1.2
PutSMTP edits an existing SMTP in the database. Per the PUT Method RFC, it presumes all data for a SMTP is provided.
func PutTemplate ¶
PutTemplate edits an existing template in the database. Per the PUT Method RFC, it presumes all data for a template is provided.
Types ¶
type Attachment ¶
type Attachment struct { Id int64 `json:"-"` TemplateId int64 `json:"-"` Content string `json:"content"` Type string `json:"type"` Name string `json:"name"` }
Attachment contains the fields and methods for an email attachment
type Campaign ¶
type Campaign struct { Id int64 `json:"id"` UserId int64 `json:"-"` Name string `json:"name" sql:"not null"` CreatedDate time.Time `json:"created_date"` CompletedDate time.Time `json:"completed_date"` TemplateId int64 `json:"-"` Template Template `json:"template"` PageId int64 `json:"-"` Page Page `json:"page"` Status string `json:"status"` Results []Result `json:"results,omitempty"` Groups []Group `json:"groups,omitempty"` Events []Event `json:"timeline,omitemtpy"` SMTPId int64 `json:"-"` SMTP SMTP `json:"smtp"` URL string `json:"url"` }
Campaign is a struct representing a created campaign
func GetCampaign ¶
GetCampaign returns the campaign, if it exists, specified by the given id and user_id.
func GetCampaigns ¶
GetCampaigns returns the campaigns owned by the given user.
func (*Campaign) UpdateStatus ¶
UpdateStatus changes the campaign status appropriately
type Event ¶
type Event struct { Id int64 `json:"-"` CampaignId int64 `json:"-"` Email string `json:"email"` Time time.Time `json:"time"` Message string `json:"message"` Details string `json:"details"` }
Event contains the fields for an event that occurs during the campaign
type Group ¶
type Group struct { Id int64 `json:"id"` UserId int64 `json:"-"` Name string `json:"name"` ModifiedDate time.Time `json:"modified_date"` Targets []Target `json:"targets" sql:"-"` }
Group contains the fields needed for a user -> group mapping Groups contain 1..* Targets
func GetGroupByName ¶
GetGroupByName returns the group, if it exists, specified by the given name and user_id.
type GroupTarget ¶
GroupTarget is used for a many-to-many relationship between 1..* Groups and 1..* Targets
type Page ¶
type Page struct { Id int64 `json:"id" gorm:"column:id; primary_key:yes"` UserId int64 `json:"-" gorm:"column:user_id"` Name string `json:"name"` HTML string `json:"html" gorm:"column:html"` CaptureCredentials bool `json:"capture_credentials" gorm:"column:capture_credentials"` CapturePasswords bool `json:"capture_passwords" gorm:"column:capture_passwords"` ModifiedDate time.Time `json:"modified_date"` }
Page contains the fields used for a Page model
func GetPageByName ¶
GetPageByName returns the page, if it exists, specified by the given name and user_id.
type Response ¶
type Response struct { Message string `json:"message"` Success bool `json:"success"` Data interface{} `json:"data"` }
Response contains the attributes found in an API response
type Result ¶
type Result struct { Id int64 `json:"-"` CampaignId int64 `json:"-"` UserId int64 `json:"-"` RId string `json:"id"` Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Position string `json:"position"` Status string `json:"status" sql:"not null"` IP string `json:"ip"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` }
Result contains the fields for a result object, which is a representation of a target in a campaign.
func (*Result) GenerateId ¶
func (r *Result) GenerateId()
GenerateId generates a unique key to represent the result in the database
func (*Result) UpdateGeo ¶
UpdateGeo updates the latitude and longitude of the result in the database given an IP address
func (*Result) UpdateStatus ¶
UpdateStatus updates the status of the result in the database
type SMTP ¶
type SMTP struct { Id int64 `json:"id" gorm:"column:id; primary_key:yes"` UserId int64 `json:"-" gorm:"column:user_id"` Interface string `json:"interface_type" gorm:"column:interface_type"` Name string `json:"name"` Host string `json:"host"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` FromAddress string `json:"from_address"` IgnoreCertErrors bool `json:"ignore_cert_errors"` ModifiedDate time.Time `json:"modified_date"` }
SMTP contains the attributes needed to handle the sending of campaign emails
func GetSMTP ¶ added in v0.1.2
GetSMTP returns the SMTP, if it exists, specified by the given id and user_id.
func GetSMTPByName ¶ added in v0.1.2
GetSMTPByName returns the SMTP, if it exists, specified by the given name and user_id.
type SendTestEmailRequest ¶
type SendTestEmailRequest struct { Template Template `json:"template"` Page Page `json:"page"` SMTP SMTP `json:"smtp"` URL string `json:"url"` Tracker string `json:"tracker"` TrackingURL string `json:"tracking_url"` From string `json:"from"` Target }
SendTestEmailRequest is the structure of a request to send a test email to test an SMTP connection
func (*SendTestEmailRequest) Validate ¶
func (s *SendTestEmailRequest) Validate() error
Validate ensures the SendTestEmailRequest structure is valid.
type Target ¶
type Target struct { Id int64 `json:"-"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` Position string `json:"position"` }
Target contains the fields needed for individual targets specified by the user Groups contain 1..* Targets, but 1 Target may belong to 1..* Groups
func GetTargets ¶
GetTargets performs a many-to-many select to get all the Targets for a Group
type Template ¶
type Template struct { Id int64 `json:"id" gorm:"column:id; primary_key:yes"` UserId int64 `json:"-" gorm:"column:user_id"` Name string `json:"name"` Subject string `json:"subject"` Text string `json:"text"` HTML string `json:"html" gorm:"column:html"` ModifiedDate time.Time `json:"modified_date"` Attachments []Attachment `json:"attachments"` }
Template models hold the attributes for an email template to be sent to targets
func GetTemplate ¶
GetTemplate returns the template, if it exists, specified by the given id and user_id.
func GetTemplateByName ¶
GetTemplateByName returns the template, if it exists, specified by the given name and user_id.
func GetTemplates ¶
GetTemplates returns the templates owned by the given user.
type User ¶
type User struct { Id int64 `json:"id"` Username string `json:"username" sql:"not null;unique"` Hash string `json:"-"` ApiKey string `json:"api_key" sql:"not null;unique"` }
User represents the user model for gophish.
func GetUser ¶
GetUser returns the user that the given id corresponds to. If no user is found, an error is thrown.
func GetUserByAPIKey ¶
GetUserByAPIKey returns the user that the given API Key corresponds to. If no user is found, an error is thrown.
func GetUserByUsername ¶
GetUserByUsername returns the user that the given username corresponds to. If no user is found, an error is thrown.