Skip to content

Commit

Permalink
Merge pull request #407 from BishopFox/stage
Browse files Browse the repository at this point in the history
Fix Upload Encoder / Improved Error Handling
  • Loading branch information
moloch-- authored Apr 22, 2021
2 parents ba43f1d + 8c27bd6 commit 6ddf846
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
4 changes: 2 additions & 2 deletions client/command/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ func getTargets(targetOS string, targetArch string) (string, string) {
targetOS = "linux"
}

if targetArch == "x64" || strings.HasPrefix(targetArch, "64") {
if targetArch == "amd64" || targetArch == "x64" || strings.HasPrefix(targetArch, "64") {
targetArch = "amd64"
}
if targetArch == "x86" || strings.HasPrefix(targetArch, "32") {
if targetArch == "386" || targetArch == "x86" || strings.HasPrefix(targetArch, "32") {
targetArch = "386"
}

Expand Down
9 changes: 9 additions & 0 deletions client/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,14 @@ var asciiLogos = []string{
╚════██║██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██╗
███████║███████╗██║ ╚████╔╝ ███████╗██║ ██║
╚══════╝╚══════╝╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
` + normal,

bold + gray + `
.------..------..------..------..------..------.
|S.--. ||L.--. ||I.--. ||V.--. ||E.--. ||R.--. |
| :/\: || :/\: || (\/) || :(): || (\/) || :(): |
| :\/: || (__) || :\/: || ()() || :\/: || ()() |
| '--'S|| '--'L|| '--'I|| '--'V|| '--'E|| '--'R|
` + "`------'`------'`------'`------'`------'`------'" + `
` + normal,
}
2 changes: 1 addition & 1 deletion go-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Creates the static go asset archives

GO_VER="1.16.3"
GARBLE_VER="1.16.2"
GARBLE_VER="1.16.3"

GO_ARCH_1="amd64"
GO_ARCH_2="arm64"
Expand Down
30 changes: 25 additions & 5 deletions implant/sliver/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,23 +309,40 @@ func uploadHandler(data []byte, resp RPCResponse) {
return
}

uploadPath, _ := filepath.Abs(uploadReq.Path)
uploadPath, err := filepath.Abs(uploadReq.Path)
if err != nil {
// {{if .Config.Debug}}
log.Printf("upload path error: %v", err)
// {{end}}
resp([]byte{}, err)
}

// Process Upload
upload := &sliverpb.Upload{Path: uploadPath}

f, err := os.Create(uploadPath)
if err != nil {
upload.Response = &commonpb.Response{
Err: fmt.Sprintf("%v", err),
}

} else {
// Create file, write data to file system
defer f.Close()
data, err := gzipRead(uploadReq.Data)
var uploadData []byte
var err error
if uploadReq.Encoder == "gzip" {
uploadData, err = gzipRead(uploadReq.Data)
} else {
uploadData = uploadReq.Data
}
// Check for decode errors
if err != nil {
upload.Response = &commonpb.Response{
Err: fmt.Sprintf("%v", err),
}
} else {
f.Write(data)
f.Write(uploadData)
}
}

Expand Down Expand Up @@ -580,9 +597,12 @@ func gzipWrite(w io.Writer, data []byte) error {

func gzipRead(data []byte) ([]byte, error) {
bytes.NewReader(data)
reader, _ := gzip.NewReader(bytes.NewReader(data))
reader, err := gzip.NewReader(bytes.NewReader(data))
if err != nil {
return nil, err
}
var buf bytes.Buffer
_, err := buf.ReadFrom(reader)
_, err = buf.ReadFrom(reader)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6ddf846

Please sign in to comment.