diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..24a7c9e --- /dev/null +++ b/COPYING @@ -0,0 +1,13 @@ +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/Makefile b/Makefile index 58076bf..b98a4c1 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,32 @@ mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -version := $(git tag -l | tail -n 1) +build_path := $(mkfile_path)build/ +version := $$(git tag -l | tail -n 1) help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -debug: ## Build a debug version - @mkdir -p $(mkfile_path)build - @go build main.go -o $(mkfile_path)open-go-knocking +debug: clean-build ## Build a debug version + @mkdir -p $(build_path) + @go build -o $(build_path)open-go-knocking main.go @echo "Debug release done" release: clean-build build-linux build-darwin build-windows ## Build the release version clean-build: ## Clean the build directory - @rm -fr @mkdir -p $(mkfile_path)build/* + @rm -fr $(build_path)/* build-linux: ## Build release version for GNU/Linux - @mkdir -p $(mkfile_path)build - @GOOS="linux" GOARCH="amd64" go build -ldflags="-X 'main.version=$(version)'" -o $(mkfile_path)open-go-knocking-$(version)-linux-amd64 main.go - @GOOS="linux" GOARCH="arm64" go build -ldflags="-X 'main.version=$(version)'" -o $(mkfile_path)open-go-knocking-$(version)-linux-arm64 main.go - @GOOS="linux" GOARCH="386" go build -ldflags="-X 'main.version=$(version)'" -o $(mkfile_path)open-go-knocking-$(version)-linux-386 main.go + @mkdir -p $(build_path) + @GOOS="linux" GOARCH="amd64" go build -ldflags="-X 'main.version=$(version)'" -o $(build_path)open-go-knocking-$(version)-linux-amd64 main.go + @GOOS="linux" GOARCH="arm64" go build -ldflags="-X 'main.version=$(version)'" -o $(build_path)open-go-knocking-$(version)-linux-arm64 main.go + @GOOS="linux" GOARCH="386" go build -ldflags="-X 'main.version=$(version)'" -o $(build_path)open-go-knocking-$(version)-linux-386 main.go build-darwin: ## Build release version for MacOS - @mkdir -p $(mkfile_path)build - @GOOS="darwin" GOARCH="amd64" go build -ldflags="-X 'main.version=$(version)'" -o $(mkfile_path)open-go-knocking-$(version)-darwin-amd64 main.go - @GOOS="darwin" GOARCH="arm64" go build -ldflags="-X 'main.version=v0.0.1'" -o $(mkfile_path)open-go-knocking-$(version)-darwin-arm64 main.go + @mkdir -p $(build_path) + @GOOS="darwin" GOARCH="amd64" go build -ldflags="-X 'main.version=$(version)'" -o $(build_path)open-go-knocking-$(version)-darwin-amd64 main.go + @GOOS="darwin" GOARCH="arm64" go build -ldflags="-X 'main.version=v0.0.1'" -o $(build_path)open-go-knocking-$(version)-darwin-arm64 main.go build-windows: ## Build release version for Windows - @mkdir -p $(mkfile_path)build - @GOOS="windows" GOARCH="amd64" go build -ldflags="-X 'main.version=$(version)'" -o $(mkfile_path)open-go-knocking-$(version)-windows-amd64.exe main.go - @GOOS="windows" GOARCH="386" go build -ldflags="-X 'main.version=$(version)'" -o $(mkfile_path)open-go-knocking-$(version)-windows-386.exe main.go + @mkdir -p $(build_path) + @GOOS="windows" GOARCH="amd64" go build -ldflags="-X 'main.version=$(version)'" -o $(build_path)open-go-knocking-$(version)-windows-amd64.exe main.go + @GOOS="windows" GOARCH="386" go build -ldflags="-X 'main.version=$(version)'" -o $(build_path)open-go-knocking-$(version)-windows-386.exe main.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..d617f1e --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# OpenGoKnocking + +Simple and cross-platform port knocking client written in GoLang. + +

+ +

+ +## Installation + +To install OpenGoKnocking in your $GOPATH: + +```bash +git clone https://github.com/leblanc-simon/open-go-knocking.git +cd open-go-knocking +go install +``` + +alternatively, you can download binary from [releases](https://github.com/leblanc-simon/open-go-knocking/releases). +Binaries are availables for GNU/Linux, MacOS and Windows + +## Usage + +```bash +# Knock to the server example.com at port 1337 (tcp), then 1338 (UDP) and finally 1339 (TCP) +open-go-knocking example.com 1337:tcp 1338:udp 1339:tcp + +# If the majority of ports are TCP ports, you can use the following syntax (ports without protocol will be in TCP) +open-go-knocking --tcp example.com 1337 1338:udp 1339 + +# If the majority of ports are UDP ports, you can use the following syntax (ports without protocol will be in UDP) +open-go-knocking --udp example.com 1337 1338:tcp 1339 +``` + +## Options + +* `--tcp`: +* `--udp`: +* `--delay` (in ms): +* `--version`: Show the current version +* `--help`: Show the help + +## Errors + +Possible exit codes : + +* 0: all is fine :) +* 1: Not enough arguments (host and port are required) +* 2: Host is not a valid hostname or IP (v4 or v6) +* 3: Problems with ports or protocols (check if you use `--tcp` or `--udp` that the option is located before the host) + +## Author + +* Simon Leblanc + +## License + +[WTFPL](http://www.wtfpl.net/) + +## Logo + +Original Logo from [Takuya Ueda](https://twitter.com/tenntenn), you can find source [in the repository](https://github.com/golang-samples/gopher-vector). Licensed under the Creative Commons 3.0 Attributions license. + +Modified by Simon Leblanc. \ No newline at end of file diff --git a/assets/open-go-knocking.png b/assets/open-go-knocking.png new file mode 100644 index 0000000..f872314 Binary files /dev/null and b/assets/open-go-knocking.png differ diff --git a/assets/open-go-knocking.svg b/assets/open-go-knocking.svg new file mode 100644 index 0000000..1794b7c --- /dev/null +++ b/assets/open-go-knocking.svg @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/main.go b/main.go index aad6a3f..7346d2a 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ var ( versionFlag = flag.Bool("version", false, "Show version") tcpFlag = flag.Bool("tcp", false, "Send all packets to TCP") udpFlag = flag.Bool("udp", false, "Send all packets to UDP") - delayFlag = flag.Int("delay", 5, "Delay between each packet") + delayFlag = flag.Int("delay", 5, "Delay between each packet (in milliseconds)") version = "develop" appName = "OpenGoKnocking" @@ -146,7 +146,7 @@ func main() { } if flag.CommandLine.NArg() < 2 { - exitWithError(1, "Arguments missing !", true) + exitWithError(ExitCodeBadArg, "Arguments missing !", true) } host := getHostAndVerify()