gzcli

package
v0.0.0-...-0d40387 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GZCTF_DIR        = ".gzctf"
	CONFIG_FILE      = "conf.yaml"
	APPSETTINGS_FILE = "appsettings.json"
)

Variables

View Source
var (
	CHALLENGE_CATEGORY = []string{
		"Misc", "Crypto", "Pwn",
		"Web", "Reverse", "Blockchain",
		"Forensics", "Hardware", "Mobile", "PPC",
		"OSINT", "Game Hacking", "AI", "Pentest",
	}
)
View Source
var LeetSpeakMap = map[rune]rune{
	'a': '4',
	'e': '3',
	'i': '1',
	'o': '0',
	's': '5',
	't': '7',
	'g': '9',
}

LeetSpeakMap defines rune replacements for leetspeak transformations

Functions

func DeleteCache

func DeleteCache(key string) error

DeleteCache removes cache files with minimal syscalls

func GetCache

func GetCache(key string, data any) error

GetCache reads cached data using optimized file access

func GetClient

func GetClient(api *gzapi.GZAPI) (*gzapi.GZAPI, error)

func GetFileHashHex

func GetFileHashHex(file string) (string, error)

func MustRunScripts

func MustRunScripts(script string)

MustRunScripts executes scripts or fatally logs error

func NormalizeFileName

func NormalizeFileName(name string) string

func ParseYamlFromBytes

func ParseYamlFromBytes(b []byte, data any) error

func ParseYamlFromFile

func ParseYamlFromFile(confPath string, data any) error

func RunScripts

func RunScripts(script string) error

Optimized script runner with worker pool

Types

type AppSettings

