Projects STRLCPY reverse_ssh Commits 3c03c49c
🤬
  • Add client public key hash as identifier

  • Loading...
  • NHAS committed 2 years ago
    3c03c49c
    1 parent b4168b87
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    internal/server/clients/clients.go
    skipped 41 lines
    42 42   
    43 43   username := NormaliseHostname(conn.User())
    44 44   
    45  - if _, ok := aliases[username]; !ok {
    46  - aliases[username] = make(map[string]bool)
    47  - }
    48  - 
    49  - uniqueIdToAllAliases[idString] = append(uniqueIdToAllAliases[idString], username)
    50  - aliases[username][idString] = true
    51  - 
    52  - if _, ok := aliases[conn.RemoteAddr().String()]; !ok {
    53  - aliases[conn.RemoteAddr().String()] = make(map[string]bool)
    54  - }
    55  - 
    56  - uniqueIdToAllAliases[idString] = append(uniqueIdToAllAliases[idString], conn.RemoteAddr().String())
    57  - aliases[conn.RemoteAddr().String()][idString] = true
     45 + addAlias(idString, username)
     46 + addAlias(idString, conn.RemoteAddr().String())
     47 + addAlias(idString, conn.Permissions.Extensions["pubkey-fp"])
    58 48   
    59 49   clients[idString] = conn
    60 50   
    skipped 4 lines
    65 55   
    66 56   return idString, username, nil
    67 57   
     58 +}
     59 + 
     60 +func addAlias(uniqueId, newAlias string) {
     61 + if _, ok := aliases[newAlias]; !ok {
     62 + aliases[newAlias] = make(map[string]bool)
     63 + }
     64 + 
     65 + uniqueIdToAllAliases[uniqueId] = append(uniqueIdToAllAliases[uniqueId], newAlias)
     66 + aliases[newAlias][uniqueId] = true
    68 67  }
    69 68   
    70 69  func Search(filter string) (out map[string]*ssh.ServerConn, err error) {
    skipped 104 lines
  • ■ ■ ■ ■ ■ ■
    internal/server/commands/list.go
    skipped 16 lines
    17 17  }
    18 18   
    19 19  type displayItem struct {
    20  - sc ssh.Conn
     20 + sc ssh.ServerConn
    21 21   id string
    22 22  }
    23 23   
    24 24  func fancyTable(tty io.ReadWriter, applicable []displayItem) {
    25 25   
    26  - t, _ := table.NewTable("Targets", "ID", "Hostname", "IP Address", "Version")
     26 + t, _ := table.NewTable("Targets", "ID", "Public Key Hash", "Hostname", "IP Address", "Version")
    27 27   for _, a := range applicable {
    28  - t.AddValues(a.id, clients.NormaliseHostname(a.sc.User()), a.sc.RemoteAddr().String(), string(a.sc.ClientVersion()))
     28 + t.AddValues(a.id, a.sc.Permissions.Extensions["pubkey-fp"], clients.NormaliseHostname(a.sc.User()), a.sc.RemoteAddr().String(), string(a.sc.ClientVersion()))
    29 29   }
    30 30   
    31 31   t.Fprint(tty)
    skipped 39 lines
    71 71   sort.Strings(ids)
    72 72   
    73 73   for _, id := range ids {
    74  - toReturn = append(toReturn, displayItem{id: id, sc: matchingClients[id]})
     74 + toReturn = append(toReturn, displayItem{id: id, sc: *matchingClients[id]})
    75 75   }
    76 76   
    77 77   if line.IsSet("t") {
    skipped 5 lines
    83 83   
    84 84   for i, tr := range toReturn {
    85 85   
    86  - fmt.Fprintf(tty, "%s %s %s, version: %s", tr.id, clients.NormaliseHostname(tr.sc.User()), tr.sc.RemoteAddr().String(), tr.sc.ClientVersion())
     86 + fmt.Fprintf(tty, "%s %s %s %s, version: %s", tr.id, tr.sc.Permissions.Extensions["pubkey-fp"], clients.NormaliseHostname(tr.sc.User()), tr.sc.RemoteAddr().String(), tr.sc.ClientVersion())
    87 87   
    88 88   if i != len(toReturn)-1 {
    89 89   fmt.Fprint(tty, sep)
    skipped 19 lines
    109 109   
    110 110   return terminal.MakeHelpText(
    111 111   "ls [OPTION] [FILTER]",
    112  - "Filter uses glob matching against all attributes of a target (hostname, ip, id)",
     112 + "Filter uses glob matching against all attributes of a target (id, public key hash, hostname, ip)",
    113 113   "\t-t\tPrint all attributes in pretty table",
    114 114   "\t-h\tPrint help",
    115 115   )
    skipped 2 lines
Please wait...
Page is in error, reload to recover