s3 updates
This commit is contained in:
26
libs/s3.py
26
libs/s3.py
@@ -296,3 +296,29 @@ def s3_upload_file(bucket, source_file, dest_file):
|
|||||||
print("Unexpected error: {}" .format(e))
|
print("Unexpected error: {}" .format(e))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("CTRL-C received, exiting...")
|
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...")
|
||||||
|
|||||||
@@ -59,3 +59,11 @@ def module_s3_list_buckets_from_file(*args):
|
|||||||
python3 weirdAAL.py -m s3_list_buckets_from_file -a 'bucket_list.txt' -t yolo
|
python3 weirdAAL.py -m s3_list_buckets_from_file -a 'bucket_list.txt' -t yolo
|
||||||
'''
|
'''
|
||||||
s3_get_bucket_objects_from_file(args[0][0])
|
s3_get_bucket_objects_from_file(args[0][0])
|
||||||
|
|
||||||
|
|
||||||
|
def module_s3_get_file_acl(*args):
|
||||||
|
'''
|
||||||
|
S3 get the ACL on a file
|
||||||
|
python3 weirdAAL.py -m s3_get_file_acl -a 'bucket','file' -t yolo
|
||||||
|
'''
|
||||||
|
s3_get_file_acl(args[0][0], args[0][1])
|
||||||
|
|||||||
Reference in New Issue
Block a user