点击上方蓝字关注我哦!
简介(Gamma实验室第二个开源工具)
在日常渗透过程中我们经常遇到信息泄露出ALIYUN_ACCESSKEYID与ALIYUN_ACCESSKEYSECRET(阿里云API key),特别是laravel框架得debug信息。APP中也会泄露这些信息。
!!!下载链接在文末!!!
概述
我们说下阿里API有什么用吧,以下是官方说明:
云服务器(Elastic Compute Service,ECS),可以调用API管理您的云上资源和开发自己的应用程序。
ECS API支持HTTP或者HTTPS网络请求协议,允许GET和POST方法。您可以通过以下方式调用ECS API
详情参考阿里云官方API文档:https://help.aliyun.com/document_detail/25484.html?spm=a2c4g.11186623.6.1276.12244f88jytZ8c
开发思路
1、通过阿里云SDK使用
SDK下载地址:https://github.com/aliyun/aliyun-openapi-python-sdk
pip安装
# Install the core library
pip install aliyun-python-sdk-core
# Install the ECS management library
pip install aliyun-python-sdk-ecs
# Install the RDS management library
pip install aliyun-python-sdk-rds
调用查询ecs主机
#!/usr/bin/env python
#coding=utf-8
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest
client = AcsClient('<accessKeyId>', '<accessSecret>', 'cn-hangzhou')
request = DescribeInstancesRequest()
request.set_accept_format('json')
response = client.do_action_with_exception(request)
# python2: print(response)
print(str(response, encoding='utf-8'))
创建命令
#!/usr/bin/env python
#coding=utf-8
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkecs.request.v20140526.CreateCommandRequest import CreateCommandRequest
client = AcsClient('<accessKeyId>', '<accessSecret>', 'cn-hangzhou')
request = CreateCommandRequest()
request.set_accept_format('json')
response = client.do_action_with_exception(request)
# python2: print(response)
print(str(response, encoding='utf-8'))
这里会返回一个云助手命令id,返回结果:
{
"RequestId": "E69EF3CC-94CD-42E7-8926-F133B86387C0",
"CommandId": "c-7d2a745b412b4601b2d47f6a768d3a14"
}
执行命令
#!/usr/bin/env python
#coding=utf-8
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkecs.request.v20140526.InvokeCommandRequest import InvokeCommandRequest
client = AcsClient('<accessKeyId>', '<accessSecret>', 'cn-hangzhou')
request = InvokeCommandRequest()
request.set_accept_format('json')
response = client.do_action_with_exception(request)
# python2: print(response)
print(str(response, encoding='utf-8'))
返回结果
{
"RequestId": "E69EF3CC-94CD-42E7-8926-F133B86387C0",
"InvokeId": "t-7d2a745b412b4601b2d47f6a768d3a14"
}
安全组部分就省略了,根据API文档
2、通过GET/POST 使用
这里先说下公共请求参数
2.1 GET请求
https://ecs.aliyuncs.com/?Action=DescribeInstanceStatus
&RegionId=cn-hangzhou
&PageSize=1
&PageNumber=1
&InstanceId.1=i-bp1j4i2jdf3owlhe****
&<公共请求参数>
XML返回格式:
<DescribeInstanceStatusResponse>
<PageNumber>1</PageNumber>
<InstanceStatuses>
<InstanceStatus>
<Status>Running</Status>
<InstanceId>i-bp1j4i2jdf3owlhe****</InstanceId>
</InstanceStatus>
</InstanceStatuses>
<TotalCount>58</TotalCount>
<PageSize>1</PageSize>
<RequestId>746C3444-9A24-4D7D-B8A8-DCBF7AC8BD66</RequestId>
</DescribeInstanceStatusResponse>
JSON返回格式
{
"PageNumber": 1,
"InstanceStatuses": {
"InstanceStatus": [
{
"Status": "Running",
"InstanceId": "i-bp1j4i2jdf3owlhe****"
}
]
},
"TotalCount": 58,
"PageSize": 1,
"RequestId": "746C3444-9A24-4D7D-B8A8-DCBF7AC8BD66"
}
2.2 POST请求
POST / HTTP/1.1
Host: ecs.aliyuncs.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
Action=DescribeInstanceStatus&RegionId=cn-hangzhou&PageSize=1&PageNumber=1&InstanceId.1=i-bp1j4i2jdf3owlhe****&<公共请求参数>
返回跟GET方式一样
工具使用
图形化界面,没什么说的。附一张截图相信大家都明白了。
结束
阿里云为运维人员与开发人员提供了方便,但同时自身也要加强安全意识,注意自己的key不要泄露,不然直接接管阿里云所有esc主机,风险比一般高危漏洞都还要高。
下载链接及漏洞文章
项目链接:https://github.com/mrknow001/aliyun-accesskey-Tools
工具下载链接:https://github.com/mrknow001/aliyun-accesskey-Tools/releases/download/1.0/Aliyun-.AK.Tools.exe
欢迎关注Gamma实验室,后续会推出更多实用方便的工具,爱您!
文章链接:https://www.freebuf.com/articles/web/255717.html
END
看完记得点赞,关注哟,爱您!
扫码领hacker资料,常用工具,以及各种福利
本文始发于微信公众号(凌晨安全):阿里云主机accesskey利用工具
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论