Skip to content

Commit

Permalink
feat(billing):tencent cloud billing query
Browse files Browse the repository at this point in the history
  • Loading branch information
404tk committed Apr 1, 2023
1 parent 2406629 commit 9bf95f8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Cloud Penetration Testing Toolkit

| Providers | Payload | Supported |
| :-------------------------: | :-----------------------------------------: | :----------------------------------------------------------: |
| Alibaba Cloud | cloudlist<br/>backdoor-user<br/>bucket-dump | ECS (Elastic Compute Service)<br/>OSS (Object Storage Service)<br/>RAM (Resource Access Management)<br/>RDS (Relational Database Service) |
| Alibaba Cloud | cloudlist<br/>backdoor-user | ECS (Elastic Compute Service)<br/>OSS (Object Storage Service)<br/>RAM (Resource Access Management)<br/>RDS (Relational Database Service) |
| Tencent Cloud | cloudlist<br/>backdoor-user | CVM (Cloud Virtual Machine)<br/>Lighthouse<br/>COS (Cloud Object Storage)<br/>CAM (Cloud Access Management) |
| Huawei Cloud | cloudlist<br/>backdoor-user | ECS (Elastic Cloud Server)<br/>OBS (Object Storage Service)<br/>IAM (Identity and Access Management)<br/>RDS (Relational Database Service) |
| Microsoft Azure | cloudlist | Virtual Machines<br/>Blob Storage |
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ require (
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.22.11+incompatible
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.0.97
github.com/modood/table v0.0.0-20220527013332-8d47e76dad33
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/billing v1.0.628
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.557
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.557
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.628
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.557
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lighthouse v1.0.557
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sts v1.0.557
Expand Down
9 changes: 8 additions & 1 deletion pkg/providers/alibaba/ecs/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ type InstanceProvider struct {
func (d *InstanceProvider) GetResource(ctx context.Context) ([]*schema.Host, error) {
list := schema.NewResources().Hosts
log.Println("[*] Start enumerating ECS ...")
// check permission
req_vpc := ecs.CreateDescribeVpcsRequest()
_, err := d.Client.DescribeVpcs(req_vpc)
if err != nil {
log.Println("[-] Describe vpcs failed.")
return list, err
}
req := ecs.CreateDescribeRegionsRequest()
resp, err := d.Client.DescribeRegions(req)
if err != nil {
log.Println("[-] Enumerate ECS failed.")
log.Println("[-] Describe regions failed.")
return list, err
}
flag := false
Expand Down
14 changes: 13 additions & 1 deletion pkg/providers/tencent/tencent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tencent

import (
"context"
"fmt"
"log"

"github.com/404tk/cloudtoolkit/pkg/providers/tencent/cam"
Expand All @@ -11,6 +12,7 @@ import (
"github.com/404tk/cloudtoolkit/pkg/schema"
"github.com/404tk/cloudtoolkit/utils"
"github.com/404tk/cloudtoolkit/utils/cache"
billing "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/billing/v20180709"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
sts "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sts/v20180813"
Expand Down Expand Up @@ -46,10 +48,20 @@ func New(options schema.Options) (*Provider, error) {
if err != nil {
return nil, err
}
log.Printf("[+] Current account type: %s\n", *response.Response.Type)
msg := "[+] Current account type: " + *response.Response.Type
// accountId, _ := strconv.Atoi(*response.Response.UserId)
cache.Cfg.CredInsert(*response.Response.Type, options)

// cpf.HttpProfile.Endpoint = "billing.tencentcloudapi.com"
client, _ := billing.NewClient(credential, "ap-guangzhou", cpf)
req_billing := billing.NewDescribeAccountBalanceRequest()
resp_billing, err := client.DescribeAccountBalance(req_billing)
if err == nil {
cash := *resp_billing.Response.RealBalance / 100
msg += fmt.Sprintf(", available cash amount: %v", cash)
}
log.Println(msg)

return &Provider{
vendor: "tencent",
credential: credential,
Expand Down

0 comments on commit 9bf95f8

Please sign in to comment.