Skip to content

Commit

Permalink
Added creds subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Jun 30, 2021
1 parent 8095fc8 commit 7756591
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
17 changes: 17 additions & 0 deletions client/command/bind-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,23 @@ func BindCommands(app *grumble.App, rpc rpcpb.SliverRPCClient) {
},
HelpGroup: consts.GenericHelpGroup,
})
lootCmd.AddCommand(&grumble.Command{
Name: consts.LootCredsStr,
Help: "Add credentials to the server's loot store",
LongHelp: help.GetHelpFor(consts.LootCredsStr),
Flags: func(f *grumble.Flags) {
f.String("n", "name", "", "name of this piece of loot")

f.Int("t", "timeout", defaultTimeout, "command timeout in seconds")
},
Run: func(ctx *grumble.Context) error {
fmt.Println()
lootAddCredential(ctx, rpc)
fmt.Println()
return nil
},
HelpGroup: consts.GenericHelpGroup,
})
lootCmd.AddCommand(&grumble.Command{
Name: consts.LootFetchStr,
Help: "Fetch a piece of loot from the server's loot store",
Expand Down
54 changes: 51 additions & 3 deletions client/command/loot.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,57 @@ func lootFetch(ctx *grumble.Context, rpc rpcpb.SliverRPCClient) {
}
}

func lootAddCredential(ctx *grumble.Context, rpc rpcpb.SliverRPCClient) {

prompt := &survey.Select{
Message: "Choose a credential type:",
Options: []string{
clientpb.CredentialType_API_KEY.String(),
clientpb.CredentialType_USER_PASSWORD.String(),
},
}
credType := ""
survey.AskOne(prompt, &credType, survey.WithValidator(survey.Required))
name := ctx.Flags.String("name")
if name == "" {
namePrompt := &survey.Input{Message: "Credential Name: "}
survey.AskOne(namePrompt, &name)
}

loot := &clientpb.Loot{
Type: clientpb.LootType_CREDENTIAL,
Name: name,
Credential: &clientpb.Credential{},
}

switch credType {
case clientpb.CredentialType_USER_PASSWORD.String():
loot.Credential.Type = clientpb.CredentialType_USER_PASSWORD
usernamePrompt := &survey.Input{Message: "Username: "}
survey.AskOne(usernamePrompt, &loot.Credential.User)
passwordPrompt := &survey.Input{Message: "Password: "}
survey.AskOne(passwordPrompt, &loot.Credential.Password)
case clientpb.CredentialType_API_KEY.String():
loot.Credential.Type = clientpb.CredentialType_API_KEY
usernamePrompt := &survey.Input{Message: "API Key: "}
survey.AskOne(usernamePrompt, &loot.Credential.APIKey)
}

loot, err := rpc.LootAdd(context.Background(), loot)
if err != nil {
fmt.Printf(Warn+"%s\n", err)
return
}

fmt.Printf(Info+"Successfully added loot to server (%s)\n", loot.LootID)
}

func displayLootText(loot *clientpb.Loot) {
if loot.File == nil {
fmt.Printf(Warn + "Missing loot file\n")
return
}
fmt.Println()

if loot.File.Name != "" {
fmt.Printf("%sFile Name:%s %s\n\n", bold, normal, loot.File.Name)
Expand All @@ -243,12 +289,14 @@ func displayLootCredential(loot *clientpb.Loot) {
return
}

fmt.Println()

switch loot.Credential.Type {
case clientpb.CredentialType_USER_PASSWORD:
fmt.Printf("%s User:%s %s\n\n", bold, normal, loot.Credential.User)
fmt.Printf("%sPassword:%s %s\n\n", bold, normal, loot.Credential.Password)
fmt.Printf("%s User:%s %s\n", bold, normal, loot.Credential.User)
fmt.Printf("%sPassword:%s %s\n", bold, normal, loot.Credential.Password)
case clientpb.CredentialType_API_KEY:
fmt.Printf("%sAPI Key:%s %s\n\n", bold, normal, loot.Credential.APIKey)
fmt.Printf("%sAPI Key:%s %s\n", bold, normal, loot.Credential.APIKey)
default:
fmt.Printf("%v\n", loot.Credential) // Well, let's give it our best
}
Expand Down
1 change: 1 addition & 0 deletions client/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const (
LootLocalStr = "local"
LootRemoteStr = "remote"
LootFetchStr = "fetch"
LootCredsStr = "creds"

ImplantBuildsStr = "implants"
ListCanariesStr = "canaries"
Expand Down

0 comments on commit 7756591

Please sign in to comment.