Documentation ¶
Index ¶
- func CallbacksToInterfaces(callbacks []Callback) []interface{}
- func FilterResponse(response []interface{}, attributes []string) ([]map[string]interface{}, error)
- func HeaderToMap(header http.Header) map[string]interface{}
- func TaskFragmentsToInterfaces(taskFragments []TaskFragment) []interface{}
- func TasksToInterfaces(tasks []TaskFragment) []interface{}
- type ActiveCallbackQuery
- type Callback
- type CallbackPayload
- type CallbackPayloadType
- type CallbackQuery
- type CreateAPITokenMutation
- type CreateAPITokenVariables
- type CreateTaskMutation
- type GetAPITokensQuery
- type Mythic
- func (mythic *Mythic) AuthenticateToMythic() error
- func (m *Mythic) CreateAPIToken() error
- func (m *Mythic) ExecuteCustomQuery(query string, variables map[string]interface{}, result interface{}) error
- func (m *Mythic) FetchGraphQLSchema() (string, error)
- func (m *Mythic) GetAllActiveCallbacks(customReturnAttributes []string) ([]map[string]interface{}, error)
- func (m *Mythic) GetAllCallbacks(customReturnAttributes []string) ([]map[string]interface{}, error)
- func (m *Mythic) GetAllSubtaskIDs(taskDisplayID int, fetchDisplayIDInstead bool) ([]int, error)
- func (m *Mythic) GetAllTaskOutputByID(taskDisplayID int) ([]TaskOutputFragment, error)
- func (m *Mythic) GetAllTasks(callbackDisplayID *int, customReturnAttributes []string) ([]map[string]interface{}, error)
- func (m *Mythic) GetHTTPTransport() (http.RoundTripper, string)
- func (m *Mythic) GetHeaders() http.Header
- func (m *Mythic) GraphQLSubscription(ctx context.Context, subscription interface{}, ...) (<-chan interface{}, error)
- func (m *Mythic) GraphqlPost(operation interface{}, variables map[string]interface{}, operationType string) error
- func (mythic *Mythic) HandleAPITokens() error
- func (m *Mythic) HttpGet(url string) ([]byte, error)
- func (m *Mythic) HttpGetChunked(url string, chunkSize int) (<-chan []byte, error)
- func (m *Mythic) HttpGetDictionary(url string) (map[string]interface{}, error)
- func (m *Mythic) HttpPost(url string, data map[string]interface{}) (map[string]interface{}, error)
- func (m *Mythic) HttpPostForm(data url.Values, url string) (map[string]interface{}, error)
- func (m *Mythic) IssueTask(commandName string, parameters interface{}, callbackDisplayID int, ...) (*CreateTaskMutation, error)
- func (m *Mythic) IssueTaskAndWaitForOutput(commandName string, parameters interface{}, callbackDisplayId int, tokenId int, ...) ([]byte, error)
- func (m *Mythic) LoadMythicSchema() bool
- func (mythic *Mythic) SetMythicDetails(serverIP string, serverPort int, username, password, apiToken string, ssl bool, ...) *graphql.Client
- func (m *Mythic) String() string
- func (m *Mythic) WaitForTaskComplete(taskDisplayID int, customReturnAttributes *string, timeout *int) (*CreateTaskMutation, error)
- func (m *Mythic) WaitForTaskOutput(taskDisplayID int, timeout *int) ([]byte, error)
- type MythicManager
- type MythicStatus
- type MythicWebSocketHandler
- func (h *MythicWebSocketHandler) Close() error
- func (h *MythicWebSocketHandler) GetCloseStatus(err error) int32
- func (h *MythicWebSocketHandler) Ping() error
- func (h *MythicWebSocketHandler) ReadJSON(v interface{}) error
- func (h *MythicWebSocketHandler) SetReadLimit(limit int64)
- func (h *MythicWebSocketHandler) WriteJSON(v interface{}) error
- type Task
- type TaskFragment
- type TaskOutput
- type TaskOutputFragment
- type TaskQuery
- type TaskQueryWithCallback
- type TaskWaitForOutputSubscription
- type TaskWaitForOutputSubscriptionVariables
- type TaskWaitForStatusSubscription
- type TaskWaitForStatusSubscriptionVariables
- type UpdateCallbackInformationMutation
- type UserOutputFragment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallbacksToInterfaces ¶
func CallbacksToInterfaces(callbacks []Callback) []interface{}
Convert []Callback to []interface{}
func FilterResponse ¶
FilterResponse filters the response according to the provided attributes.
func HeaderToMap ¶
HeaderToMap is assumed to convert http.Header to a map[string]interface{} type. Replace this with your actual function if it is different.
func TaskFragmentsToInterfaces ¶
func TaskFragmentsToInterfaces(taskFragments []TaskFragment) []interface{}
func TasksToInterfaces ¶
func TasksToInterfaces(tasks []TaskFragment) []interface{}
Convert []TaskFragment to []interface{}
Types ¶
type ActiveCallbackQuery ¶
type ActiveCallbackQuery struct {
Callback []Callback `graphql:"callback(where: {active: {_eq: true}}, order_by: {id: asc})"`
}
type Callback ¶
type Callback struct { Architecture string `graphql:"architecture"` Description string `graphql:"description"` Domain string `graphql:"domain"` ExternalIP string `graphql:"external_ip"` Host string `graphql:"host"` ID int `graphql:"id"` DisplayID int `graphql:"display_id"` IntegrityLevel int `graphql:"integrity_level"` IP string `graphql:"ip"` ExtraInfo string `graphql:"extra_info"` SleepInfo string `graphql:"sleep_info"` PID int `graphql:"pid"` OS string `graphql:"os"` User string `graphql:"user"` AgentCallbackID string `graphql:"agent_callback_id"` OperationID int `graphql:"operation_id"` ProcessName string `graphql:"process_name"` Payload CallbackPayload `graphql:"payload"` }
Defining struct for Callback
type CallbackPayload ¶
type CallbackPayload struct { OS string `graphql:"os"` PayloadType CallbackPayloadType `graphql:"payloadtype"` Description string `graphql:"description"` UUID string `graphql:"uuid"` }
Defining struct for Payload
type CallbackPayloadType ¶
type CallbackPayloadType struct {
Name string `graphql:"name"`
}
Defining struct for PayloadType
type CallbackQuery ¶
type CallbackQuery struct {
Callback []Callback `graphql:"callback(order_by: {id: asc})"`
}
type CreateAPITokenMutation ¶
type CreateAPITokenVariables ¶
type CreateAPITokenVariables struct {
TokenType string `graphql:"token_type"`
}
type CreateTaskMutation ¶
type CreateTaskMutation struct { CreateTask struct { Status MythicStatus `graphql:"status"` ID int `graphql:"id"` DisplayID int `graphql:"display_id"` Error string `graphql:"error"` } `` /* 221-byte string literal not displayed */ }
type GetAPITokensQuery ¶
type Mythic ¶
type Mythic struct { Username string `json:"username"` Password string `json:"password"` APIToken string `json:"apitoken"` AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ServerIP string `json:"server_ip"` ServerPort int `json:"server_port"` SSL bool `json:"ssl"` HTTP string `json:"-"` WS string `json:"-"` GlobalTimeout int `json:"global_timeout"` ScriptingVersion string `json:"scripting_version"` CurrentOperationID int `json:"current_operation_id"` Schema string `json:"schema"` }
func Login ¶
func Login(mythicManager *MythicManager, serverIP string, serverPort int, username, password, apiToken string, ssl bool, timeout, loggingLevel int) (*Mythic, error)
Login sets up a new Mythic instance and tries to authenticate with the provided credentials or API token.
func (*Mythic) AuthenticateToMythic ¶
AuthenticateToMythic function sends a POST request to authenticate to the Mythic server with the provided username and password.
func (*Mythic) CreateAPIToken ¶
CreateAPIToken function sends a GraphQL mutation to the Mythic server to create a new API token.
func (*Mythic) ExecuteCustomQuery ¶
func (m *Mythic) ExecuteCustomQuery(query string, variables map[string]interface{}, result interface{}) error
ExecuteCustomQuery sends a custom GraphQL query to the server and unmarshals the response into result.
func (*Mythic) FetchGraphQLSchema ¶
UNTESTED FetchGraphQLSchema function sends an HTTP GET request to the Mythic server to retrieve the GraphQL schema and returns it as a string.
func (*Mythic) GetAllActiveCallbacks ¶
func (m *Mythic) GetAllActiveCallbacks(customReturnAttributes []string) ([]map[string]interface{}, error)
GetAllActiveCallbacks sends a GraphQL query to fetch all active callbacks from the server.
func (*Mythic) GetAllCallbacks ¶
GetAllCallbacks sends a GraphQL query to fetch all callbacks from the server.
func (*Mythic) GetAllSubtaskIDs ¶
This function gets all the subtask IDs for a particular task, identified by its DisplayID. If fetchDisplayIDInstead is true, it fetches DisplayIDs instead of normal IDs.
func (*Mythic) GetAllTaskOutputByID ¶
func (m *Mythic) GetAllTaskOutputByID(taskDisplayID int) ([]TaskOutputFragment, error)
This function retrieves all the output for a specific task, identified by its DisplayID.
func (*Mythic) GetAllTasks ¶
func (m *Mythic) GetAllTasks(callbackDisplayID *int, customReturnAttributes []string) ([]map[string]interface{}, error)
GetAllTasks sends a GraphQL query to fetch all tasks associated with a callback from the server.
func (*Mythic) GetHTTPTransport ¶
func (m *Mythic) GetHTTPTransport() (http.RoundTripper, string)
GetHTTPTransport function sets up the HTTP transport using the defined server configuration in Mythic struct. It also sets up custom headers for the requests using the GetHeaders function.
func (*Mythic) GetHeaders ¶
GetHeaders function sets up the custom headers for the request based on the provided API token or Access token in the Mythic struct.
func (*Mythic) GraphQLSubscription ¶
func (m *Mythic) GraphQLSubscription(ctx context.Context, subscription interface{}, variables map[string]interface{}, timeout int) (<-chan interface{}, error)
GraphQLSubscription function sets up the GraphQL subscription using the provided parameters.
func (*Mythic) GraphqlPost ¶
func (m *Mythic) GraphqlPost(operation interface{}, variables map[string]interface{}, operationType string) error
GraphqlPost function performs a GraphQL query or mutation using the Hasura GraphQL client.
func (*Mythic) HandleAPITokens ¶
HandleAPITokens function fetches the API tokens associated with the user from the Mythic server using a GraphQL query.
func (*Mythic) HttpGet ¶
UNTESTED HttpGet function sends a GET request to the specified URL and returns the raw response.
func (*Mythic) HttpGetChunked ¶
UNTESTED HttpGetChunked function sends a GET request to the specified URL and returns the response in chunks.
func (*Mythic) HttpGetDictionary ¶
UNTESTED HttpGetDictionary function sends a GET request to the specified URL and returns the response as a dictionary.
func (*Mythic) HttpPost ¶
HttpPost function sends a POST request to the specified URL with the provided data as JSON. The request is sent using the HTTP transport set up in the GetHTTPTransport function.
func (*Mythic) HttpPostForm ¶
UNTESTED HttpPostForm function sends a POST request to the specified URL with the provided data as form values.
func (*Mythic) IssueTask ¶
func (m *Mythic) IssueTask(commandName string, parameters interface{}, callbackDisplayID int, tokenID *int, originalParams interface{}, parameterGroupName interface{}, waitForComplete bool, timeout *int) (*CreateTaskMutation, error)
IssueTask sends a task to a callback and optionally waits for it to complete.
func (*Mythic) IssueTaskAndWaitForOutput ¶
func (m *Mythic) IssueTaskAndWaitForOutput(commandName string, parameters interface{}, callbackDisplayId int, tokenId int, originalParams interface{}, parameterGroupName interface{}, waitForComplete bool, timeout int) ([]byte, error)
IssueTaskAndWaitForOutput sends a task to a callback, waits for it to complete, and then retrieves its output.
func (*Mythic) LoadMythicSchema ¶
UNTESTED LoadMythicSchema function fetches the GraphQL schema from the Mythic server and stores it in the Mythic struct.
func (*Mythic) SetMythicDetails ¶
func (mythic *Mythic) SetMythicDetails(serverIP string, serverPort int, username, password, apiToken string, ssl bool, timeout int) *graphql.Client
SetMythicDetails function sets up the Mythic struct with the provided server details and returns a new GraphQL client.
func (*Mythic) WaitForTaskComplete ¶
func (m *Mythic) WaitForTaskComplete(taskDisplayID int, customReturnAttributes *string, timeout *int) (*CreateTaskMutation, error)
WaitForTaskComplete subscribes to task updates and waits for the task to complete or fail.
func (*Mythic) WaitForTaskOutput ¶
This function is responsible for waiting for the output of a specific task
identified by its display ID. The output will be collected and returned as a byte array. A timeout can be provided to stop waiting after a specific duration.
type MythicManager ¶
type MythicManager struct {
// contains filtered or unexported fields
}
func NewMythicManager ¶
func NewMythicManager() *MythicManager
func (*MythicManager) GetMythicInstance ¶
func (mm *MythicManager) GetMythicInstance() *Mythic
func (*MythicManager) InvalidateMythicInstance ¶
func (mm *MythicManager) InvalidateMythicInstance()
type MythicStatus ¶
type MythicStatus string
const ( Error MythicStatus = "error" Completed MythicStatus = "completed" Processed MythicStatus = "processed" Processing MythicStatus = "processing" Preprocessing MythicStatus = "preprocessing" Delegating MythicStatus = "delegating" Submitted MythicStatus = "submitted" )
func (MythicStatus) Equals ¶
func (s MythicStatus) Equals(obj interface{}) bool
func (MythicStatus) GreaterThanOrEqual ¶
func (s MythicStatus) GreaterThanOrEqual(obj interface{}) bool
func (MythicStatus) String ¶
func (s MythicStatus) String() string
type MythicWebSocketHandler ¶
type MythicWebSocketHandler struct { Conn *websocket.Conn // contains filtered or unexported fields }
func (*MythicWebSocketHandler) Close ¶
func (h *MythicWebSocketHandler) Close() error
Close function closes the WebSocket connection.
func (*MythicWebSocketHandler) GetCloseStatus ¶
func (h *MythicWebSocketHandler) GetCloseStatus(err error) int32
GetCloseStatus function gets the close status of the WebSocket connection.
func (*MythicWebSocketHandler) Ping ¶
func (h *MythicWebSocketHandler) Ping() error
Ping sends a ping message through the WebSocket connection This is a simple implementation and might need to be adjusted based on actual requirements
func (*MythicWebSocketHandler) ReadJSON ¶
func (h *MythicWebSocketHandler) ReadJSON(v interface{}) error
ReadJSON function reads JSON data from the WebSocket connection.
func (*MythicWebSocketHandler) SetReadLimit ¶
func (h *MythicWebSocketHandler) SetReadLimit(limit int64)
SetReadLimit function sets the read limit for the WebSocket connection.
func (*MythicWebSocketHandler) WriteJSON ¶
func (h *MythicWebSocketHandler) WriteJSON(v interface{}) error
WriteJSON function writes JSON data to the WebSocket connection.
type Task ¶
type Task struct {
Responses []UserOutputFragment `graphql:"responses(order_by: {id: asc})"`
}
type TaskFragment ¶
type TaskFragment struct { Callback struct { ID int `graphql:"id"` DisplayID int `graphql:"display_id"` } `graphql:"callback"` ID int `graphql:"id"` DisplayID int `graphql:"display_id"` Operator struct { Username string `graphql:"username"` } `graphql:"operator"` Status MythicStatus `graphql:"status"` Completed bool `graphql:"completed"` OriginalParams string `graphql:"original_params"` DisplayParams string `graphql:"display_params"` Timestamp string `graphql:"timestamp"` CommandName string `graphql:"command_name"` Tasks []struct { ID int `graphql:"id"` } `graphql:"tasks"` Token struct { TokenID string `graphql:"token_id"` } `graphql:"token"` }
type TaskOutput ¶
type TaskOutput struct {
Response []TaskOutputFragment `graphql:"response(order_by: {id: asc}, where: {task:{display_id: {_eq: $task_display_id}}})"`
}
type TaskOutputFragment ¶
type TaskOutputFragment struct { ID int `graphql:"id"` Timestamp string `graphql:"timestamp"` ResponseText string `graphql:"response_text"` Task struct { ID int `graphql:"id"` DisplayID int `graphql:"display_id"` Status MythicStatus `graphql:"status"` Completed bool `graphql:"completed"` AgentTaskID string `graphql:"agent_task_id"` CommandName string `graphql:"command_name"` } `graphql:"task"` }
type TaskQuery ¶
type TaskQuery struct {
Task []TaskFragment `graphql:"task(order_by: {id: desc})"`
}
type TaskQueryWithCallback ¶
type TaskQueryWithCallback struct {
Task []TaskFragment `graphql:"task(where: {callback: {display_id: {_eq: $callbackDisplayID}}}, order_by: {id: asc})"`
}
type TaskWaitForOutputSubscription ¶
type TaskWaitForOutputSubscription struct {
TaskStream []Task `` /* 130-byte string literal not displayed */
}
type TaskWaitForOutputSubscriptionVariables ¶
type TaskWaitForOutputSubscriptionVariables struct {
DisplayID int `graphql:"display_id"`
}
type TaskWaitForStatusSubscription ¶
type TaskWaitForStatusSubscription struct {
TaskStream []TaskFragment `` /* 130-byte string literal not displayed */
}
type TaskWaitForStatusSubscriptionVariables ¶
type TaskWaitForStatusSubscriptionVariables struct {
DisplayID int `graphql:"display_id"`
}
type UpdateCallbackInformationMutation ¶
type UpdateCallbackInformationMutation struct { UpdateCallback struct { Status MythicStatus `graphql:"status"` Error string `graphql:"error"` } `` /* 295-byte string literal not displayed */ }