cli tool for hacktrack cuz why not
- Go (1.21+ recommended, currently configured for
latestviamise) make(optional, for running task automation)
You can install ht using the following curl command:
curl -fsSL https://raw.githubusercontent.com/hackerspacemmu/hacktrackmmu-cli/main/install.sh | bash- Clone or copy this repository to your local machine:
git clone https://github.com/hackerspacemmu/hacktrackmmu-cli.git cd hacktrackmmu-cli - Initialize and tidy dependencies:
go mod tidy
ht [flags]Flags:
-v, --verbose: Enable debug level structured logs (overrideslog_levelconfig value).
Authenticate with the Hacktrack MMU server using your password.
ht login [password]Ping the Hacktrack API server before running other requests (recommended when cold starting).
ht pingView details of a specific member.
ht view [name]Manage meetups.
- Create a meetup interactively:
ht meetup create
Manage projects.
- Create a project:
ht project create
Manage updates/contributions for members.
- Create an update interactively:
ht update create
Print compilation details:
ht versionPrint in JSON format:
ht version --jsonYou can use the provided Makefile to simplify development tasks:
-
Build the binary:
make build
This places the compiled binary in
bin/htwith injected build information. -
Run the CLI directly:
make run ARGS="version" # Or with flags: make run ARGS="version -v"
-
Run tests:
make test -
Format code:
make fmt
-
Install to global
GOBIN:make install
To add a new subcommand to the CLI, use the cobra-cli binary:
# If not already installed:
go install github.com/spf13/cobra-cli@latest
# Add a command:
cobra-cli add <command-name>Alternatively, you can manually create a new file in cmd/<command-name>.go following the pattern in cmd/version.go:
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var myCmd = &cobra.Command{
Use: "mycmd",
Short: "A brief description",
Run: func(cmd *cobra.Command, args []string) {
cfg := GetConfig() // Access the configuration
fmt.Println("Running mycmd...")
},
}
func init() {
rootCmd.AddCommand(myCmd)
}The CLI load order for configurations is:
- Local flags (e.g.
--verbose) - Environment Variables (prefixed with
HACKTRACK_) - Configuration file (defaults to
config.yamlin the working directory, or$HOME/.config/hacktrackmmu-cli/config.yaml) - Struct Defaults
Create a config.yaml file in the root of the project to customize settings:
# config.yaml
log_level: info
api_url: "api-url"