■ ■ ■ ■ ■ ■
internal/client/handlers/session.go
| skipped 13 lines |
14 | 14 | | |
15 | 15 | | "github.com/NHAS/reverse_ssh/internal" |
16 | 16 | | "github.com/NHAS/reverse_ssh/internal/client/handlers/subsystems" |
| 17 | + | "github.com/NHAS/reverse_ssh/internal/terminal" |
17 | 18 | | "github.com/NHAS/reverse_ssh/pkg/logger" |
18 | 19 | | "github.com/NHAS/reverse_ssh/pkg/storage" |
19 | 20 | | |
| skipped 57 lines |
77 | 78 | | |
78 | 79 | | req.Reply(true, nil) |
79 | 80 | | |
80 | | - | parts := strings.Split(cmd.Cmd, " ") |
81 | | - | if len(parts) == 0 { |
| 81 | + | line := terminal.ParseLine(cmd.Cmd, 0) |
| 82 | + | |
| 83 | + | if line.Empty() { |
| 84 | + | log.Warning("Human client sent an empty exec payload: %s\n", err) |
82 | 85 | | return |
83 | 86 | | } |
84 | 87 | | |
85 | | - | if parts[0] == "scp" { |
86 | | - | scp(parts, connection, log) |
| 88 | + | command := line.Command.Value() |
| 89 | + | |
| 90 | + | if command == "scp" { |
| 91 | + | scp(line.Chunks[1:], connection, log) |
87 | 92 | | return |
88 | 93 | | } |
89 | 94 | | |
90 | | - | command := parts[0] |
91 | | - | if u, ok := isUrl(parts[0]); ok { |
| 95 | + | if u, ok := isUrl(command); ok { |
92 | 96 | | command, err = download(user.ServerConnection, u) |
93 | 97 | | if err != nil { |
94 | 98 | | fmt.Fprintf(connection, "%s", err.Error()) |
| skipped 2 lines |
97 | 101 | | } |
98 | 102 | | |
99 | 103 | | if user.Pty != nil { |
100 | | - | runCommandWithPty(command, parts[1:], user, requests, log, connection) |
| 104 | + | runCommandWithPty(command, line.Chunks[1:], user, requests, log, connection) |
101 | 105 | | return |
102 | 106 | | } |
103 | | - | runCommand(command, parts[1:], connection) |
| 107 | + | runCommand(command, line.Chunks[1:], connection) |
104 | 108 | | |
105 | 109 | | return |
106 | 110 | | case "shell": |
| skipped 143 lines |