type AppSettings struct {
	AllowedHosts      string `json:"AllowedHosts"`
	ConnectionStrings struct {
		Database   string `json:"Database"`
		RedisCache string `json:"RedisCache"`
	} `json:"ConnectionStrings"`
	Logging struct {
		LogLevel struct {
			Default                  string `json:"Default"`
			Microsoft                string `json:"Microsoft"`
			MicrosoftHostingLifetime string `json:"Microsoft.Hosting.Lifetime"`
		} `json:"LogLevel"`
		Loki struct {
			Enable             bool     `json:"Enable"`
			EndpointUri        string   `json:"EndpointUri"`
			Labels             []Label  `json:"Labels"`
			PropertiesAsLabels []string `json:"PropertiesAsLabels"`
			Credentials        struct {
				Login    string `json:"Login"`
				Password string `json:"Password"`
			} `json:"Credentials"`
			Tenant       string `json:"Tenant"`
			MinimumLevel string `json:"MinimumLevel"`
		} `json:"Loki"`
	} `json:"Logging"`
	Telemetry struct {
		Prometheus struct {
			Enable                     bool `json:"Enable"`
			Port                       int  `json:"Port"`
			TotalNameSuffixForCounters bool `json:"TotalNameSuffixForCounters"`
		} `json:"Prometheus"`
		OpenTelemetry struct {
			Enable      bool   `json:"Enable"`
			Protocol    string `json:"Protocol"`
			EndpointUri string `json:"EndpointUri"`
		} `json:"OpenTelemetry"`
		AzureMonitor struct {
			Enable           bool   `json:"Enable"`
			ConnectionString string `json:"ConnectionString"`
		} `json:"AzureMonitor"`
		Console struct {
			Enable bool `json:"Enable"`
		} `json:"Console"`
	} `json:"Telemetry"`
	EmailConfig struct {
		SenderAddress string `json:"SenderAddress"`
		SenderName    string `json:"SenderName"`
		UserName      string `json:"UserName"`
		Password      string `json:"Password"`
		Smtp          struct {
			Host             string `json:"Host"`
			Port             int    `json:"Port"`
			BypassCertVerify bool   `json:"BypassCertVerify"`
		} `json:"Smtp"`
	} `json:"EmailConfig"`
	XorKey            string `json:"XorKey"`
	ContainerProvider struct {
		Type                 string `json:"Type"`
		PortMappingType      string `json:"PortMappingType"`
		EnableTrafficCapture bool   `json:"EnableTrafficCapture"`
		PublicEntry          string `json:"PublicEntry"`
		DockerConfig         struct {
			SwarmMode        bool   `json:"SwarmMode"`
			ChallengeNetwork string `json:"ChallengeNetwork"`
			Uri              string `json:"Uri"`
			UserName         string `json:"UserName"`
			Password         string `json:"Password"`
		} `json:"DockerConfig"`
		KubernetesConfig struct {
			Namespace  string   `json:"Namespace"`
			ConfigPath string   `json:"ConfigPath"`
			AllowCIDR  []string `json:"AllowCIDR"`
			DNS        []string `json:"DNS"`
		} `json:"KubernetesConfig"`
	} `json:"ContainerProvider"`
	RequestLogging   bool `json:"RequestLogging"`
	DisableRateLimit bool `json:"DisableRateLimit"`
	RegistryConfig   struct {
		UserName      string `json:"UserName"`
		Password      string `json:"Password"`
		ServerAddress string `json:"ServerAddress"`
	} `json:"RegistryConfig"`
	CaptchaConfig struct {
		Provider        string `json:"Provider"`
		SiteKey         string `json:"SiteKey"`
		SecretKey       string `json:"SecretKey"`
		GoogleRecaptcha struct {
			VerifyAPIAddress   string `json:"VerifyAPIAddress"`
			RecaptchaThreshold string `json:"RecaptchaThreshold"`
		} `json:"GoogleRecaptcha"`
	} `json:"CaptchaConfig"`
	ForwardedOptions struct {
		ForwardedHeaders       int      `json:"ForwardedHeaders"`
		ForwardLimit           int      `json:"ForwardLimit"`
		ForwardedForHeaderName string   `json:"ForwardedForHeaderName"`
		TrustedNetworks        []string `json:"TrustedNetworks"`
		TrustedProxies         []string `json:"TrustedProxies"`
	} `json:"ForwardedOptions"`
	Kestrel struct {
		Endpoints struct {
			Web struct {
				Url string `json:"Url"`
			} `json:"Web"`
			Prometheus struct {
				Url string `json:"Url"`
			} `json:"Prometheus"`
		} `json:"Endpoints"`
		Limits struct {
			MaxResponseBufferSize            int    `json:"MaxResponseBufferSize"`
			MaxRequestBufferSize             int    `json:"MaxRequestBufferSize"`
			MaxRequestLineSize               int    `json:"MaxRequestLineSize"`
			MaxRequestHeadersTotalSize       int    `json:"MaxRequestHeadersTotalSize"`
			MaxRequestHeaderCount            int    `json:"MaxRequestHeaderCount"`
			MaxRequestBodySize               int64  `json:"MaxRequestBodySize"`
			KeepAliveTimeout                 string `json:"KeepAliveTimeout"`
			RequestHeadersTimeout            string `json:"RequestHeadersTimeout"`
			MaxConcurrentConnections         *int   `json:"MaxConcurrentConnections"`
			MaxConcurrentUpgradedConnections *int   `json:"MaxConcurrentUpgradedConnections"`
		} `json:"Limits"`
		AddServerHeader                bool    `json:"AddServerHeader"`
		AllowResponseHeaderCompression bool    `json:"AllowResponseHeaderCompression"`
		AllowSynchronousIO             bool    `json:"AllowSynchronousIO"`
		AllowAlternateSchemes          bool    `json:"AllowAlternateSchemes"`
		DisableStringReuse             bool    `json:"DisableStringReuse"`
		ConfigurationLoader            *string `json:"ConfigurationLoader"`
	} `json:"Kestrel"`
}

type CTFTimeFeed

type CTFTimeFeed struct {
	Tasks     []string   `json:"tasks"`
	Standings []Standing `json:"standings"`
}

type ChallengeYaml

