Skip to content

Commit

Permalink
add option to save stage to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
TimBF committed Nov 10, 2023
1 parent a19fddf commit 48d7e72
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions client/command/generate/profiles-stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,17 @@ func ProfilesStageCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args
prependSize, _ := cmd.Flags().GetBool("prepend-size")
compressF, _ := cmd.Flags().GetString("compress")
compress := strings.ToLower(compressF)
save, _ := cmd.Flags().GetString("save")

profile := GetImplantProfileByName(profileName, con)
if profile == nil {
con.PrintErrorf("Profile not found\n")
return
}

save, _ := cmd.Flags().GetString("save")
if save == "" {
save, _ = os.Getwd()
}

ctrl := make(chan bool)
con.SpinUntil("Compiling, please wait ...", ctrl)
_, err := con.Rpc.GenerateStage(context.Background(), &clientpb.GenerateStageReq{
stage2, err := con.Rpc.GenerateStage(context.Background(), &clientpb.GenerateStageReq{
Profile: profileName,
Name: name,
AESEncryptKey: aesEncryptKey,
Expand All @@ -68,4 +64,17 @@ func ProfilesStageCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args
con.PrintErrorf("%s\n", err)
return
}

saveTo, err := saveLocation(save, stage2.File.Name, con)
if err != nil {
con.PrintErrorf("%s\n", err)
return
}

err = os.WriteFile(saveTo, stage2.File.Data, 0o700)
if err != nil {
con.PrintErrorf("Failed to write to: %s\n", saveTo)
return
}
con.PrintInfof("Implant saved to %s\n", saveTo)
}

0 comments on commit 48d7e72

Please sign in to comment.