Skip to content

Commit

Permalink
added banner and make flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ropnop committed Feb 20, 2019
1 parent 764ddcc commit 97093b0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 24 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
TARGET=./dist
ARCHS=amd64 386
GOOS=windows linux darwin
PACKAGENAME="github.com/ropnop/kerbrute"

COMMIT=`git rev-parse --short HEAD`
DATE=`date +%m/%d/%y`
GOVERSION=`go version | cut -d " " -f 3`

LDFLAGS="-X ${PACKAGENAME}/util.GitCommit=${COMMIT} \
-X ${PACKAGENAME}/util.BuildDate=${DATE} \
-X ${PACKAGENAME}/util.GoVersion=${GOVERSION} \
"

.PHONY: help windows linux mac all clean

Expand All @@ -10,21 +20,21 @@ help: ## Show this help.
windows: ## Make Windows x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for windows $${ARCH}.." ;\
GOOS=windows GOARCH=$${ARCH} go build -o ${TARGET}/kerbrute_windows_$${ARCH}.exe ;\
GOOS=windows GOARCH=$${ARCH} go build -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_windows_$${ARCH}.exe ;\
done; \
echo "Done."

linux: ## Make Linux x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for linux $${ARCH}..." ; \
GOOS=linux GOARCH=$${ARCH} go build -o ${TARGET}/kerbrute_linux_$${ARCH} ;\
GOOS=linux GOARCH=$${ARCH} go build -ldflags "${LDFLAGS}" -o ${TARGET}/kerbrute_linux_$${ARCH} ;\
done; \
echo "Done."

mac: ## Make Darwin (Mac) x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for mac $${ARCH}..." ; \
GOOS=darwin GOARCH=$${ARCH} go build -o ${TARGET}/kerbrute_darwin_$${ARCH} ;\
GOOS=darwin GOARCH=$${ARCH} go build -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_darwin_$${ARCH} ;\
done; \
echo "Done."

Expand Down
22 changes: 22 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"fmt"

"github.com/ropnop/kerbrute/util"
"github.com/spf13/cobra"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Display version info and quit",
Run: showVersion,
}

func init() {
rootCmd.AddCommand(versionCmd)
}

func showVersion(cmd *cobra.Command, args []string) {
fmt.Printf("Kerbrute %v\nCommit: %v\nBuilt: %v with %v\n", util.Version, util.GitCommit, util.BuildDate, util.GoVersion)
}
23 changes: 2 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
package main

import (
"fmt"

"github.com/ropnop/kerbrute/cmd"
"github.com/ropnop/kerbrute/util"
)

var (
version = "dev"
commit = "none"
date = "unknown"
author = "Ronnie Flathers (@ropnop)"
)

func banner() {
banner := `
__ __ __
/ /_____ _____/ /_ _______ __/ /____
/ //_/ _ \/ ___/ __ \/ ___/ / / / __/ _ \
/ ,< / __/ / / /_/ / / / /_/ / /_/ __/
/_/|_|\___/_/ /_.___/_/ \__,_/\__/\___/
`
fmt.Printf("%v\nVersion: %v(%v) - %v\t%v\n\n", banner, version, commit, date, author)
}

func main() {
banner()
util.PrintBanner()
cmd.Execute()
}
14 changes: 14 additions & 0 deletions util/banner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package util

import "fmt"

func PrintBanner() {
banner := `
__ __ __
/ /_____ _____/ /_ _______ __/ /____
/ //_/ _ \/ ___/ __ \/ ___/ / / / __/ _ \
/ ,< / __/ / / /_/ / / / /_/ / /_/ __/
/_/|_|\___/_/ /_.___/_/ \__,_/\__/\___/
`
fmt.Printf("%v\nVersion: %v(%v) - %v - %v\n\n", banner, Version, GitCommit, BuildDate, Author)
}
9 changes: 9 additions & 0 deletions util/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package util

var (
Version = "dev"
GitCommit string
BuildDate string
GoVersion string
Author = "Ronnie Flathers @ropnop"
)

0 comments on commit 97093b0

Please sign in to comment.