Skip to content

Commit

Permalink
[+] #32 display commands execution results
Browse files Browse the repository at this point in the history
  • Loading branch information
WangYihang committed Mar 19, 2021
1 parent ac3db94 commit 74eb0ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions lib/cli/dispatcher/data_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"os"
"strings"

"github.com/WangYihang/Platypus/lib/context"
"github.com/WangYihang/Platypus/lib/util/log"
Expand All @@ -19,17 +20,13 @@ func (dispatcher Dispatcher) DataDispatcher(args []string) {
return
}
n := 0
command = strings.TrimSpace(command)
for _, server := range context.Ctx.Servers {
for _, client := range (*server).GetAllTCPClients() {
if client.GroupDispatch {
log.Info("Executing on %s: %s", client.FullDesc(), command[0:len(command)-1])
size, err := client.Conn.Write([]byte(command + "\n"))
fmt.Println(size)
if err != nil {
log.Error("Write error: %s", err)
(*server).DeleteTCPClient(client)
continue
}
log.Info("Executing on %s: %s", client.FullDesc(), command)
result := client.SystemToken(command)
log.Success("%s", result)
n++
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/context/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (s *TCPServer) Run() {
}
}
if clientExist {
log.Warn("Incoming connection comes from a machine which has already connected.")
log.Warn("Incoming connection comes from a machine which has already connected. You can use `BlockSameIP` to switch [ON|OFF]")
client.Close()
} else {
log.Info("New client %s Connected", client.FullDesc())
Expand Down

0 comments on commit 74eb0ff

Please sign in to comment.