type ChallengeYaml struct {
	Name        string            `yaml:"name"`
	Author      string            `yaml:"author"`
	Description string            `yaml:"description"`
	Flags       []string          `yaml:"flags"`
	Value       int               `yaml:"value"`
	Provide     *string           `yaml:"provide,omitempty"`
	Visible     *bool             `yaml:"visible"`
	Type        string            `yaml:"type"`
	Hints       []string          `yaml:"hints"`
	Container   Container         `yaml:"container"`
	Scripts     map[string]string `yaml:"scripts"`
	Category    string            `yaml:"-"`
	Cwd         string            `yaml:"-"`
}

func GetChallengesYaml

func GetChallengesYaml(config *Config) ([]ChallengeYaml, error)

type Config

type Config struct {
	Url   string      `yaml:"url"`
	Creds gzapi.Creds `yaml:"creds"`
	Event gzapi.Game  `yaml:"event"`
	// contains filtered or unexported fields
}

func GetConfig

func GetConfig(api *gzapi.GZAPI) (*Config, error)

type Container

type Container struct {
	FlagTemplate         string `yaml:"flagTemplate"`
	ContainerImage       string `yaml:"containerImage"`
	MemoryLimit          int    `yaml:"memoryLimit"`
	CpuCount             int    `yaml:"cpuCount"`
	StorageLimit         int    `yaml:"storageLimit"`
	ContainerExposePort  int    `yaml:"containerExposePort"`
	EnableTrafficCapture bool   `yaml:"enableTrafficCapture"`
}

type GZ

type GZ struct {
	UpdateGame bool
	// contains filtered or unexported fields
}

func Init

func Init() (*GZ, error)

func MustInit

func MustInit() *GZ

MustInit initializes GZ or fatally logs error

func (*GZ) CreateTeams

func (gz *GZ) CreateTeams(csvURL string, isSendEmail bool) error

func (*GZ) CreteTeamAndUser

func (gz *GZ) CreteTeamAndUser(teamCreds *TeamCreds, config *Config, existingTeamNames, existingUserNames map[string]struct{}, credsCache []*TeamCreds, isSendEmail bool) (*TeamCreds, error)

CreteTeamAndUser creates a team and user, ensuring the team name is unique and within the specified length.

func (*GZ) DeleteAllUser

func (gz *GZ) DeleteAllUser() error

func (*GZ) GenerateStructure

func (gz *GZ) GenerateStructure() error

func (*GZ) MustCreateTeams

func (gz *GZ) MustCreateTeams(url string, sendEmail bool)

MustCreateTeams creates teams or fatally logs error

func (*GZ) MustDeleteAllUser

func (gz *GZ) MustDeleteAllUser()

MustDeleteAllUser removes all users or fatally logs error

func (*GZ) MustScoreboard2CTFTimeFeed

func (gz *GZ) MustScoreboard2CTFTimeFeed() *CTFTimeFeed

func (*GZ) MustSync

func (gz *GZ) MustSync()

MustSync synchronizes data or fatally logs error

func (*GZ) RemoveAllEvent

func (gz *GZ) RemoveAllEvent() error

Bulk game deletion with parallel execution

func (*GZ) Scoreboard2CTFTimeFeed

func (gz *GZ) Scoreboard2CTFTimeFeed() (*CTFTimeFeed, error)

Preallocated scoreboard generation

func (*GZ) Sync

func (gz *GZ) Sync() error

type Label

type Label struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

type Standing

type Standing struct {
	Pos   int    `json:"pos"`
	Team  string `json:"team"`
	Score int    `json:"score"`
}

type TeamCreds

type TeamCreds struct {
	Username           string `json:"username" yaml:"username"`
	Password           string `json:"password" yaml:"password"`
	Email              string `json:"email" yaml:"email"`
	TeamName           string `json:"team_name" yaml:"team_name"`
	IsEmailAlreadySent bool   `json:"is_email_already_sent" yaml:"is_email_already_sent"`
	IsTeamCreated      bool   `json:"is_team_created" yaml:"is_team_created"`
}

TeamCreds stores team credentials

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