From fd41b220e2356e4bea6ca079b07fe5983ecf074c Mon Sep 17 00:00:00 2001 From: nakabonne Date: Thu, 1 Oct 2020 16:13:10 +0900 Subject: [PATCH] Show input parameters --- gui/gui.go | 2 +- gui/widgets.go | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gui/gui.go b/gui/gui.go index 1d6e25a..bd473ad 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -41,7 +41,7 @@ func run(t *termbox.Terminal, r runner, targetURL string, opts *attacker.Options return fmt.Errorf("failed to generate container: %w", err) } - w, err := newWidgets() + w, err := newWidgets(targetURL, opts) if err != nil { return fmt.Errorf("failed to generate widgets: %w", err) } diff --git a/gui/widgets.go b/gui/widgets.go index 29ea121..765e7cf 100644 --- a/gui/widgets.go +++ b/gui/widgets.go @@ -1,6 +1,7 @@ package gui import ( + "fmt" "strconv" "github.com/mum4k/termdash/cell" @@ -55,16 +56,12 @@ type widgets struct { navi Text } -func newWidgets() (*widgets, error) { +func newWidgets(targetURL string, opts *attacker.Options) (*widgets, error) { latencyChart, err := newLineChart() if err != nil { return nil, err } - paramsText, err := newText("") - if err != nil { - return nil, err - } messageText, err := newText("Give the target URL and press Enter") if err != nil { return nil, err @@ -82,6 +79,11 @@ func newWidgets() (*widgets, error) { return nil, err } + paramsText, err := newText(makeParamsText(targetURL, opts)) + if err != nil { + return nil, err + } + navi, err := newText("Ctrl-C: quit, Enter: attack") if err != nil { return nil, err @@ -177,3 +179,14 @@ func newGauge() (Gauge, error) { //gauge.BorderTitle("Progress"), ) } + +// TODO: Make header easy to see. +func makeParamsText(targetURL string, opts *attacker.Options) string { + return fmt.Sprintf(`Target: %s +Rate: %d +Duration: %v +Method: %s +Header: %v +Body: %s +`, targetURL, opts.Rate, opts.Duration, opts.Method, opts.Header, opts.Body) +}