Skip to content

pkg flags

Jacob Paullus edited this page Apr 17, 2026 · 1 revision

pkg/flags - Unified CLI Framework

The flags package provides standardized command-line flag parsing that mirrors Impacket's interface.

Types

Options

type Options struct {
    // Authentication
    Hashes    string // -hashes LMHASH:NTHASH
    NoPass    bool   // -no-pass
    Kerberos  bool   // -k
    AesKey    string // -aesKey HEX
    Keytab    string // -keytab FILE

    // Connection
    DcHost    string // -dc-host HOST
    DcIP      string // -dc-ip IP
    TargetIP  string // -target-ip IP
    Port      int    // -port PORT (default: 445)
    IPv6      bool   // -6

    // Utility
    InputFile  string // -inputfile FILE
    OutputFile string // -outputfile FILE
    Timestamp  bool   // -ts
    Debug      bool   // -debug

    // Positional
    TargetStr string   // First positional arg (target)
    Arguments []string // Remaining positional args
}

Functions

Parse

Registers all standard flags, parses os.Args, and returns the populated Options.

func Parse() *Options

Methods

Options.ApplyToSession

Copies parsed CLI flags into a Target and Credentials struct.

func (o *Options) ApplyToSession(target *session.Target, creds *session.Credentials)

Handles -hashes, -k, -dc-ip, -dc-host, -target-ip, -port, -6, -aesKey, -keytab, and -no-pass.

Options.Command

Returns remaining positional arguments joined as a single string (useful for remote execution tools).

func (o *Options) Command() string

Adding Custom Flags

Use Go's flag package alongside flags.Parse():

import "flag"

var maxRid int
flag.IntVar(&maxRid, "maxRid", 4000, "Maximum RID to brute force")

// flags.Parse() calls flag.Parse() internally
opts := flags.Parse()

Customizing Help Text

import "gopacket/pkg/flags"

flags.ExtraUsageLine = "[maxRid]"
flags.ExtraUsageText = "\nPositional arguments:\n  maxRid  Maximum RID (default: 4000)\n"
opts := flags.Parse()

Clone this wiki locally