| 162 | self.q.task_done() |
| 163 | |
| 164 | def __check_http(self, bucket_url): |
| 165 | check_response = self.session.head( |
| 166 | S3_URL, timeout=3, headers={"Host": bucket_url}) |
| 167 | |
| 168 | if not ARGS.ignore_rate_limiting\ |
| 169 | and (check_response.status_code == 503 and check_response.reason == "Slow Down"): |
| 170 | self.q.rate_limited = True |
| 171 | # add it back to the queue for re-processing |
| 172 | self.q.put(bucket_url) |
| 173 | elif check_response.status_code == 307: # valid bucket, lets check if its public |
| 174 | new_bucket_url = check_response.headers["Location"] |
| 175 | bucket_response = requests.request( |
| 176 | "GET" if ARGS.only_interesting else "HEAD", new_bucket_url, timeout=3) |
| 177 | |
| 178 | if bucket_response.status_code == 200\ |
| 179 | and (not ARGS.only_interesting or |
| 180 | (ARGS.only_interesting and any(keyword in bucket_response.text for keyword in KEYWORDS))): |
| 181 | self.__output("Found bucket '{}'".format(new_bucket_url), "green") |
| 182 | self.__log(new_bucket_url) |
| 183 | |
| 184 | def __check_boto(self, bucket_url): |
| 185 | bucket_name = bucket_url.replace(".s3.amazonaws.com", "") |