api

package
v0.0.0-...-bfc522d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RESULT_ACTION_OPEN   = 0
	RESULT_ACTION_CLICK  = iota
	RESULT_ACTION_SUBMIT = iota
)
View Source
const (
	CacheTypeModules     = "modules"
	CacheTypeRedirectors = "redirectors"
)

Cache type constants

View Source
const (
	CLOUDFLARE_URL = "https://api.cloudflare.com"
)

Variables

View Source
var ErrEmptyRole = errors.New("No role specified")

ErrEmptyRole is throws when no role is provided when creating or modifying a user.

View Source
var ErrEmptyUsername = errors.New("No username provided")

ErrEmptyUsername is thrown when a user attempts to register a username that is taken.

View Source
var ErrInsufficientPermission = errors.New("Permission denied")

ErrInsufficientPermission is thrown when a user attempts to change an attribute (such as the role) for which they don't have permission.

View Source
var ErrUsernameTaken = errors.New("Username already taken")

ErrUsernameTaken is thrown when a user attempts to register a username that is taken.

Functions

func JSONResponse

func JSONResponse(w http.ResponseWriter, d interface{}, c int)

JSONResponse attempts to set the status code, c, and marshal the given interface, d, into a response that is written to the given ResponseWriter.

Types

type CloudflareAccountResponse

type CloudflareAccountResponse struct {
	Result []struct {
		ID string `json:"id"`
	} `json:"result"`
	Success bool `json:"success"`
}

type CloudflareConfig

type CloudflareConfig struct {
	NS1        string   `json:"ns1"`
	NS2        string   `json:"ns2"`
	DNSRecords []string `json:"dns_records"`
	// CloudflareToken string   `json:"cloudflare_token"`
	Status string `json:"status"`
}

type CloudflareDNSRecord

type CloudflareDNSRecord struct {
	ID      string `json:"id"`
	Type    string `json:"type"`
	Name    string `json:"name"`
	Content string `json:"content"`
	TTL     int    `json:"ttl"`
	Proxied bool   `json:"proxied"`
}

type CloudflareDNSRecordsResponse

type CloudflareDNSRecordsResponse struct {
	Result  []CloudflareDNSRecord `json:"result"`
	Success bool                  `json:"success"`
}

type CloudflareSingleZoneResponse

type CloudflareSingleZoneResponse struct {
	Result []struct {
		ID          string   `json:"id"`
		NameServers []string `json:"name_servers"`
		Status      string   `json:"status"`
	} `json:"result"`
	Success bool `json:"success"`
}

type CloudflareZone

type CloudflareZone struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
	// Paused      bool     `json:"paused"`
	// Type        string   `json:"type"`
	NameServers []string `json:"name_servers"`
}

type CloudflareZonesResponse

type CloudflareZonesResponse struct {
	Result  []CloudflareZone `json:"result"`
	Success bool             `json:"success"`
}

type Config

type Config struct {
	Domain           string `json:"domain"`
	IPv4             string `json:"external_ipv4"`
	UnauthURL        string `json:"unauth_url"`
	GophishAdminURL  string `json:"gophish_admin_url"`
	GophishAdmin_key string `json:"gophish_api_key"`
	GophishInsecure  bool   `json:"gophish_insecure"`
}

type EC2StatusResponse

type EC2StatusResponse struct {
	InstanceID   string `json:"instance_id"`
	State        string `json:"state"`
	PublicIP     string `json:"public_ip,omitempty"`
	Region       string `json:"region"`
	ScreenStatus string `json:"status,omitempty"`
}

