Skip to content

Commit

Permalink
Merge pull request #134 from CalypsoSys/ntlm_message_encryption
Browse files Browse the repository at this point in the history
support NTLM message encryption
  • Loading branch information
masterzen authored Nov 20, 2023
2 parents a7fbe84 + 30b2a0f commit 807053a
Show file tree
Hide file tree
Showing 4 changed files with 507 additions and 39 deletions.
24 changes: 24 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ func (c *Client) RunWithContextWithString(ctx context.Context, command string, s
return outWriter.String(), errWriter.String(), exitCode, err
}

// RunCmdWithContext will run command on the the remote host, returning the process stdout and stderr
// as strings
// If the context is canceled, the remote command is canceled.
func (c *Client) RunCmdWithContext(ctx context.Context, command string) (string, string, int, error) {
var outWriter, errWriter bytes.Buffer
exitCode, err := c.RunWithContextWithInput(ctx, command, &outWriter, &errWriter, nil)
return outWriter.String(), errWriter.String(), exitCode, err
}

// RunPSWithString will basically wrap your code to execute commands in powershell.exe. Default RunWithString
// runs commands in cmd.exe
//
Expand All @@ -157,6 +166,21 @@ func (c *Client) RunPSWithContextWithString(ctx context.Context, command string,
return c.RunWithContextWithString(ctx, command, stdin)
}

// RunPSWithContext will basically wrap your code to execute commands in powershell.exe.
// runs commands in cmd.exe
func (c *Client) RunPSWithContext(ctx context.Context, command string) (string, string, int, error) {
command = Powershell(command)

// Let's check if we actually created a command
if command == "" {
return "", "", 1, errors.New("cannot encode the given command")
}

var outWriter, errWriter bytes.Buffer
exitCode, err := c.RunWithContextWithInput(ctx, command, &outWriter, &errWriter, nil)
return outWriter.String(), errWriter.String(), exitCode, err
}

// RunWithInput will run command on the the remote host, writing the process stdout and stderr to
// the given writers, and injecting the process stdin with the stdin reader.
// Warning stdin (not stdout/stderr) are bufferized, which means reading only one byte in stdin will
Expand Down
Loading

0 comments on commit 807053a

Please sign in to comment.