您好,登錄后才能下訂單哦!
這篇文章主要介紹s3tk是一款什么安全審計套件,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
s3tk是一款針對Amazon S3的安全審計套件,廣大安全研究人員可以使用s3tk來對Amazon S3 Bucket進行安全測試。
廣大研究人員可以使用pip來完成s3tk的安裝:
pip install s3tk
研究人員可以使用AWS CLI命令行工具來配置AWS憑證:
pip install awscliaws configure
可掃描的Bucket組件如下:
1、公開ACL
2、公開策略
3、屏蔽的公開訪問
4、啟用的登錄
5、版本修改
6、默認加密
s3tk scan
針對特定Bucket運行掃描:
s3tk scan my-bucket my-bucket-2
支持通配符:
s3tk scan "my-bucket*"
跳過日志和默認加密:
s3tk scan --skip-logging --skip-versioning --skip-default-encryption
獲取郵件通知(通過SNS):
s3tk scan --sns-topic arn:aws:sns:...
枚舉Bucket策略:
s3tk list-policy
針對特定Bucket運行掃描:
s3tk list-policy my-bucket my-bucket-2
顯示名稱:
s3tk list-policy --named
設置策略:
s3tk set-policy my-bucket --no-object-acl
刪除策略:
s3tk delete-policy my-bucket
屏蔽公開訪問:
s3tk block-public-access my-bucket my-bucket-2
針對所有Bucket啟用默認加密:
s3tk enable-default-encryption
僅針對特定Bucket啟用:
s3tk enable-default-encryption my-bucket my-bucket-2
掃描目標Bucket中所有對象的ACL:
s3tk scan-object-acl my-bucket
掃描特定對象:
s3tk scan-object-acl my-bucket --only "*.pdf"
排除特定對象:
s3tk scan-object-acl my-bucket --except "*.jpg"
s3tk scan-dns
用戶憑證可以在“~/.aws/credentials”中或環境變量中設置,我們可以使用下列命令設置一個profile:
AWS_PROFILE=your-profile s3tk
下面給出的是每一條命令所需的權限,用戶只需要將相應權限在下列代碼中聲明即可:
{"Version": "2012-10-17","Statement": [ {"Sid": "Scan","Effect": "Allow","Action": ["s3:ListAllMyBuckets","s3:GetBucketAcl","s3:GetBucketPolicy","s3:GetBucketPublicAccessBlock","s3:GetBucketLogging","s3:GetBucketVersioning","s3:GetEncryptionConfiguration"],"Resource": "*"}, {"Sid": "ScanDNS","Effect": "Allow","Action": ["s3:ListAllMyBuckets","route53:ListHostedZones","route53:ListResourceRecordSets"],"Resource": "*"}, {"Sid": "ListPolicy","Effect": "Allow","Action": ["s3:ListAllMyBuckets","s3:GetBucketPolicy"],"Resource": "*"}, {"Sid": "SetPolicy","Effect": "Allow","Action": ["s3:PutBucketPolicy"],"Resource": "*"}, {"Sid": "DeletePolicy","Effect": "Allow","Action": ["s3:DeleteBucketPolicy"],"Resource": "*"}, {"Sid": "BlockPublicAccess","Effect": "Allow","Action": ["s3:ListAllMyBuckets","s3:PutBucketPublicAccessBlock"],"Resource": "*"}, {"Sid": "EnableLogging","Effect": "Allow","Action": ["s3:ListAllMyBuckets","s3:PutBucketLogging"],"Resource": "*"}, {"Sid": "EnableVersioning","Effect": "Allow","Action": ["s3:ListAllMyBuckets","s3:PutBucketVersioning"],"Resource": "*"}, {"Sid": "EnableDefaultEncryption","Effect": "Allow","Action": ["s3:ListAllMyBuckets","s3:PutEncryptionConfiguration"],"Resource": "*"}, {"Sid": "ResetObjectAcl","Effect": "Allow","Action": ["s3:ListBucket","s3:GetObjectAcl","s3:PutObjectAcl"],"Resource": ["arn:aws:s3:::my-bucket","arn:aws:s3:::my-bucket/*"] }, {"Sid": "Encrypt","Effect": "Allow","Action": ["s3:ListBucket","s3:GetObject","s3:PutObject"],"Resource": ["arn:aws:s3:::my-bucket","arn:aws:s3:::my-bucket/*"] }, {"Sid": "DeleteUnencryptedVersions","Effect": "Allow","Action": ["s3:ListBucketVersions","s3:GetObjectVersion","s3:DeleteObjectVersion"],"Resource": ["arn:aws:s3:::my-bucket","arn:aws:s3:::my-bucket/*"] } ] }
Amazon Athena適用于查詢S3日志,創建下列表:
CREATE EXTERNAL TABLE my_bucket ( bucket_owner string, bucket string,time string, remote_ip string, requester string, request_id string, operation string, key string, request_verb string, request_url string, request_proto string, status_code string, error_code string, bytes_sent string, object_size string, total_time string, turn_around_time string, referrer string, user_agent string, version_id string ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'WITH SERDEPROPERTIES ('serialization.format' = '1','input.regex' = '([^ ]*) ([^ ]*) \\[(.*?)\\] ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) \\\"([^ ]*) ([^ ]*) (- |[^ ]*)\\\" (-|[0-9]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) (\"[^\"]*\\") ([^ ]*)$') LOCATION 's3://my-s3-logs/my-bucket/';
修改最后一行代碼,并指向你的日志Bucket:
SELECTdate_parse(time, '%d/%b/%Y:%H:%i:%S +0000') AS time, request_url, remote_ip, user_agentFROMmy_bucketWHERErequester = '-'AND status_code LIKE '2%'AND request_url LIKE '/some-keys%'ORDER BY 1
Amazon Athena同樣可以用于查詢CloudTrail日志,創建一個表:
CREATE EXTERNAL TABLE cloudtrail_logs ( eventversion STRING, userIdentity STRUCT<type:STRING, principalid:STRING, arn:STRING, accountid:STRING, invokedby:STRING, accesskeyid:STRING, userName:String, sessioncontext:STRUCT<attributes:STRUCT<mfaauthenticated:STRING, creationdate:STRING>, sessionIssuer:STRUCT<type:STRING, principalId:STRING, arn:STRING, accountId:STRING, userName:STRING>>>, eventTime STRING, eventSource STRING, eventName STRING, awsRegion STRING, sourceIpAddress STRING, userAgent STRING, errorCode STRING, errorMessage STRING, requestId STRING, eventId STRING, resources ARRAY<STRUCT<ARN:STRING, accountId:STRING, type:STRING>>, eventType STRING, apiVersion STRING, readOnly BOOLEAN, recipientAccountId STRING, sharedEventID STRING, vpcEndpointId STRING, requestParameters STRING, responseElements STRING, additionalEventData STRING, serviceEventDetails STRING ) ROW FORMAT SERDE 'com.amazon.emr.hive.serde.CloudTrailSerde'STORED AS INPUTFORMAT 'com.amazon.emr.cloudtrail.CloudTrailInputFormat'OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'LOCATION 's3://my-cloudtrail-logs/'
修改最后一行代碼,并指向你的CloudTrail日志Bucket:
SELECTeventTime, eventName,userIdentity.userName, requestParametersFROMcloudtrail_logsWHEREeventName LIKE '%Bucket%'ORDER BY 1
{"Version": "2012-10-17","Statement": [ {"Effect": "Deny","Principal": "*","Action": "s3:PutObjectAcl","Resource": "arn:aws:s3:::my-bucket/*"} ] }
運行下列命令:
pip install s3tk --upgrade
使用Master,可運行下列命令:
pip install git+https://github.com/ankane/s3tk.git --upgrade
運行下列命令:
docker run -it ankane/s3tk aws configure
提交你的憑證:
docker commit $(docker ps -l -q) my-s3tk
接下來,運行下列命令:
docker run -it my-s3tk s3tk scan
以上是“s3tk是一款什么安全審計套件”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。