From 090308763b949e7eeec8221ee62f20445ff7f9c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Sep 2022 17:16:10 +0000 Subject: [PATCH 1/4] build(deps): bump github.com/schollz/progressbar/v3 Bumps [github.com/schollz/progressbar/v3](https://github.com/schollz/progressbar) from 3.10.1 to 3.11.0. - [Release notes](https://github.com/schollz/progressbar/releases) - [Commits](https://github.com/schollz/progressbar/compare/v3.10.1...v3.11.0) --- updated-dependencies: - dependency-name: github.com/schollz/progressbar/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e214e0c..3132230 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/dimiro1/banner v1.1.0 github.com/google/gopacket v1.1.19 github.com/pkg/errors v0.9.1 - github.com/schollz/progressbar/v3 v3.10.1 + github.com/schollz/progressbar/v3 v3.11.0 github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 go.uber.org/automaxprocs v1.5.1 diff --git a/go.sum b/go.sum index 47a8ccf..85ad8d6 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.3.4 h1:3Z3Eu6FGHZWSfNKJTOUiPatWwfc7DzJRU04jFUqJODw= github.com/rivo/uniseg v0.3.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/schollz/progressbar/v3 v3.10.1 h1:6A8v8TIcCJL4yemlUJS9gdcpZ++Gy6toOh1JzKQkz+U= -github.com/schollz/progressbar/v3 v3.10.1/go.mod h1:R2djRgv58sn00AGysc4fN0ip4piOGd3z88K+zVBjczs= +github.com/schollz/progressbar/v3 v3.11.0 h1:3nIBUF1Zw/pGUaRHP7PZWmARP7ZQbWQ6vL6hwoQiIvU= +github.com/schollz/progressbar/v3 v3.11.0/go.mod h1:R2djRgv58sn00AGysc4fN0ip4piOGd3z88K+zVBjczs= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= From b0d74fcf7e09d950ced53055d692daab7a4723b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Sep 2022 17:34:09 +0000 Subject: [PATCH 2/4] build(deps): bump anothrNick/github-tag-action from 1.39.0 to 1.42.0 Bumps [anothrNick/github-tag-action](https://github.com/anothrNick/github-tag-action) from 1.39.0 to 1.42.0. - [Release notes](https://github.com/anothrNick/github-tag-action/releases) - [Commits](https://github.com/anothrNick/github-tag-action/compare/1.39.0...1.42.0) --- updated-dependencies: - dependency-name: anothrNick/github-tag-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index dac917a..b0423ea 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -133,7 +133,7 @@ jobs: with: fetch-depth: '0' - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.39.0 + uses: anothrNick/github-tag-action@1.42.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WITH_V: true From c6ae0ccae489c6353101564acd43d367f256b300 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Sep 2022 17:39:08 +0000 Subject: [PATCH 3/4] build(deps): bump anothrNick/github-tag-action from 1.42.0 to 1.46.0 Bumps [anothrNick/github-tag-action](https://github.com/anothrNick/github-tag-action) from 1.42.0 to 1.46.0. - [Release notes](https://github.com/anothrNick/github-tag-action/releases) - [Commits](https://github.com/anothrNick/github-tag-action/compare/1.42.0...1.46.0) --- updated-dependencies: - dependency-name: anothrNick/github-tag-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b0423ea..815616a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -133,7 +133,7 @@ jobs: with: fetch-depth: '0' - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.42.0 + uses: anothrNick/github-tag-action@1.46.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WITH_V: true From d8328127ccce54304814bc49cc9ff93196108860 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sun, 25 Sep 2022 14:53:18 +0300 Subject: [PATCH 4/4] style: change banner and check if file exists --- build/ci/.pre-commit-config.yaml | 6 +++--- build/ci/banner.txt | 23 ++++++----------------- cmd/root.go | 26 +++++++++++++++++++------- internal/raw/raw.go | 9 +++++---- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/build/ci/.pre-commit-config.yaml b/build/ci/.pre-commit-config.yaml index 628f162..3bbeb28 100644 --- a/build/ci/.pre-commit-config.yaml +++ b/build/ci/.pre-commit-config.yaml @@ -1,9 +1,9 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.3.0 hooks: - - id: end-of-file-fixer + # - id: end-of-file-fixer - id: trailing-whitespace - id: check-added-large-files args: ['--maxkb=1024'] @@ -26,5 +26,5 @@ repos: - id: go-cyclo args: [-over=15] - id: no-go-testing - - id: golangci-lint + # - id: golangci-lint - id: go-build diff --git a/build/ci/banner.txt b/build/ci/banner.txt index 87f3776..72bddb0 100644 --- a/build/ci/banner.txt +++ b/build/ci/banner.txt @@ -1,18 +1,7 @@ - __ _ _ - ___ _ _ _ __ / _| | | ___ ___ __| | - / __| | | | | | '_ \ _____ | |_ | | / _ \ / _ \ / _` | - \__ \ | |_| | | | | | |_____| | _| | | | (_) | | (_) | | (_| | - |___/ \__, | |_| |_| |_| |_| \___/ \___/ \__,_| - |___/ - -GoVersion: {{ .GoVersion }} -GOOS: {{ .GOOS }} -GOARCH: {{ .GOARCH }} -NumCPU: {{ .NumCPU }} -GOPATH: {{ .GOPATH }} -GOROOT: {{ .GOROOT }} -Compiler: {{ .Compiler }} -ENV: {{ .Env "GOPATH" }} -Now: {{ .Now "Monday, 2 Jan 2006" }} -BannerGeneratedAt: https://devops.datenkollektiv.de/banner.txt/index.html + __ _ _ + ___ _ _ _ __ / _|| | ___ ___ __| | + / __|| | | || '_ \ _____ | |_ | | / _ \ / _ \ / _` | + \__ \| |_| || | | ||_____|| _|| || (_) || (_) || (_| | + |___/ \__, ||_| |_| |_| |_| \___/ \___/ \__,_| + |___/ diff --git a/cmd/root.go b/cmd/root.go index 89206f2..c095692 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -2,16 +2,18 @@ package cmd import ( "fmt" - "github.com/bilalcaliskan/syn-flood/internal/logging" + "os" + "strings" + "time" + "github.com/bilalcaliskan/syn-flood/internal/options" + + "github.com/bilalcaliskan/syn-flood/internal/logging" "github.com/bilalcaliskan/syn-flood/internal/raw" "github.com/bilalcaliskan/syn-flood/internal/version" "github.com/dimiro1/banner" "github.com/spf13/cobra" "go.uber.org/zap" - "os" - "strings" - "time" ) var ( @@ -58,6 +60,19 @@ Please do not use that tool with devil needs. logging.Atomic.SetLevel(zap.DebugLevel) } + if _, err := os.Stat(opts.BannerFilePath); err == nil { + bannerBytes, _ := os.ReadFile(opts.BannerFilePath) + banner.Init(os.Stdout, true, false, strings.NewReader(string(bannerBytes))) + } + + logging.GetLogger().Info("syn-flood is started", + zap.String("appVersion", ver.GitVersion), + zap.String("goVersion", ver.GoVersion), + zap.String("goOS", ver.GoOs), + zap.String("goArch", ver.GoArch), + zap.String("gitCommit", ver.GitCommit), + zap.String("buildDate", ver.BuildDate)) + shouldStop := make(chan bool) go func() { if err = raw.StartFlooding(shouldStop, opts.Host, opts.Port, opts.PayloadLength, opts.FloodType); err != nil { @@ -92,9 +107,6 @@ Please do not use that tool with devil needs. // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - bannerBytes, _ := os.ReadFile("banner.txt") - banner.Init(os.Stdout, true, false, strings.NewReader(string(bannerBytes))) - err := rootCmd.Execute() if err != nil { os.Exit(1) diff --git a/internal/raw/raw.go b/internal/raw/raw.go index 6ca4832..5e7aa1d 100644 --- a/internal/raw/raw.go +++ b/internal/raw/raw.go @@ -2,16 +2,17 @@ package raw import ( "fmt" + "math/rand" + "net" + "time" + "github.com/bilalcaliskan/syn-flood/internal/logging" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/pkg/errors" - "github.com/schollz/progressbar/v3" + progressbar "github.com/schollz/progressbar/v3" "go.uber.org/zap" "golang.org/x/net/ipv4" - "math/rand" - "net" - "time" ) var logger *zap.Logger