' >>~/objectify-s3/out.html
140 | listbuckets; printmisconfbuckets;
141 | echo $'\n'"$(tput bold)$(tput setab 7)$(tput setaf 1)Listing public objects from all buckets now $(tput sgr 0)"$'\n'
142 | echo '
Public Objects Found ▼
'>>~/objectify-s3/out.html
143 | for bucket in `cat ~/.objectify-s3/vulnbuckets.txt`
144 | do
145 | echo $'\n'"$(tput bold)$(tput setaf 1)Bucket - > $bucket $(tput sgr 0)";
146 | findvulnobj;
147 | tmpfile=~/objectify-s3/tmp.html
148 | if [ -f $tmpfile ]; then
149 | echo '
'>>~/objectify-s3/out.html
150 | cat ~/objectify-s3/tmp.html >> ~/objectify-s3/out.html 2>/dev/null
151 | rm ~/objectify-s3/tmp.html 2>/dev/null
152 | echo "
">>~/objectify-s3/out.html
153 | fi
154 |
155 |
156 | done
157 | echo "
">>~/objectify-s3/out.html
158 | open ~/objectify-s3/out.html
159 |
160 | echo $'\n'"$(tput smso) $(tput setaf 2) <<<<<<<<<<<<<< COMPLETED >>>>>>>>>>>>>> $(tput sgr 0)"$'\n'
161 |
--------------------------------------------------------------------------------
/sample_output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emgaurav/objectify-s3/889e7a173b985dbc6fed3d00293a1f6e1e29b8e3/sample_output.png
--------------------------------------------------------------------------------
/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "$(tput clear)$(tput bel)$(tput bold)"
3 | printf " _ _ _ _ __ _____
4 | ___ | |__ (_) ___ ___| |_(_)/ _|_ _ ___|___ /
5 | / _ \| '_ \| |/ _ \/ __| __| | |_| | | |_____/ __| |_ \
6 | | (_) | |_) | | __/ (__| |_| | _| |_| |_____\__ \___) |
7 | \___/|_.__// |\___|\___|\__|_|_| \__, | |___/____/
8 | |__/ |___/
9 | "
10 | tput sgr 0;
11 | if [ ! -d ~/.objectify-s3 ]; then
12 | mkdir ~/.objectify-s3
13 | fi
14 | touch ~/.objectify-s3/vulnbuckets.txt;
15 | touch ~/.objectify-s3/allbuckets.txt;
16 | echo -e "\n\n"
17 | echo "$(tput bold)$(tput setaf 2)<<<< Beginning Installation >>>>$(tput sgr 0)";
18 | echo "-----------------------------------"
19 | #setting aliases
20 | chmod +x objectify-s3.sh
21 | #ln -s objectify-s3.sh objectify-s3 2>/dev/null
22 | echo 'alias objectify-s3="bash ~/objectify-s3/objectify-s3.sh"' >> ~/.bashrc
23 | echo 'alias objectify-s3="bash ~/objectify-s3/objectify-s3.sh"' >> ~/.zshrc
24 | echo 'export PATH="$PATH:~/objectify-s3/"' >> ~/.bashrc
25 | echo 'export PATH="$PATH:~/objectify-s3/"' >> ~/.bash_profile
26 | echo 'export PATH="$PATH:~/objectify-s3/"' >> ~/.zshrc
27 |
28 | echo "$(tput bold)Finding ruby"
29 | if which ruby; then
30 | echo "$(tput bold)$(tput setaf 2)Found$(tput sgr 0)"
31 | echo "-----------------------------------"
32 | echo "Installing required gems"
33 | bundle install
34 | echo "$(tput bold)$(tput setaf 2)Done$(tput sgr 0)"
35 | else
36 | echo "$(tput setaf 1)$(tput bold)it seems ruby is not installed$(tput sgr 0)"
37 | exit 0;
38 | fi
39 | echo "-----------------------------------"
40 | echo "$(tput bold)Finding awscli"
41 | if which aws; then
42 | echo "$(tput bold)$(tput setaf 2)Found$(tput sgr 0)"
43 | echo "-----------------------------------"
44 | else
45 | echo "$(tput setaf 1) $(tput bold)it seems awscli is not installed.$(tput sgr 0)"
46 | echo "$(tput setaf 2) $(tput bold)Trying to install now. $(tput sgr 0)"
47 | if which brew; then
48 | brew install awscli
49 | brew link awscli
50 | echo "Now you need to set up your credentials for awscli."
51 | echo "-----------------------------------"
52 | else
53 | curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
54 | unzip awscliv2.zip
55 | sudo ./aws/install
56 | aws --version
57 | echo "$(tput setaf 2) $(tput bold) $(tput bel)awscli should be installed now. you must set up your aws access using $(tput sgr 0) aws configure"
58 | echo "-----------------------------------"
59 | fi
60 | fi
61 | #echo "$(tput bold)All Done. Run 'source ~/.bashrc' to set alias $(tput sgr 0)"$'\n'
62 | source ~/.bash_profile 2>/dev/null
63 | source ~/.bashrc 2>/dev/null
64 | source ~/.zshrc 2>/dev/null
65 |
66 |
67 | echo "$(tput setaf 2)$(tput bold)$(tput bel)<<<< Installation Complete >>>>$(tput sgr 0)"$'\n'
68 |
69 |
--------------------------------------------------------------------------------
/vulnobj.rb:
--------------------------------------------------------------------------------
1 | # find_public_s3_objects.rb
2 | require 'aws-sdk-s3' # v2: require 'aws-sdk'
3 | require 'thread/pool'
4 |
5 | BUCKET = ARGV[0] or raise("expected bucket name")
6 |
7 | s3 = Aws::S3::Resource.new(region: ARGV[1])
8 | region = ARGV[1]
9 |
10 | count = 0
11 | comp = 500
12 | pool = Thread.pool 50
13 | mutex = Mutex.new
14 | s3.bucket(BUCKET).objects.each do |object|
15 | pool.process do
16 | grants = object.acl.grants
17 | mutex.synchronize do
18 | count += 1
19 | if count % comp == 0
20 | $stdout.write "Objects Scanned : #{count}"
21 | string = " - Press Ctrl + \\ to skip scanning this directory"
22 | puts string
23 | comp = comp * 2
24 |
25 | end
26 | end
27 | if grants.map { |x| x.grantee.uri }.any? { |x| x =~ /AllUsers|AuthenticatedUsers/ }
28 | mutex.synchronize do
29 | puts " ⭕ https://#{BUCKET}.s3.#{region}.amazonaws.com/"+object.key
30 | File.open("tmp.html","a") do |f|
31 | f.puts "
/"+object.key+""
32 | end
33 | end
34 | end
35 | end
36 | end
37 |
38 | pool.shutdown
39 |
--------------------------------------------------------------------------------