Documentation
¶
Index ¶
- Constants
- func Base64Decode(s string) (string, error)
- func Base64Encode(s string) string
- func CanCheck(mod Exploit) bool
- func Contains(s, substr string) bool
- func Dedent(s string) string
- func Errorf(format string, args ...any) error
- func HasOpt(opts []Option, name string) bool
- func HasOption(mod Exploit, name string) bool
- func JSONBody(v any) string
- func Multipart(parts map[string]string) (string, string)
- func MultipartOrdered(boundary string, parts ...string) (string, string)
- func NameOf(mod Exploit) string
- func Names() []string
- func ObfuscateEmail(email string) string
- func RandInt(min, max int) int
- func RandTextDefault(n int) string
- func RegexFind(pattern, s string) string
- func Register(mod Exploit)
- func RegisterEnricher(fn OptionEnricher)
- func Replace(s string, oldNew ...string) string
- func Run(mod Exploit, opts ...RunOption)
- func SetLabManager(m LabManager)
- func SetRunner(fn func(Exploit, RunOptions))
- func Sprintf(format string, args ...any) string
- type Author
- type AuthorRank
- type CheckCode
- type CheckResult
- type Checker
- type CmdStager
- type Context
- func (c *Context) Base64Bash(cmd string) string
- func (c *Context) Commands() []string
- func (c *Context) CommentTrail(cmd string) string
- func (c *Context) Elapsed(start bool) float64
- func (c *Context) Error(format string, args ...any)
- func (c *Context) Get(key string) string
- func (c *Context) Payload() string
- func (c *Context) RandText(n int) string
- func (c *Context) Send(req Request) (*Response, error)
- func (c *Context) SetCommands(cmds []string)
- func (c *Context) SetTarget(t Target)
- func (c *Context) Status(format string, args ...any)
- func (c *Context) Success(format string, args ...any)
- func (c *Context) Target() Target
- func (c *Context) Warning(format string, args ...any)
- type Exploit
- type Info
- type Lab
- type LabManager
- type LabServiceStatus
- type LabStatus
- type Notes
- type Option
- func OptAddress(name, def, desc string) Option
- func OptAdvanced(opt Option) Option
- func OptBool(name string, def bool, desc string) Option
- func OptEnum(name, def, desc string, values ...string) Option
- func OptInt(name string, def int, desc string) Option
- func OptPort(name string, def int, desc string) Option
- func OptRequired(name, def, desc string) Option
- func OptString(name, def, desc string) Option
- func OptTargetURI(def string) Option
- func ResolveOptions(mod Exploit) []Option
- type OptionEnricher
- type OptionType
- type Params
- func (p Params) Arch() string
- func (p Params) Clone() Params
- func (p Params) Get(key string) string
- func (p Params) GetOr(key, def string) string
- func (p Params) Int(key string) int
- func (p Params) IntOr(key string, def int) int
- func (p Params) Lhost() string
- func (p Params) Lport() int
- func (p Params) Map() map[string]string
- func (p Params) Set(key, value string)
- func (p Params) Srvhost() string
- func (p Params) Srvport() int
- func (p Params) Target() string
- func (p Params) Tunnel() string
- type Pik
- type Query
- type RefType
- type Reference
- type Reliability
- type Request
- type Response
- func (r *Response) BodyBytes() ([]byte, error)
- func (r *Response) BodyString() (string, error)
- func (r *Response) Contains(substr string) bool
- func (r *Response) ContainsAny(substrs ...string) bool
- func (r *Response) Header(key string) string
- func (r *Response) JSON(target any) error
- func (r *Response) SetContainsFn(fn func(...string) bool)
- type RunOption
- type RunOptions
- type Service
- type Stance
- type Target
- type Values
Constants ¶
const ( CrashSafe = "CRASH_SAFE" CrashUnsafe = "CRASH_UNSAFE" ServiceRestart = "SERVICE_RESTART" ArtifactsOnDisk = "ARTIFACTS_ON_DISK" IOCInLogs = "IOC_IN_LOGS" ConfigChanges = "CONFIG_CHANGES" RepeatableSession = "REPEATABLE_SESSION" AccountLockout = "ACCOUNT_LOCKOUT_POSSIBLE" )
Standard stability tags.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶ added in v0.2.0
Base64Decode decodes a base64 string.
func Base64Encode ¶ added in v0.2.0
Base64Encode encodes a string to base64.
func JSONBody ¶ added in v0.2.0
JSONBody serializes a value to a JSON string for use in Request.Body.
func Multipart ¶ added in v0.2.0
Multipart builds a multipart/form-data body from named parts (unordered). Returns the body string and content-type header.
func MultipartOrdered ¶ added in v0.2.0
MultipartOrdered builds a multipart/form-data body from ordered name-value pairs. Parts are provided as alternating name, value strings. Returns the body string and content-type header.
func ObfuscateEmail ¶ added in v0.2.0
ObfuscateEmail formats a raw email to <user[at]domain>. Already obfuscated emails are returned as-is.
func RandTextDefault ¶ added in v0.2.0
RandTextDefault generates random alphanumeric text without needing a Context.
func RegexFind ¶ added in v0.2.0
RegexFind returns the first capturing group match of pattern in s, or empty string.
func Register ¶
func Register(mod Exploit)
Register adds an exploit to the global registry. The name is derived from the caller's file path relative to modules/. callerSkip controls stack depth: use 0 when calling from init() directly, use 1 when called through an intermediary (like sdk.Register wrapper).
func RegisterEnricher ¶
func RegisterEnricher(fn OptionEnricher)
func Run ¶
Run starts a standalone single-module CLI. Requires importing _ "github.com/Chocapikk/pik/pkg/cli" to register the runner.
func SetLabManager ¶ added in v0.2.0
func SetLabManager(m LabManager)
SetLabManager registers the lab manager (called from pkg/lab init).
func SetRunner ¶
func SetRunner(fn func(Exploit, RunOptions))
SetRunner registers the standalone runner function. Called from pkg/cli's init() to break the import cycle.
Types ¶
type Author ¶ added in v0.2.0
type Author struct {
Name string // real name or alias
Handle string // online handle (e.g. "Chocapikk")
Email string // contact email (pass raw "user@domain", stored as "<user[at]domain>")
}
Author describes a module contributor. Email is automatically formatted to <user[at]domain> for anti-scraping.
type AuthorRank ¶
AuthorRank holds contributor statistics.
func Rankings ¶
func Rankings() []AuthorRank
Rankings returns a sorted leaderboard of exploit authors.
type CheckResult ¶
type CheckResult struct {
Code CheckCode
Reason string
Details map[string]string // version detected, banner, etc.
}
func Detected ¶
func Detected(reason string) (CheckResult, error)
func Safe ¶
func Safe(reason string) (CheckResult, error)
func Unknown ¶
func Unknown(err error) (CheckResult, error)
func Vulnerable ¶
func Vulnerable(reason string, details ...string) (CheckResult, error)
Check result constructors - match MSF's CheckCode::Vulnerable() style.
func (CheckResult) FormatReason ¶
func (r CheckResult) FormatReason() string
type Checker ¶
type Checker interface {
Check(run *Context) (CheckResult, error)
}
Checker is an optional interface for modules that support vulnerability checking.
type CmdStager ¶
CmdStager is a marker interface for modules that support chunked command delivery. When the runner uses cmdstager mode, it sets commands on the Context via SetCommands(). The module reads them with Commands() and delivers them in its Exploit() method, handling its own setup/teardown.
type Context ¶
type Context struct {
// Function hooks injected by the runner.
SendFn func(Request) (*Response, error)
StatusFn func(string, ...any)
SuccessFn func(string, ...any)
ErrorFn func(string, ...any)
WarningFn func(string, ...any)
Base64BashFn func(string) string
CommentFn func(string) string
RandTextFn func(int) string
// contains filtered or unexported fields
}
Context is the execution context passed to exploits. Provides HTTP, logging, payload helpers, and timing.
func NewContext ¶
NewContext creates a Context with option values and payload command.
func (*Context) Base64Bash ¶
func (*Context) Commands ¶
Commands returns the CmdStager commands set by the runner. Empty when in single-shot mode.
func (*Context) CommentTrail ¶
func (*Context) SetCommands ¶
SetCommands is called by the runner to inject CmdStager commands.
type Info ¶
type Info struct {
Name string // Software name (e.g. "OpenDCIM", "Langflow", "Next.js")
Versions string // Affected versions (e.g. "< 24.2", "1.0.0 - 1.2.9")
Description string // Vulnerability title (e.g. "SQLi to RCE via Config Poisoning")
Detail string
Authors []Author
DisclosureDate string // "2026-01-15"
Reliability Reliability
Stance Stance
Privileged bool // does exploitation yield privileged access?
Notes Notes
References []Reference
Queries []Query
Targets []Target
DefaultOptions map[string]string
Lab Lab
}
func (Info) AuthorNames ¶ added in v0.2.0
func (Info) TargetStrings ¶
type Lab ¶ added in v0.2.0
type Lab struct {
Services []Service
}
Lab declares an optional Docker lab environment for testing a module.
type LabManager ¶ added in v0.2.0
type LabManager interface {
Start(ctx context.Context, name string, services []Service) error
Stop(ctx context.Context, name string) error
Status(ctx context.Context) ([]LabStatus, error)
IsRunning(ctx context.Context, name string) bool
Target(services []Service) string
WaitReady(ctx context.Context, addr string, timeout time.Duration) error
WaitProbe(ctx context.Context, timeout time.Duration, fn func() error) error
DockerGateway() string
}
LabManager is implemented by pkg/lab and registered via SetLabManager. This late binding keeps Docker SDK out of the sdk package and out of standalone binaries that don't import pkg/lab.
func GetLabManager ¶ added in v0.2.0
func GetLabManager() LabManager
GetLabManager returns the registered lab manager, or nil if not available.
type LabServiceStatus ¶ added in v0.2.0
LabServiceStatus holds status for one service container.
type LabStatus ¶ added in v0.2.0
type LabStatus struct {
Name string
Services []LabServiceStatus
}
LabStatus holds status for a lab (mirrors lab.LabInfo without importing it).
type Option ¶
type Option struct {
Name string
Type OptionType // defaults to TypeString if empty
Default string
Desc string
Required bool
Advanced bool
Enums []string // valid values for TypeEnum
}
func OptAddress ¶
func OptRequired ¶
func OptTargetURI ¶
func ResolveOptions ¶
ResolveOptions returns the full option set: module + enrichers + target defaults + module defaults.
type OptionEnricher ¶
type OptionType ¶
type OptionType string
const ( TypeString OptionType = "string" TypeInt OptionType = "int" TypeBool OptionType = "bool" TypePort OptionType = "port" TypePath OptionType = "path" TypeAddress OptionType = "address" TypeEnum OptionType = "enum" )
type Params ¶
Params holds the resolved option values for a module run.
type Pik ¶
type Pik struct{}
Pik is the base struct embedded by all modules. It provides default implementations for optional interface methods.
type Query ¶
type Query struct {
Engine string
Dork string
Scope string // optional, e.g. "service" or "leak" for LeakIX
}
Query is a search engine dork for finding targets.
type Reliability ¶
type Reliability int
const ( Unstable Reliability = 0 Unlikely Reliability = 100 Difficult Reliability = 200 Typical Reliability = 300 Reliable Reliability = 400 VeryReliable Reliability = 500 Certain Reliability = 600 )
func (Reliability) String ¶
func (r Reliability) String() string
type Request ¶
type Request struct {
Method string
Path string
Query Values
Form Values
Body string // raw request body
ContentType string
Headers map[string]string
Timeout int // seconds
NoRedirect bool
FireAndForget bool // send request, ignore response and errors
}
Request describes an HTTP request from module code.
func (*Request) BodyReader ¶ added in v0.2.0
BodyReader returns the Body as an io.Reader. Used internally by the HTTP bridge.
type Response ¶
type Response struct {
StatusCode int
Body io.ReadCloser
Headers map[string]string
// contains filtered or unexported fields
}
Response is an HTTP response for module code.
func (*Response) BodyString ¶ added in v0.2.0
BodyString returns the response body as a string.
func (*Response) Contains ¶ added in v0.2.0
Contains checks if the response body contains the given substring.
func (*Response) ContainsAny ¶
ContainsAny returns true if the response body contains any of the given substrings.
func (*Response) Header ¶ added in v0.2.0
Header returns the value of a response header (case-insensitive).
func (*Response) SetContainsFn ¶
SetContainsFn sets the function used by ContainsAny.
type RunOption ¶ added in v0.1.4
type RunOption func(*RunOptions)
RunOption is a functional option for Run.
func WithConsole ¶ added in v0.1.4
func WithConsole() RunOption
WithConsole enables the interactive console subcommand in standalone binaries.
type RunOptions ¶ added in v0.1.4
type RunOptions struct {
Console bool // Add interactive console subcommand.
Lab bool // Add lab management subcommands.
}
RunOptions configures standalone binary behavior.
type Service ¶ added in v0.2.0
type Service struct {
Name string // container name suffix (e.g. "web", "db")
Image string // Docker image (e.g. "vulhub/langflow:1.2.0")
Ports []string // port bindings (e.g. "7860:7860")
Env map[string]string // environment variables
Cmd []string // override entrypoint command
Volumes []string // bind mounts (host:container)
Healthcheck []string // CMD-SHELL health check command
}
Service describes a container in a lab environment. pkg/lab converts these to Docker SDK types at runtime.
func NewLabService ¶ added in v0.2.0
NewLabService builds a Service for the common case: image + port bindings. Chain WithEnv(), WithCmd(), WithVolume(), and WithHealthcheck() for more.
func (Service) WithHealthcheck ¶ added in v0.2.0
WithHealthcheck sets a CMD-SHELL health check.
func (Service) WithVolume ¶ added in v0.2.0
WithVolume adds a bind mount (host:container).
type Target ¶
type Target struct {
Name string
Platform string
Type string // module-defined, e.g. "cmd", "dropper"
Arches []string
DefaultOptions map[string]string // per-target option overrides
}