utils

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: GPL-3.0 Imports: 22 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 GetActiveReleaseArenaMachineIP added in v1.6.0

func GetActiveReleaseArenaMachineIP() (string, error)

GetActiveReleaseArenaMachineIP returns the ip of the active release arena machine

func GetChallengeBlooder added in v1.6.0

func GetChallengeBlooder(challengeID string) (string, error)

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 GetReleaseArenaExpiredTime added in v1.6.0

func GetReleaseArenaExpiredTime() (string, error)

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 SearchEndgameID added in v1.6.0

func SearchEndgameID(partialName string) (int, error)

func SearchFortressID added in v1.6.0

func SearchFortressID(partialName string) (int, error)

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 SearchLastReleaseArenaMachine added in v1.5.1

func SearchLastReleaseArenaMachine() (string, error)

func SearchProlabID added in v1.6.0

func SearchProlabID(partialName string) (int, error)

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 Activity added in v1.6.0

type Activity struct {
	CreatedAt  string `json:"created_at"`
	Date       string `json:"date"`
	DateDiff   string `json:"date_diff"`
	UserID     int    `json:"user_id"`
	UserName   string `json:"user_name"`
	UserAvatar string `json:"user_avatar"`
	Type       string `json:"type"`
}

type Challenge

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

type ChallengeFinder added in v1.6.0

type ChallengeFinder struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

func SearchChallengeByName added in v1.6.0

func SearchChallengeByName(partialName string) (ChallengeFinder, error)

type ChallengeResponseFinder added in v1.6.0

type ChallengeResponseFinder struct {
	ChallengesFinder []ChallengeFinder `json:"challenges"`
}

type Data added in v1.6.0

type Data struct {
	Labs []Lab `json:"labs"`
}

Structure pour représenter la section 'data' du JSON

type DataActivity added in v1.6.0

type DataActivity struct {
	Info InfoActivity `json:"info"`
}

type Endgame added in v1.6.0

type Endgame struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Endgames

type EndgameJsonResponse added in v1.6.0

type EndgameJsonResponse struct {
	Status bool      `json:"status"`
	Data   []Endgame `json:"data"`
}

type InfoActivity added in v1.6.0

type InfoActivity struct {
	Activities []Activity `json:"activity"`
}

type Item added in v1.6.0

type Item struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type JsonResponse added in v1.6.0

type JsonResponse struct {
	Status bool            `json:"status"`
	Data   map[string]Item `json:"data"`
}

Structure pour représenter le JSON entier

type Lab added in v1.6.0

type Lab struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type Machine

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

type ProlabJsonResponse added in v1.6.0

type ProlabJsonResponse struct {
	Status bool `json:"status"`
	Data   Data `json:"data"`
}

Structure pour représenter le JSON entier

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