Projects STRLCPY reverse_ssh Commits 4214bcfc
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    internal/client/client.go
    skipped 186 lines
    187 187   
    188 188   clientLog := logger.NewLog("client")
    189 189   
    190  - user, err := internal.CreateUser(sshConn)
    191  - if err != nil {
    192  - clientLog.Warning("Unable to create internal user")
    193  - return
    194  - }
    195  - 
    196 190   //Do not register new client callbacks here, they are actually within the JumpHandler
    197 191   //session is handled here as a legacy hangerover from allowing a client who has directly connected to the servers console to run the connect command
    198 192   //Otherwise anything else should be done via jumphost syntax -J
    199  - err = internal.RegisterChannelCallbacks(user, chans, clientLog, map[string]internal.ChannelHandler{
    200  - "session": handlers.Session,
     193 + err = internal.RegisterChannelCallbacks(nil, chans, clientLog, map[string]internal.ChannelHandler{
     194 + "session": handlers.ServerConsoleSession(sshConn),
    201 195   "jump": handlers.JumpHandler(sshPriv),
    202 196   })
    203 197   
    skipped 12 lines
  • ■ ■ ■ ■ ■ ■
    internal/client/handlers/session.go
    skipped 15 lines
    16 16   "github.com/NHAS/reverse_ssh/internal/client/handlers/subsystems"
    17 17   "github.com/NHAS/reverse_ssh/pkg/logger"
    18 18   "github.com/NHAS/reverse_ssh/pkg/storage"
     19 + 
    19 20   "golang.org/x/crypto/ssh"
    20 21  )
     22 + 
     23 +func ServerConsoleSession(ServerConn ssh.Conn) internal.ChannelHandler {
     24 + 
     25 + user, err := internal.CreateUser(ServerConn)
     26 + 
     27 + return func(_ *internal.User, newChannel ssh.NewChannel, log logger.Logger) {
     28 + if err != nil {
     29 + log.Error("Unable to add user %s\n", err)
     30 + newChannel.Reject(ssh.ConnectionFailed, err.Error())
     31 + return
     32 + }
     33 + 
     34 + Session(user, newChannel, log)
     35 + }
     36 + 
     37 +}
    21 38   
    22 39  // Session has a lot of 'function' in ssh. It can be used for shell, exec, subsystem, pty-req and more.
    23 40  // However these calls are done through requests, rather than opening a new channel
    skipped 209 lines
  • ■ ■ ■ ■
    internal/server/commands/exec.go
    skipped 88 lines
    89 89   continue
    90 90   }
    91 91   go ssh.DiscardRequests(r)
    92  - defer newChan.Close()
    93 92   
    94 93   response, err := newChan.SendRequest("exec", true, commandByte)
    95 94   if err != nil && !line.IsSet("q") {
    skipped 12 lines
    108 107   }
    109 108   
    110 109   io.Copy(tty, newChan)
     110 + newChan.Close()
    111 111   }
    112 112   
    113 113   fmt.Fprint(tty, "\n")
    skipped 22 lines
Please wait...
Page is in error, reload to recover