config

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config provides functions to manage the CookieFarm client configuration globally.

Index

Constants

This section is empty.

Variables

View Source
var ConfigTemplate = []byte(`host: "localhost"
port: 8080
https: false
username: "cookieguest"
`)
View Source
var DefaultConfigPath, _ = filesystem.ExpandTilde("~/.config/cookiefarm")
View Source
var ExploitTemplate = []byte(`#!/usr/bin/env python3
from cookiefarm import exploit_manager

# "ip" are the IP address of the target team (example: 10.10.X.1)
# "port" is the port of the target service (example: 1337)
# "name_service" is the name of the service to exploit (example: "CookieService")
# "flag_ids" is the flag IDs of the target team and target service (example: [{"username": "psQSDAasd", "password": "qweqweqwe"}, {"username": "sdafjhAS", "password": "HIUOasdb"}])

@exploit_manager
def exploit(ip, port, name_service, flag_ids: list):
    # Run your exploit here
    flag = ""

    # Just print the flag to stdout
    print(flag)
`)

Functions

This section is empty.

Types

type ArgsAttack

type ArgsAttack struct {
	ServicePort uint16 `json:"port"`         // Service Port
	TickTime    int    `json:"tick_time"`    // Optional custom tick time
	ThreadCount int    `json:"thread_count"` // Optional number of concurrent threads (coroutine) to use
	Detach      bool   `json:"detach"`       // Run in background if true
	ExploitPath string `json:"exploit_path"` // Path to the exploit to run
}

ArgsAttack represents the command-line arguments or configuration values passed at runtime to control the exploit manager behavior.

type ConfigLocal

type ConfigLocal struct {
	Host     string    `json:"host"`     // Host address of the server
	Port     uint16    `json:"port"`     // Port of the server
	HTTPS    bool      `json:"protocol"` // Protocol used to connect to the server (e.g., http, https)
	Username string    `json:"username"` // Username of the client
	Exploits []Exploit `json:"exploits"` // List of exploits available in the client
}

type ConfigManager

type ConfigManager struct {
	// contains filtered or unexported fields
}

ConfigManager manages all configuration state in a thread-safe manner

func GetConfigManager

func GetConfigManager() *ConfigManager

GetConfigManager returns the global ConfigManager instance Use this to access the new configuration management system

func GetInstance

func GetInstance() *ConfigManager

GetInstance returns the singleton instance of ConfigManager

func NewConfigManager

func NewConfigManager() *ConfigManager

NewConfigManager creates a new ConfigManager instance for dependency injection Use this when you need a fresh instance (e.g., for testing)

func (*ConfigManager) GetArgsAttackInstance

func (cm *ConfigManager) GetArgsAttackInstance() ArgsAttack

ArgsAttack methods

func (*ConfigManager) GetLocalConfig

func (cm *ConfigManager) GetLocalConfig() ConfigLocal

LocalConfig methods

func (*ConfigManager) GetPID

func (cm *ConfigManager) GetPID() int

PID methods

func (*ConfigManager) GetSession

func (cm *ConfigManager) GetSession() (string, error)

GetSession retrieves the current stored session

func (*ConfigManager) GetSharedConfig

func (cm *ConfigManager) GetSharedConfig() models.ConfigShared

SharedConfig methods

func (*ConfigManager) GetToken

func (cm *ConfigManager) GetToken() string

Token methods

func (*ConfigManager) GetUseBanner

func (cm *ConfigManager) GetUseBanner() bool

Banner methods

func (*ConfigManager) GetUseTUI

func (cm *ConfigManager) GetUseTUI() bool

TUI methods

func (*ConfigManager) LoadLocalConfigFromFile

func (cm *ConfigManager) LoadLocalConfigFromFile() error

LoadLocalConfigFromFile loads the local configuration from file

func (*ConfigManager) Logout

func (cm *ConfigManager) Logout() (string, error)

Logout handles user logout by removing session file

func (*ConfigManager) MapPortToService

func (cm *ConfigManager) MapPortToService(port uint16) string

MapPortToService maps a port to a service name using the shared configuration

func (*ConfigManager) ResetLocalConfigToDefaults

func (cm *ConfigManager) ResetLocalConfigToDefaults() (string, error)

ResetLocalConfigToDefaults resets the local configuration to defaults

func (*ConfigManager) SetArgsAttackInstance

func (cm *ConfigManager) SetArgsAttackInstance(args ArgsAttack)

func (*ConfigManager) SetLocalConfig

func (cm *ConfigManager) SetLocalConfig(config ConfigLocal)

func (*ConfigManager) SetPID

func (cm *ConfigManager) SetPID(pid int)

func (*ConfigManager) SetSharedConfig

func (cm *ConfigManager) SetSharedConfig(config models.ConfigShared)

func (*ConfigManager) SetToken

func (cm *ConfigManager) SetToken(token string)

func (*ConfigManager) SetUseBanner

func (cm *ConfigManager) SetUseBanner(useBanner bool)

func (*ConfigManager) SetUseTUI

func (cm *ConfigManager) SetUseTUI(useTUI bool)

func (*ConfigManager) ShowLocalConfigContent

func (cm *ConfigManager) ShowLocalConfigContent() (string, error)

ShowLocalConfigContent displays the current local configuration file content

func (*ConfigManager) UpdateLocalConfig

func (cm *ConfigManager) UpdateLocalConfig(host string, port uint16, username string, https bool, exploits []Exploit)

UpdateLocalConfig the value empty are not setted except for https for the string empty is "" for number is 0

func (*ConfigManager) UpdateLocalConfigToFile

func (cm *ConfigManager) UpdateLocalConfigToFile(configuration ConfigLocal) (string, error)

UpdateLocalConfigToFile updates the local configuration and writes to file

func (*ConfigManager) WriteLocalConfigToFile

func (cm *ConfigManager) WriteLocalConfigToFile() error

WriteLocalConfigToFile writes the current local configuration to file

type Exploit

type Exploit struct {
	Name string `json:"name"` // Name of the exploit
	PID  int    `json:"pid"`  // Process ID of the exploit
}

Jump to

Keyboard shortcuts

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