Skip to content

Commit

Permalink
Remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
rkervella committed Jun 9, 2022
1 parent 573ec4d commit 6cbfe64
Showing 1 changed file with 0 additions and 152 deletions.
152 changes: 0 additions & 152 deletions client/command/filesystem/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,158 +37,6 @@ import (
"github.com/desertbit/grumble"
)

// func PerformDownload(remotePath string, fileName string, destination string, ctx *grumble.Context, con *console.SliverConsoleClient) (*sliverpb.Download, error) {
// ctrl := make(chan bool)
// con.SpinUntil(fmt.Sprintf("%s -> %s", fileName, destination), ctrl)
// download, err := con.Rpc.Download(context.Background(), &sliverpb.DownloadReq{
// Request: con.ActiveTarget.Request(ctx),
// Path: remotePath,
// })
// ctrl <- true
// <-ctrl
// if err != nil {
// return nil, err
// }
// if download.Response != nil && download.Response.Async {
// con.AddBeaconCallback(download.Response.TaskID, func(task *clientpb.BeaconTask) {
// err = proto.Unmarshal(task.Response, download)
// if err != nil {
// con.PrintErrorf("Failed to decode response %s\n", err)
// }
// })
// con.PrintAsyncResponse(download.Response)
// }

// if download.Response != nil && download.Response.Err != "" {
// return download, fmt.Errorf("%s\n", download.Response.Err)
// }

// if download.Encoder == "gzip" {
// download.Data, err = new(encoders.Gzip).Decode(download.Data)
// if err != nil {
// return nil, fmt.Errorf("Decoding failed %s", err)
// }
// }

// return download, nil
// }

// // DownloadCmd - Download a file from the remote system
// func DownloadCmd(ctx *grumble.Context, con *console.SliverConsoleClient) {
// session, beacon := con.ActiveTarget.GetInteractive()
// if session == nil && beacon == nil {
// return
// }

// remotePath := ctx.Args.String("remote-path")
// localPath := ctx.Args.String("local-path")

// src := remotePath
// fileName := filepath.Base(src)
// var dst string
// var err error
// var lootType clientpb.LootType
// var fileType clientpb.FileType
// var lootName string = ""

// if ctx.Flags.Bool("loot") {
// // The destination is the loot store.
// dst = "loot"
// lootName = ctx.Flags.String("name")

// lootType, err = loot.ValidateLootType(ctx.Flags.String("type"))
// if err != nil {
// con.PrintErrorf("%s\n", err)
// return
// }
// // Determine file type after the download is complete
// } else {
// // If this download is not being looted, make sure the local path exists
// dst, err = filepath.Abs(localPath)
// if err != nil {
// con.PrintErrorf("%s\n", err)
// return
// }
// fi, err := os.Stat(dst)
// if err != nil && !os.IsNotExist(err) {
// con.PrintErrorf("%s\n", err)
// return
// }
// if err == nil && fi.IsDir() {
// dst = path.Join(dst, fileName)
// }
// }

// download, err := PerformDownload(src, fileName, dst, ctx, con)
// if err != nil {
// con.PrintErrorf("%s\n", err)
// return
// }

// if dst == "loot" {
// // Hand off to the loot package to take care of looting
// fileType = loot.ValidateLootFileType(ctx.Flags.String("file-type"), download.Data)
// loot.LootDownload(download, lootName, lootType, fileType, ctx, con)
// } else {
// PrintDownload(download, ctx, con)
// }
// }

// // PrintDownload - Print the download response, and save file to disk
// func PrintDownload(download *sliverpb.Download, ctx *grumble.Context, con *console.SliverConsoleClient) {
// if download.Response != nil && download.Response.Err != "" {
// con.PrintErrorf("%s\n", download.Response.Err)
// return
// }

// remotePath := ctx.Args.String("remote-path")
// localPath := ctx.Args.String("local-path")

// src := remotePath
// fileName := filepath.Base(src)
// dst, err := filepath.Abs(localPath)
// if err != nil {
// con.PrintErrorf("%s\n", err)
// return
// }

// fi, err := os.Stat(dst)
// if err != nil && !os.IsNotExist(err) {
// con.PrintErrorf("%s\n", err)
// return
// }
// if err == nil && fi.IsDir() {
// dst = path.Join(dst, fileName)
// }

// // Add an extension to a directory download if one is not provided.
// if download.IsDir && (!strings.HasSuffix(dst, ".tgz") || !strings.HasSuffix(dst, ".tar.gz")) {
// dst += ".tar.gz"
// }

// if _, err := os.Stat(dst); err == nil {
// overwrite := false
// prompt := &survey.Confirm{Message: "Overwrite local file?"}
// survey.AskOne(prompt, &overwrite, nil)
// if !overwrite {
// return
// }
// }

// dstFile, err := os.Create(dst)
// if err != nil {
// con.PrintErrorf("Failed to open local file %s: %s\n", dst, err)
// return
// }
// defer dstFile.Close()
// n, err := dstFile.Write(download.Data)
// if err != nil {
// con.PrintErrorf("Failed to write data %v\n", err)
// } else {
// con.PrintInfof("Wrote %d bytes to %s\n", n, dstFile.Name())
// }
// }

func DownloadCmd(ctx *grumble.Context, con *console.SliverConsoleClient) {
session, beacon := con.ActiveTarget.GetInteractive()
if session == nil && beacon == nil {
Expand Down

0 comments on commit 6cbfe64

Please sign in to comment.