s3 updates

This commit is contained in:
carnal0wnage
2018-05-17 20:10:19 -04:00
parent 7f6ad7a02f
commit 9742a6fb99
2 changed files with 34 additions and 0 deletions

View File

@@ -296,3 +296,29 @@ def s3_upload_file(bucket, source_file, dest_file):
print("Unexpected error: {}" .format(e))
except KeyboardInterrupt:
print("CTRL-C received, exiting...")
def s3_get_file_acl(bucket, file):
'''
get file in a s3 bucket ACL
'''
try:
client = boto3.client('s3', region_name=region)
object_acl = client.get_object_acl(Bucket=bucket, Key=file)
if object_acl:
print("{} ACL:\n".format(file))
print("{}".format(object_acl['Grants']))
except FileNotFoundError as e:
print("[-] {} not found [-]".format(file))
except botocore.exceptions.ClientError as e:
if e.response['Error']['Code'] == "404":
print("{} object does not exist.".format(file))
elif e.response['Error']['Code'] == 'InvalidClientTokenId':
sys.exit("The AWS KEY IS INVALID. Exiting")
elif e.response['Error']['Code'] == 'NotSignedUp':
print('{} : doesnt have s3 access' .format(AWS_ACCESS_KEY_ID))
elif e.response['Error']['Code'] == 'SubscriptionRequiredException':
print('{} : Has permissions but isnt signed up for service - usually means you have a root account' .format(AWS_ACCESS_KEY_ID))
else:
print("Unexpected error: {}" .format(e))
except KeyboardInterrupt:
print("CTRL-C received, exiting...")