MCPcopy Create free account
hub / github.com/evilsocket/shellz / toOutputFile

Function toOutputFile

cmd/shellz/run.go:52–71  ·  view source on GitHub ↗
(shell models.Shell, out []byte)

Source from the content-addressed store, hash-verified

50}
51
52func toOutputFile(shell models.Shell, out []byte) (outs string) {
53 toOutputLock.Lock()
54 defer toOutputLock.Unlock()
55
56 fileName := toOutputFilename(shell)
57 if file, err := os.OpenFile(fileName, os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644); err != nil {
58 outs = fmt.Sprintf(" > error while saving to %s: %s", fileName, err)
59 } else {
60 defer file.Close()
61 size := len(out)
62 if wrote, err := file.Write(out); err != nil {
63 outs = fmt.Sprintf(" > error while saving to %s: %s", fileName, err)
64 } else if wrote != size {
65 outs = fmt.Sprintf(" > error while saving to %s: size is %d, wrote %d", fileName, size, wrote)
66 } else {
67 outs = tui.Dim(fmt.Sprintf(" > %d bytes saved to %s", size, fileName))
68 }
69 }
70 return
71}
72
73func processOutput(out []byte, shell models.Shell) string {
74 outs := tui.Dim(" <no output>")

Callers 1

processOutputFunction · 0.85

Calls 3

toOutputFilenameFunction · 0.85
WriteMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected