utils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: GPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskConfirmation

func AskConfirmation(message string) bool

AskConfirmation will request confirmation from the user

func DisplayInformationsGUI

func DisplayInformationsGUI(profile map[string]interface{}, advancedLabsMap map[string]map[string]interface{})

Initializes and displays user information in tview

func GetActiveExpiredTime added in v1.5.0

func GetActiveExpiredTime() (string, error)

GetActiveExpiredTime returns the expired date of the active machine

func GetActiveMachineID

func GetActiveMachineID() (string, error)

GetActiveMachineID returns the id of the active machine

func GetActiveMachineIP

func GetActiveMachineIP() (string, error)

GetActiveMachineIP returns the ip of the active machine

func GetCurrentUsername added in v1.5.0

func GetCurrentUsername() string

GetCurrentUsername retrieves the current system user's name.

func GetHTBToken

func GetHTBToken() (string, error)

GetHTBToken checks whether the HTB_TOKEN environment variable exists

func GetInformationsFromActiveMachine

func GetInformationsFromActiveMachine() (map[string]interface{}, error)

func GetMachineType

func GetMachineType(machine_id interface{}) (string, error)

GetMachineType will return the machine type

func GetUserSubscription

func GetUserSubscription() (string, error)

GetUserSubscription returns the user's subscription level

func HTTPRequest

func HTTPRequest(method string, urlParam string, jsonData []byte) (*http.Response, error)

HTTPRequest makes an HTTP request with the specified method, URL, proxy settings, and data.

func HtbRequest

func HtbRequest(method string, urlParam string, jsonData []byte) (*http.Response, error)

HtbRequest makes an HTTP request to the Hackthebox API

func ParseAndFormatDate

func ParseAndFormatDate(input string) (string, error)

ParseAndFormatDate takes an input date string, parses it into a time.Time object, and formats it to the "2006-01-02" format.

func ParseJsonMessage

func ParseJsonMessage(resp *http.Response, key string) interface{}

ParseJsonMessage will parse the result of the API request into a JSON

func SearchItemIDByName

func SearchItemIDByName(item string, element_type string) (string, error)

SearchItemIDByName will return the id of an item (machine / challenge / user) based on its name

func SetRetiredStatus

func SetRetiredStatus(data map[string]interface{}) string

SetRetiredStatus determines whether an item is retired or not.

func SetStatus

func SetStatus(data map[string]interface{}) string

SetStatus determines the status based on user and root flags.

func SetTabWriterData

func SetTabWriterData(w *tabwriter.Writer, data string)

SetTabWriterData will write the contents of each array cell

func SetTabWriterHeader

func SetTabWriterHeader(header string) *tabwriter.Writer

SetTabWriterHeader will display the information in an array

func TruncateString added in v1.5.0

func TruncateString(str string, maxLength int) string

Types

type Challenge

type Challenge struct {
	ID    string `json:"id"`
	Value string `json:"value"`
}

type Machine

type Machine struct {
	ID    string `json:"id"`
	Value string `json:"value"`
}

type Root

type Root struct {
	Machines   interface{} `json:"machines"`
	Challenges interface{} `json:"challenges"`
	Usernames  interface{} `json:"users"`
}

type Username

type Username struct {
	ID    string `json:"id"`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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