ctfd

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 15 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

This section is empty.

Types

type Challenge

type Challenge 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"`
	// Requirements []struct {
	// 	ID   int64  `json:"id"`
	// 	Name string `json:"name"`
	// } `json:"requirements"`
	Solves     int64         `json:"solves"`
	SolvedByMe bool          `json:"solved_by_me"`
	Files      []string      `json:"files"`
	Hints      []Hint        `json:"hints"`
	Tags       []interface{} `json:"tags"`
}

type ChallengeData

type ChallengeData 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"`
}

type Challenges

type Challenges struct {
	Success bool            `json:"success"`
	Data    []ChallengeData `json:"data"`
}

type Client

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

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 client to the CTFd instance with the given username, password.

func (*Client) Challenge

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

func (*Client) Check

func (c *Client) Check() error

Check will check if the instance is a CTFd instance.

func (*Client) DownloadFiles

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

func (*Client) GetDescription

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

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

func (*Client) ListChallenges

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

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

func (*Client) ScoreboardTop added in v0.0.2

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

type Credentials added in v0.0.2

type Credentials struct {
	Username string
	Password string
}

type Hint

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

type Response added in v0.0.2

type Response struct {
	Success bool        `json:"success"`
	Data    TopTeamData `json:"data"`
}

type Solves added in v0.0.2

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 Team added in v0.0.2

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

type TopTeamData added in v0.0.2

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 added in v0.0.2

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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