-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (41 loc) · 1013 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"os"
metacredsaws "github.com/4armed/metacreds/pkg/aws"
)
func main() {
var creds metacredsaws.Creds
stdin := flag.Bool("s", false, "process STDIN instead of metadata service")
region := flag.String("region", "eu-west-1", "AWS region")
flag.Parse()
if *stdin {
err := json.NewDecoder(os.Stdin).Decode(&creds)
if err != nil {
log.Fatal(err)
}
} else {
c, p, err := metacredsaws.New()
if err != nil {
fmt.Printf("New session error: %v", err)
return
}
metadataCreds, err := metacredsaws.Retrieve(c, p)
if err != nil {
fmt.Printf("Retrieve creds error: %v", err)
return
}
awsRegion, _ := c.Region()
region = &awsRegion
creds = metacredsaws.Creds{
AccessKeyID: metadataCreds.AccessKeyID,
SecretAccessKey: metadataCreds.SecretAccessKey,
SessionToken: metadataCreds.SessionToken,
}
}
profile := metacredsaws.GenerateProfile("pentest", *region, creds)
fmt.Printf("%v\n", profile)
}