ctf

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Constants for max file sizes (1mb, 5mb, 25mb, 100mb, 0)
	NoFileSizeLimit    = 0
	OneMB              = 1000000
	FiveMB             = 5000000
	TwentyFiveMB       = 25000000
	OneHundredMB       = 100000000
	TwoHhundredFiftyMB = 250000000
)

Variables

This section is empty.

Functions

func CleanDescription

func CleanDescription(description string) string

Clean the description of a CTF event, removing \r\n and limiting the length of the description

func IsActive added in v0.1.9

func IsActive(event Event) bool

IsActive returns true if the CTF event is active based on the start and finish times

Types

type CTFOpts added in v0.0.23

type CTFOpts struct {
	URL        string
	Username   string
	Password   string
	Output     string
	Overwrite  bool
	SaveConfig bool
}

func NewOpts added in v0.0.23

func NewOpts() *CTFOpts

NewOptions returns a new Options struct

type CTFTeam

type CTFTeam struct {
	ID           int      `json:"id"`
	Academic     bool     `json:"academic"`
	PrimaryAlias string   `json:"primary_alias"`
	Name         string   `json:"name"`
	Country      string   `json:"country"`
	Aliases      []string `json:"aliases"`
	Rating       map[string]struct {
		RatingPlace     int     `json:"rating_place"`
		OrganizerPoints float64 `json:"organizer_points"`
		RatingPoints    float64 `json:"rating_points"`
		CountryPlace    int     `json:"country_place"`
	} `json:"rating"`
}

Struct for API Endpoint ctftime.org/api/v1/teams/

type ChallengeData

type ChallengeData struct {
	ID             int64  `json:"id"`
	Name           string `json:"name"`
	Description    string `json:"description"`
	ConnectionInfo string `json:"connection_info"`
	NextID         int64  `json:"next_id"`
	Attempts       int64  `json:"attempts"`
	MaxAttempts    int64  `json:"max_attempts"`
	Value          int64  `json:"value"`
	Category       string `json:"category"`
	Type           string `json:"type"`
	TypeData       struct {
		ID        string `json:"id"`
		Name      string `json:"name"`
		Templates struct {
			Create string `json:"create"`
			Update string `json:"update"`
			View   string `json:"view"`
		} `json:"templates"`
		Scripts struct {
			Create string `json:"create"`
			Update string `json:"update"`
			View   string `json:"view"`
		} `json:"scripts"`
	} `json:"type_data"`
	State      string        `json:"state"`
	Solves     int64         `json:"solves"`
	SolvedByMe bool          `json:"solved_by_me"`
	Files      []string      `json:"files"`
	Hints      []Hint        `json:"hints"`
	Tags       []interface{} `json:"tags"`
}

type ChallengesData added in v0.0.19

type ChallengesData struct {
	ID         int64         `json:"id"`
	Type       string        `json:"type"`
	Name       string        `json:"name"`
	Value      int64         `json:"value"`
	Solves     int64         `json:"solves"`
	SolvedByMe bool          `json:"solved_by_me"`
	Category   string        `json:"category"`
	Tags       []interface{} `json:"tags"`
}

type Client

type Client struct {
	Client      *http.Client
	BaseURL     *url.URL
	Creds       *Credentials
	MaxFileSize int64
}

func NewClient

func NewClient(transport http.RoundTripper) *Client

NewClient constructs a new Client. If transport is nil, a default transport is used.

func (*Client) Authenticate

func (c *Client) Authenticate() error

Authenticate will attempt to authenticate the client with the provided username and password.

func (*Client) Challenge

func (c *Client) Challenge(id int64) (*ChallengeData, error)

Challenge returns a challenge by ID

func (*Client) Check

func (c *Client) Check() error

Check will check if the instance is a CTFd instance.

func (*Client) DoRequest added in v0.0.24

func (c *Client) DoRequest(req *http.Request) (*http.Response, error)

func (*Client) DownloadFiles

func (c *Client) DownloadFiles(id int64, outputPath string) error

DownloadFiles will download all the files of a challenge by ID and save them to the given directory

func (*Client) GetCTFEvent

func (c *Client) GetCTFEvent(id int) (Event, error)

Retrieve information about a specific CTF event on CTFTime

func (*Client) GetCTFEvents

