Documentation
¶
Index ¶
- Constants
- type ActivityResponse
- type CategoriesListInfo
- type CategoriesListInfoResponse
- type Challenge
- type ChallengeActivity
- type ChallengeList
- type ChallengeListResponse
- type ChallengeQuery
- func (q *ChallengeQuery) AllResults(ctx context.Context) (ChallengeListResponse, error)
- func (q *ChallengeQuery) Ascending() *ChallengeQuery
- func (q *ChallengeQuery) ByCategory(val ...int) *ChallengeQuery
- func (q *ChallengeQuery) ByCategoryList(val ...int) *ChallengeQuery
- func (q *ChallengeQuery) ByDifficulty(val string) *ChallengeQuery
- func (q *ChallengeQuery) ByDifficultyList(val ...string) *ChallengeQuery
- func (q *ChallengeQuery) ByKeyword(keyword string) *ChallengeQuery
- func (q *ChallengeQuery) ByState(val string) *ChallengeQuery
- func (q *ChallengeQuery) ByStateList(val ...string) *ChallengeQuery
- func (q *ChallengeQuery) Descending() *ChallengeQuery
- func (q *ChallengeQuery) First(ctx context.Context) (ChallengeListResponse, error)
- func (q *ChallengeQuery) Next() *ChallengeQuery
- func (q *ChallengeQuery) Page(n int) *ChallengeQuery
- func (q *ChallengeQuery) PerPage(n int) *ChallengeQuery
- func (q *ChallengeQuery) Previous() *ChallengeQuery
- func (q *ChallengeQuery) Results(ctx context.Context) (ChallengeListResponse, error)
- func (q *ChallengeQuery) SortedBy(field string) *ChallengeQuery
- type DownloadResponse
- type Handle
- func (h *Handle) Activity(ctx context.Context) (ActivityResponse, error)
- func (h *Handle) Download(ctx context.Context) (DownloadResponse, error)
- func (h *Handle) Info(ctx context.Context) (InfoResponse, error)
- func (h *Handle) Own(ctx context.Context, flag string) (common.MessageResponse, error)
- func (h *Handle) Start(ctx context.Context) (common.MessageResponse, error)
- func (h *Handle) Stop(ctx context.Context) (common.MessageResponse, error)
- func (h *Handle) ToDo(ctx context.Context) (common.TodoUpdateResponse, error)
- type InfoResponse
- type Service
Constants ¶
const ( SortByChallenge = v4Client.GetChallengesParamsSortBy("Challenge") SortByCatagory = v4Client.GetChallengesParamsSortBy("Catagory") SortByRating = v4Client.GetChallengesParamsSortBy("Rating") SortByUsersSolves = v4Client.GetChallengesParamsSortBy("Solves") SortByReleaseDate = v4Client.GetChallengesParamsSortBy("ReleaseDate") )
const ( StateActive = "active" StateRetired = "retired" StateUnreleased = "unreleased" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivityResponse ¶
type ActivityResponse struct {
Data []ChallengeActivity
ResponseMeta common.ResponseMeta
}
type CategoriesListInfo ¶ added in v0.1.0
type CategoriesListInfo = v4Client.CategoriesListInfo
type CategoriesListInfoResponse ¶ added in v0.1.0
type CategoriesListInfoResponse struct {
Data CategoriesListInfo
ResponseMeta common.ResponseMeta
}
type ChallengeActivity ¶
type ChallengeActivity = v4Client.ChallengeActivity
type ChallengeList ¶
type ChallengeList = v4Client.ChallengeList
type ChallengeListResponse ¶
type ChallengeListResponse struct {
Data []ChallengeList
ResponseMeta common.ResponseMeta
}
type ChallengeQuery ¶
type ChallengeQuery struct {
// contains filtered or unexported fields
}
func (*ChallengeQuery) AllResults ¶
func (q *ChallengeQuery) AllResults(ctx context.Context) (ChallengeListResponse, error)
AllResults executes the query and returns all pages of challenges. This method automatically paginates through all available results. Use with caution for large datasets as it may consume significant memory.
Example:
allChallenges, err := client.Challenges.List().
ByDifficulty("Hard").
AllResults(ctx)
func (*ChallengeQuery) Ascending ¶
func (q *ChallengeQuery) Ascending() *ChallengeQuery
Ascending sets the sort order to ascending. Must be called after SortedBy(). Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.SortedBy("Rating").Ascending().Results(ctx)
func (*ChallengeQuery) ByCategory ¶
func (q *ChallengeQuery) ByCategory(val ...int) *ChallengeQuery
ByCategory filters challenges by category ID. Category IDs are typically obtained from category listings. Returns a new ChallengeQuery that can be further chained.
Example:
webChallenges := query.ByCategory(1).Results(ctx) cryptoChallenges := query.ByCategory(2).Results(ctx)
func (*ChallengeQuery) ByCategoryList ¶
func (q *ChallengeQuery) ByCategoryList(val ...int) *ChallengeQuery
ByCategoryList filters challenges by multiple category IDs. Category IDs are typically obtained from category listings. Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.ByCategoryList(1, 2, 3).Results(ctx)
func (*ChallengeQuery) ByDifficulty ¶
func (q *ChallengeQuery) ByDifficulty(val string) *ChallengeQuery
ByDifficulty filters challenges by difficulty level. Valid values are "VeryEasy", "Easy", "Medium", "Hard", and "Insane". Returns a new ChallengeQuery that can be further chained.
Example:
hardChallenges := query.ByDifficulty("Hard").Results(ctx)
easyChallenges := query.ByDifficulty("Hard").ByDifficulty("Easy").Results(ctx)
func (*ChallengeQuery) ByDifficultyList ¶
func (q *ChallengeQuery) ByDifficultyList(val ...string) *ChallengeQuery
ByDifficultyList filters challenges by multiple difficulty levels. Valid values are "Easy", "Medium", "Hard", and "Insane". Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.ByDifficultyList("Hard", "Insane").Results(ctx)
func (*ChallengeQuery) ByKeyword ¶ added in v0.1.0
func (q *ChallengeQuery) ByKeyword(keyword string) *ChallengeQuery
ByKeyword filters Challenge name Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.ByKeyword("spo").Results(ctx)
func (*ChallengeQuery) ByState ¶
func (q *ChallengeQuery) ByState(val string) *ChallengeQuery
ByState filters challenges by state. Valid values are "active", "retired", and "unreleased". Returns a new ChallengeQuery that can be further chained.
Example:
activeChallenges := query.ByState("active").Results(ctx)
retiredChallenges := query.ByState("retired").Results(ctx)
func (*ChallengeQuery) ByStateList ¶
func (q *ChallengeQuery) ByStateList(val ...string) *ChallengeQuery
ByStateList filters challenges by multiple states. Valid values are "active", "retired", and "unreleased". Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.ByStateList("active", "retired").Results(ctx)
func (*ChallengeQuery) Descending ¶
func (q *ChallengeQuery) Descending() *ChallengeQuery
Descending sets the sort order to descending. Must be called after SortedBy(). Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.SortedBy("Rating").Descending().Results(ctx)
func (*ChallengeQuery) First ¶
func (q *ChallengeQuery) First(ctx context.Context) (ChallengeListResponse, error)
First executes the query and returns only the first challenge. Returns an error if no results are found.
Example:
firstChallenge, err := client.Challenges.List().
ByDifficulty("Insane").
SortedBy("Rating").Descending().
First(ctx)
func (*ChallengeQuery) Next ¶
func (q *ChallengeQuery) Next() *ChallengeQuery
Next moves to the next page in the pagination sequence. Returns a new ChallengeQuery that can be further chained.
Example:
nextPage := query.Next().Results(ctx)
func (*ChallengeQuery) Page ¶
func (q *ChallengeQuery) Page(n int) *ChallengeQuery
Page sets the specific page number for pagination. Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.Page(3).Results(ctx)
func (*ChallengeQuery) PerPage ¶
func (q *ChallengeQuery) PerPage(n int) *ChallengeQuery
PerPage sets the number of results per page. Returns a new ChallengeQuery that can be further chained.
Example:
challenges := query.PerPage(50).Results(ctx)
func (*ChallengeQuery) Previous ¶
func (q *ChallengeQuery) Previous() *ChallengeQuery
Previous moves to the previous page in the pagination sequence. If already on the first page, it remains on page 1. Returns a new ChallengeQuery that can be further chained.
Example:
prevPage := query.Previous().Results(ctx)
func (*ChallengeQuery) Results ¶
func (q *ChallengeQuery) Results(ctx context.Context) (ChallengeListResponse, error)
Results executes the query and returns the current page of challenges. This method should be called last in the query chain to fetch the actual data.
Example:
challenges, err := client.Challenges.List().
ByDifficulty("Hard").
ByState("active").
SortedBy("Rating").Descending().
Results(ctx)
func (*ChallengeQuery) SortedBy ¶
func (q *ChallengeQuery) SortedBy(field string) *ChallengeQuery
SortedBy sets the field to sort results by. Valid values include "Challenge", "Catagory", "Rating", "Solves", and "ReleaseDate". Returns a new ChallengeQuery that can be further chained with Ascending() or Descending().
Example:
challenges := query.SortedBy("Rating").Descending().Results(ctx)
challenges := query.SortedBy("ReleaseDate").Ascending().Results(ctx)
type DownloadResponse ¶
type DownloadResponse struct {
Data []byte
ResponseMeta common.ResponseMeta
}
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
func (*Handle) Activity ¶
func (h *Handle) Activity(ctx context.Context) (ActivityResponse, error)
Activity retrieves the recent activity history for the challenge. This includes recent solves, attempts, and other challenge-related activities.
Example:
activity, err := client.Challenges.Challenge(12345).Activity(ctx)
if err != nil {
log.Fatal(err)
}
for _, act := range activity.Data {
fmt.Printf("Activity: %s at %s\n", act.Type, act.Date)
}
func (*Handle) Download ¶
func (h *Handle) Download(ctx context.Context) (DownloadResponse, error)
Download retrieves the challenge files for download. This returns the challenge's downloadable zip. Note: Not all challenges have downloadable files. Check Info() first to verify availability.
Example:
challenge := client.Challenges.Challenge(12345)
// Get challenge info first to check if files are available
info, err := challenge.Info(ctx)
if err != nil {
log.Fatal(err)
}
// Check if the challenge has downloadable files
if info.Data.FileName == "" {
fmt.Println("This challenge has no downloadable files")
return
}
// Download the challenge files
download, err := challenge.Download(ctx)
if err != nil {
log.Fatal(err)
}
// Write to file
err = os.WriteFile(info.Data.FileName, download.Data, 0644)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Downloaded challenge files to: %s (%d bytes)\n", info.Data.FileName, len(download.Data))
func (*Handle) Info ¶
func (h *Handle) Info(ctx context.Context) (InfoResponse, error)
Info retrieves detailed information about the challenge. This includes comprehensive challenge details such as name, difficulty, category, description, and other metadata.
Example:
info, err := client.Challenges.Challenge(12345).Info(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Challenge: %s (%s, %s)\n", info.Data.Name, info.Data.Difficulty, info.Data.Category)
func (*Handle) Own ¶
Own submits a flag for the challenge to claim ownership. This is used to submit the solution flag to complete the challenge.
Example:
result, err := client.Challenges.Challenge(12345).Own(ctx, "HTB{example_flag_here}")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Flag submission: %s\n", result.Data.Message)
func (*Handle) Start ¶
Start initiates a new instance of the challenge. This creates and starts a challenge instance for solving.
Example:
result, err := client.Challenges.Challenge(12345).Start(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Challenge started: %s\n", result.Data.Message)
func (*Handle) Stop ¶
Stop terminates the running challenge instance. This stops and destroys the active challenge instance.
Example:
result, err := client.Challenges.Challenge(12345).Stop(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Challenge stopped: %s (Success: %t)\n", result.Data.Message, result.Data.Success)
type InfoResponse ¶
type InfoResponse struct {
Data Challenge
ResponseMeta common.ResponseMeta
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Categories ¶ added in v0.1.0
func (s *Service) Categories(ctx context.Context) (CategoriesListInfoResponse, error)
func (*Service) Challenge ¶
Challenge returns a handle for a specific challenge with the given ID. This handle can be used to perform operations on the challenge such as retrieving information, starting/stopping instances, or submitting flags.
func (*Service) ChallengeName ¶ added in v0.0.24
func (*Service) List ¶
func (s *Service) List() *ChallengeQuery
List creates a new query for challenges. This returns a ChallengeQuery that can be chained with filtering and pagination methods. Use this to search and filter challenges based on various criteria.
Example:
query := client.Challenges.List()
challenges, err := query.ByDifficulty("Hard").ByState("active").Results(ctx)