本文由 简悦 SimpRead 转码, 原文地址 mp.weixin.qq.com
点击上方蓝字关注我哦!
在日常渗透过程中我们经常遇到信息泄露出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
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.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
看完记得点赞,关注哟,爱您!
请严格遵守网络安全法相关条例!此分享主要用于学习,切勿走上违法犯罪的不归路,一切后果自付!
关注此公众号,回复"Gamma"关键字免费领取一套网络安全视频以及相关书籍,公众号内还有收集的常用工具!
在看你就赞赞我!
扫码关注我们
扫码领hacker资料,常用工具,以及各种福利
转载是一种动力 分享是一种美德
免责声明:本站提供安全工具、程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
转载声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
订阅查看更多复现文章、学习笔记
thelostworld
安全路上,与你并肩前行!!!!
个人知乎:https://www.zhihu.com/people/fu-wei-43-69/columns
个人简书:https://www.jianshu.com/u/bf0e38a8d400
个人CSDN:https://blog.csdn.net/qq_37602797/category_10169006.html
个人博客园:https://www.cnblogs.com/thelostworld/
FREEBUF主页:https://www.freebuf.com/author/thelostworld?type=article
欢迎添加本公众号作者微信交流,添加时备注一下“公众号”