func (c *Client) GetCTFEvents() ([]Event, error)

Retrieve information about all CTF events on CTFTime

func (*Client) GetCTFTeam

func (c *Client) GetCTFTeam(id int) (CTFTeam, error)

Get information about a specific team on CTFTime

func (*Client) GetDescription

func (c *Client) GetDescription(challenge *ChallengeData, challengePath string) error

GetDescription retrieves a challenge and returns a writeup template of the challenge

func (*Client) GetDoc added in v0.0.21

func (c *Client) GetDoc(urlStr string, a ...interface{}) (*goquery.Document, error)

GetDoc fetches a urlStr (URL relative to the client's BaseURL) and returns the parsed response document.

func (*Client) GetJson added in v0.0.21

func (c *Client) GetJson(urlStr string, a ...interface{}) (*http.Response, error)

GetJson fetches a urlStr (URL relative to the client's BaseURL) and returns the parsed response body.

func (*Client) GetTopTeams

func (c *Client) GetTopTeams() ([]TopTeam, error)

Get the top teams on CTFTime

func (*Client) ListChallenges

func (c *Client) ListChallenges() ([]ChallengesData, error)

ListChallenges returns a list of challenges

func (*Client) ScoreboardTop

func (c *Client) ScoreboardTop(count int64) (TopTeamData, error)

ScoreboardTop returns the top teams on the scoreboard

func (*Client) SubmitFlag added in v0.0.19

func (c *Client) SubmitFlag(submission Submission) error

type Credentials

type Credentials struct {
	Username string
	Password string
}

type Event

type Event struct {
	ID            uint64    `json:"id"`
	CTFID         int       `json:"ctf_id"`
	Title         string    `json:"title"`
	Description   string    `json:"description"`
	URL           string    `json:"url"`
	Weight        float64   `json:"weight"`
	Onsite        bool      `json:"onsite"`
	Location      string    `json:"location"`
	Restrictions  string    `json:"restrictions"`
	Format        string    `json:"format"`
	FormatID      int       `json:"format_id"`
	Participants  int       `json:"participants"`
	CTFTimeURL    string    `json:"ctftime_url"`
	LiveFeed      string    `json:"live_feed"`
	IsVotableNow  bool      `json:"is_votable_now"`
	PublicVotable bool      `json:"public_votable"`
	Start         time.Time `json:"start"`
	Finish        time.Time `json:"finish"`
}

Struct for API Endpoint ctftime.org/api/v1/events/

func CleanCTFEvents

func CleanCTFEvents(events []Event) ([]Event, error)

CleanCTFEvents will clean the CTF events, removing any events that have finished

type Hint

type Hint struct {
	ID      int64  `json:"id"`
	Cost    int64  `json:"cost"`
	Content string `json:"content"`
}

type Solves

type Solves struct {
	ChallengeID interface{} `json:"challenge_id"`
	AccountID   int         `json:"account_id"`
	TeamID      int         `json:"team_id"`
	UserID      int         `json:"user_id"`
	Value       int         `json:"value"`
	Date        time.Time   `json:"date"`
}

type Submission added in v0.0.19

type Submission struct {
	ID   int    `json:"challenge_id"`
	Flag string `json:"submission"`
}

type Team

type Team struct {
	ID     int      `json:"id"`
	Name   string   `json:"name"`
	Solves []Solves `json:"solves"`
}

type TopTeam

type TopTeam struct {
	TeamName string  `json:"team_name"`
	Points   float64 `json:"points"`
	TeamID   int     `json:"team_id"`
}

type TopTeamData

type TopTeamData struct {
	Num1  Team `json:"1"`
	Num2  Team `json:"2"`
	Num3  Team `json:"3"`
	Num4  Team `json:"4"`
	Num5  Team `json:"5"`
	Num6  Team `json:"6"`
	Num7  Team `json:"7"`
	Num8  Team `json:"8"`
	Num9  Team `json:"9"`
	Num10 Team `json:"10"`
}

func (*TopTeamData) GetTeam

func (d *TopTeamData) GetTeam(number int) (*Team, error)

GetTeam returns the team information for a given team ID !TODO: This needs to be refactored to allow for a list of any number of teams

type TopTeams

type TopTeams struct {
	Teams []TopTeam `json:"2022"`
}

Jump to

Keyboard shortcuts

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