EC2StatusResponse represents the response from EC2 status endpoint

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	Success bool   `json:"success"`
	APIKey  string `json:"api_key"`
	Message string `json:"message,omitempty"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(options ...ServerOption) *Server

NewServer returns a new instance of the API handler with the provided options applied.

func (*Server) CallSimulationServer

func (as *Server) CallSimulationServer(campaign string) error

CallSimulationServer makes an authenticated call to the TrustStrike server

func (*Server) Campaign

func (as *Server) Campaign(w http.ResponseWriter, r *http.Request)

Campaign returns details about the requested campaign. If the campaign is not valid, APICampaign returns null.

func (*Server) CampaignComplete

func (as *Server) CampaignComplete(w http.ResponseWriter, r *http.Request)

CampaignComplete effectively "ends" a campaign. Future phishing emails clicked will return a simple "404" page.

func (*Server) CampaignResults

func (as *Server) CampaignResults(w http.ResponseWriter, r *http.Request)

CampaignResults returns just the results for a given campaign to significantly reduce the information returned.

func (*Server) CampaignSummary

func (as *Server) CampaignSummary(w http.ResponseWriter, r *http.Request)

CampaignSummary returns the summary for a given campaign.

func (*Server) Campaigns

func (as *Server) Campaigns(w http.ResponseWriter, r *http.Request)

Campaigns returns a list of campaigns if requested via GET. If requested via POST, APICampaigns creates a new campaign and returns a reference to it.

func (*Server) CampaignsSummary

func (as *Server) CampaignsSummary(w http.ResponseWriter, r *http.Request)

CampaignsSummary returns the summary for the current user's campaigns

func (*Server) CancelBulkImport

func (as *Server) CancelBulkImport(w http.ResponseWriter, r *http.Request)

CancelBulkImport cancels a running bulk import job

func (*Server) CommitBulkImport

func (as *Server) CommitBulkImport(w http.ResponseWriter, r *http.Request)

CommitBulkImport starts the background import job

func (*Server) CreateCloudflareDNSRecord

func (as *Server) CreateCloudflareDNSRecord(zoneID, name, content, token string) error

func (*Server) CreateCloudflareZone

func (as *Server) CreateCloudflareZone(domain, accountID, token string) error

func (*Server) CreateDNSRecord

func (as *Server) CreateDNSRecord(w http.ResponseWriter, r *http.Request)

func (*Server) CreateRedirector

func (as *Server) CreateRedirector(w http.ResponseWriter, r *http.Request)

CreateRedirector proxies the request to create a new redirector and invalidates cache

func (*Server) CreateStrike

func (as *Server) CreateStrike(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteCloudflareDNSRecord

func (as *Server) DeleteCloudflareDNSRecord(zoneID, recordID, token string) error

func (*Server) DeleteDNSRecord

func (as *Server) DeleteDNSRecord(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteRedirector

func (as *Server) DeleteRedirector(w http.ResponseWriter, r *http.Request)

DeleteRedirector proxies the request to delete a redirector and invalidates cache

func (*Server) DeleteStrike

func (as *Server) DeleteStrike(w http.ResponseWriter, r *http.Request)

DeleteStrike proxies the request to delete a strike

func (*Server) EditStrike

func (as *Server) EditStrike(w http.ResponseWriter, r *http.Request)

EditStrike proxies the request to edit a strike

func (*Server) FetchAllDomains

func (as *Server) FetchAllDomains(w http.ResponseWriter, r *http.Request)

GetAllDomains is the API handler to fetch all domains

func (*Server) FetchDNSRecords

func (as *Server) FetchDNSRecords(w http.ResponseWriter, r *http.Request)

func (*Server) GetAPI

func (as *Server) GetAPI(w http.ResponseWriter, r *http.Request)

func (*Server) GetActiveJobs

func (as *Server) GetActiveJobs(w http.ResponseWriter, r *http.Request)

GetActiveJobs returns all active jobs for the current user

func (*Server) GetCloudflareAccountID

func (as *Server) GetCloudflareAccountID(token string) (string, error)

func (*Server) GetCloudflareConfig

func (as *Server) GetCloudflareConfig(w http.ResponseWriter, r *http.Request)

func (*Server) GetCloudflareDNSRecords

func (as *Server) GetCloudflareDNSRecords(zoneID string, token string) ([]CloudflareDNSRecord, error)

func (*Server) GetConfig

func (as *Server) GetConfig(w http.ResponseWriter, r *http.Request)

func (*Server) GetDNSRecords

func (as *Server) GetDNSRecords(domain string, token string) (*CloudflareConfig, error)

func (*Server) GetDomainsList

func (as *Server) GetDomainsList(token string) ([]CloudflareZone, error)

func (*Server) GetEC2Status

func (as *Server) GetEC2Status(w http.ResponseWriter, r *http.Request)

GetEC2Status returns the current status of the EC2 instance

func (*Server) GetJobStatus

func (as *Server) GetJobStatus(w http.ResponseWriter, r *http.Request)

GetJobStatus returns the status of a job

func (*Server) GetModules

func (as *Server) GetModules(w http.ResponseWriter, r *http.Request)

GetModules returns modules exclusively from the database cache while triggering a background sync/stop sequence

func (*Server) GetPhishletHosts

func (as *Server) GetPhishletHosts(w http.ResponseWriter, r *http.Request)

GetPhishletHosts proxies the request to get hosts for a phishlet

func (*Server) GetRedirector

func (as *Server) GetRedirector(w http.ResponseWriter, r *http.Request)

GetRedirector proxies the request to get a single redirector's details

func (*Server) GetRedirectors

func (as *Server) GetRedirectors(w http.ResponseWriter, r *http.Request)

GetRedirectors returns available redirectors exclusively from the database cache while triggering a background refresh

func (*Server) GetStrikes

func (as *Server) GetStrikes(w http.ResponseWriter, r *http.Request)

GetStrikes proxies the request to get all strikes

func (*Server) Group

func (as *Server) Group(w http.ResponseWriter, r *http.Request)

Group returns details about the requested group. If the group is not valid, Group returns null.

func (*Server) GroupSummary

func (as *Server) GroupSummary(w http.ResponseWriter, r *http.Request)

GroupSummary returns a summary of the groups owned by the current user.

func (*Server) Groups

func (as *Server) Groups(w http.ResponseWriter, r *http.Request)

Groups returns a list of groups if requested via GET. If requested via POST, APIGroups creates a new group and returns a reference to it.

func (*Server) GroupsSummary

func (as *Server) GroupsSummary(w http.ResponseWriter, r *http.Request)

GroupsSummary returns a summary of the groups owned by the current user.

func (*Server) IMAPServer

func (as *Server) IMAPServer(w http.ResponseWriter, r *http.Request)

IMAPServer handles requests for the /api/imapserver/ endpoint

func (*Server) IMAPServerValidate

func (as *Server) IMAPServerValidate(w http.ResponseWriter, r *http.Request)

IMAPServerValidate handles requests for the /api/imapserver/validate endpoint

func (*Server) ImportEmail

func (as *Server) ImportEmail(w http.ResponseWriter, r *http.Request)

ImportEmail allows for the importing of email. Returns a Message object

func (*Server) ImportGroup

func (as *Server) ImportGroup(w http.ResponseWriter, r *http.Request)

ImportGroup imports a CSV of group members

func (*Server) ImportSite

func (as *Server) ImportSite(w http.ResponseWriter, r *http.Request)

ImportSite allows for the importing of HTML from a website Without "include_resources" set, it will merely place a "base" tag so that all resources can be loaded relative to the given URL.

func (*Server) Page

func (as *Server) Page(w http.ResponseWriter, r *http.Request)

Page contains functions to handle the GET'ing, DELETE'ing, and PUT'ing of a Page object

func (*Server) Pages

func (as *Server) Pages(w http.ResponseWriter, r *http.Request)

Pages handles requests for the /api/pages/ endpoint

func (*Server) PhishletsProxy

func (as *Server) PhishletsProxy(w http.ResponseWriter, r *http.Request)

PhishletsProxy proxies requests to the underlying simulation server

func (*Server) ProvisionCertificate

func (as *Server) ProvisionCertificate(w http.ResponseWriter, r *http.Request)

func (*Server) RefreshAllCaches

func (as *Server) RefreshAllCaches(preventAutoStop bool)

RefreshAllCaches forces an update of redirectors and modules from the simulation server. RefreshAllCaches forces an update of redirectors and modules from the simulation server.

func (*Server) ResultClick

func (as *Server) ResultClick(w http.ResponseWriter, r *http.Request)

func (*Server) ResultOpen

func (as *Server) ResultOpen(w http.ResponseWriter, r *http.Request)

func (*Server) ResultSubmit

func (as *Server) ResultSubmit(w http.ResponseWriter, r *http.Request)

func (*Server) SMSCampaigns

func (as *Server) SMSCampaigns(w http.ResponseWriter, r *http.Request)

Campaigns returns a list of campaigns if requested via GET. If requested via POST, APICampaigns creates a new campaign and returns a reference to it.

func (*Server) SMSProfile

func (as *Server) SMSProfile(w http.ResponseWriter, r *http.Request)

SMSProfile contains functions to handle the GET'ing, DELETE'ing, and PUT'ing of a SMS profile object

func (*Server) SMSProfiles

func (as *Server) SMSProfiles(w http.ResponseWriter, r *http.Request)

SMSProfiles handles requests for the /api/sms/ endpoint

func (*Server) SendTestEmail

func (as *Server) SendTestEmail(w http.ResponseWriter, r *http.Request)

SendTestEmail sends a test email using the template name and Target given.

func (*Server) SendingProfile

func (as *Server) SendingProfile(w http.ResponseWriter, r *http.Request)

SendingProfile contains functions to handle the GET'ing, DELETE'ing, and PUT'ing of a SMTP object

func (*Server) SendingProfiles

func (as *Server) SendingProfiles(w http.ResponseWriter, r *http.Request)

SendingProfiles handles requests for the /api/smtp/ endpoint

func (*Server) ServeHTTP

func (as *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetCloudflare

func (as *Server) SetCloudflare(w http.ResponseWriter, r *http.Request)

Cloudflare API's -------

func (*Server) SetDNS

func (as *Server) SetDNS(w http.ResponseWriter, r *http.Request)

SetDNS proxies the request to set DNS configuration

func (*Server) SetDomain

func (as *Server) SetDomain(w http.ResponseWriter, r *http.Request)

SetDomain proxies the request to set the domain

func (*Server) SetGophish

func (as *Server) SetGophish(w http.ResponseWriter, r *http.Request)

SetGophish proxies the request to set gophish configuration

func (*Server) SetIPv4

func (as *Server) SetIPv4(w http.ResponseWriter, r *http.Request)

SetIPv4 proxies the request to set the external IPv4

func (*Server) SetPhishletHostname

func (as *Server) SetPhishletHostname(w http.ResponseWriter, r *http.Request)

SetPhishletHostname proxies the request to set the hostname for a phishlet

func (*Server) SetPhishletLandingDomain

func (as *Server) SetPhishletLandingDomain(w http.ResponseWriter, r *http.Request)

SetPhishletLandingDomain proxies the request to set the landing domain for a phishlet

func (*Server) SetUnauthURL

func (as *Server) SetUnauthURL(w http.ResponseWriter, r *http.Request)

SetUnauthURL proxies the request to set the unauth URL

func (*Server) SetupCloudflare

func (as *Server) SetupCloudflare(w http.ResponseWriter, r *http.Request)

func (*Server) StartEC2Instance

func (as *Server) StartEC2Instance(w http.ResponseWriter, r *http.Request)

StartEC2Instance starts the EC2 instance and optionally starts evil

func (*Server) StartEC2ShutdownScheduler

func (as *Server) StartEC2ShutdownScheduler()

StartEC2ShutdownScheduler runs a background goroutine that checks if EC2 should be shut down

func (*Server) StopEC2Instance

func (as *Server) StopEC2Instance(w http.ResponseWriter, r *http.Request)

StopEC2Instance stops the EC2 instance

func (*Server) SyncCloudflareDNS

func (as *Server) SyncCloudflareDNS(domain, ip, token string) error

SyncCloudflareDNS ensures the A record for the domain points to the given IP

func (*Server) Template

func (as *Server) Template(w http.ResponseWriter, r *http.Request)

Template handles the functions for the /api/templates/:id endpoint

func (*Server) Templates

func (as *Server) Templates(w http.ResponseWriter, r *http.Request)

Templates handles the functionality for the /api/templates endpoint

func (*Server) TogglePhishlet

func (as *Server) TogglePhishlet(w http.ResponseWriter, r *http.Request)

TogglePhishlet proxies the request to toggle a phishlet

func (*Server) TriggerStrike

func (as *Server) TriggerStrike(w http.ResponseWriter, r *http.Request)

TriggerStrike handles the API request to trigger a strike

func (*Server) UpdateCloudflareDNSRecord

func (as *Server) UpdateCloudflareDNSRecord(zoneID, recordID, name, content, token string) error

UpdateCloudflareDNSRecord updates an existing DNS record

func (*Server) UpdatePhishletSubdomain

func (as *Server) UpdatePhishletSubdomain(w http.ResponseWriter, r *http.Request)

UpdatePhishletSubdomain proxies the request to update phish_sub and orig_sub on the simulation server

func (*Server) UpdateRedirector

func (as *Server) UpdateRedirector(w http.ResponseWriter, r *http.Request)

UpdateRedirector proxies the request to update a redirector and invalidates cache

func (*Server) UpdateRemoteIPv4

func (as *Server) UpdateRemoteIPv4(ip string) error

UpdateRemoteIPv4 updates the IPv4 config on the simulation server

func (*Server) UpdateSimulationServerGophishConfig

func (as *Server) UpdateSimulationServerGophishConfig(r *http.Request, apiKey string) error

UpdateSimulationServerGophishConfig pushes the current Gophish admin URL and API key to the simulation server. This is triggered from the backend when a new campaign cycle begins (e.g., EC2 start).

func (*Server) UploadBulkCSV

func (as *Server) UploadBulkCSV(w http.ResponseWriter, r *http.Request)

UploadBulkCSV handles uploading the file and returning a preview

func (*Server) User

func (as *Server) User(w http.ResponseWriter, r *http.Request)

User contains functions to retrieve or delete a single user. Users with the ModifySystem permission can view and modify any user. Otherwise, users may only view or delete their own account.

func (*Server) Users

func (as *Server) Users(w http.ResponseWriter, r *http.Request)

Users contains functions to retrieve a list of existing users or create a new user. Users with the ModifySystem permissions can view and create users.

func (*Server) ValidateWebhook

func (as *Server) ValidateWebhook(w http.ResponseWriter, r *http.Request)

ValidateWebhook makes an HTTP request to a specified remote url to ensure that it's valid.

func (*Server) Webhook

func (as *Server) Webhook(w http.ResponseWriter, r *http.Request)

Webhook returns details of a single webhook specified by "id" parameter

func (*Server) Webhooks

func (as *Server) Webhooks(w http.ResponseWriter, r *http.Request)

Webhooks returns a list of webhooks, both active and disabled

type ServerOption

type ServerOption func(*Server)

ServerOption is an option to apply to the API server.

func WithConfig

func WithConfig(cfg *config.Config) ServerOption

func WithLimiter

func WithLimiter(limiter *ratelimit.PostLimiter) ServerOption

func WithWorker

func WithWorker(w worker.Worker) ServerOption

WithWorker is an option that sets the background worker.

type Strike

type Strike struct {
	ID          int    `json:"id"`
	URL         string `json:"url"`
	RedirectURL string `json:"redirect_url"`
	Module      string `json:"module"`
	LurPath     string `json:"lure_path"`
	Redirector  string `json:"redirector"`
	LandingUrl  string `json:"landing_url"`
}

Strike definition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL