iT邦幫忙

2023 iThome 鐵人賽

DAY 16
0
Security

天堂雲端之從開始到接管系列 第 16

[Day 16] 天堂雲端 - AWS S3 Enumerate POC

  • 分享至 

  • xImage
  •  

Enumerate

S3 Web endpoint

S3 web endpoint組成:https://{BUCKET_NAME}.s3.amazonaws.com/
enumerate(枚舉)所有可能的名詞組合建立出來的S3 bucket是否是公開存取的?

// set wordlist to enumerate all s3-buckets

package main

import (
	"bufio"
	"fmt"
	"net/http"
	"os"
)

func main() {
	// open wordlist file
	file, err := os.Open("S3/wordlist.txt")   # File here!
	if err != nil {
		fmt.Println("Failed to open wordlist file:", err)
		return
	}
	defer file.Close()

	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		// get wordlist
		word := scanner.Text()

		// build s3 web endpoint
		url := "https://" + word + ".s3.amazonaws.com/"

		// send http request
		response, err := http.Get(url)
		if err != nil {
			fmt.Println("Http request err:", err)
			return
		}
		defer response.Body.Close()

		// Get status code
		if response.StatusCode == http.StatusOK {
			fmt.Printf("%s: S3 bucket is exist!\n", url)
		} else if response.StatusCode == http.StatusNotFound {
			fmt.Printf("%s: S3 bucket is not exist\n", url)
		} else {
			fmt.Printf("%s: Unknown status code %d\n", url, response.StatusCode)
		}
	}

	if err := scanner.Err(); err != nil {
		fmt.Println("scanner err:", err)
	}
}

上一篇
[Day 15] 天堂雲端 - Data Exfiltration on S3
下一篇
[Day 17] 天堂雲端 - AWS S3 Misconfiguration&POC
系列文
天堂雲端之從開始到接管30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言