阿里云主机accesskey利用工具
2020-12-24 21:43:20 Author: mp.weixin.qq.com(查看原文) 阅读量:30 收藏

点击上方蓝字关注我哦!

简介(Gamma实验室第二个开源工具)

在日常渗透过程中我们经常遇到信息泄露出ALIYUN_ACCESSKEYIDALIYUN_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 librarypip install aliyun-python-sdk-core # Install the ECS management librarypip install aliyun-python-sdk-ecs # Install the RDS management librarypip install aliyun-python-sdk-rds

调用查询ecs主机

#!/usr/bin/env python#coding=utf-8from aliyunsdkcore.client import AcsClientfrom aliyunsdkcore.acs_exception.exceptions import ClientExceptionfrom aliyunsdkcore.acs_exception.exceptions import ServerExceptionfrom aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequestclient = 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-8from aliyunsdkcore.client import AcsClientfrom aliyunsdkcore.acs_exception.exceptions import ClientExceptionfrom aliyunsdkcore.acs_exception.exceptions import ServerExceptionfrom aliyunsdkecs.request.v20140526.CreateCommandRequest import CreateCommandRequestclient = 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-8from aliyunsdkcore.client import AcsClientfrom aliyunsdkcore.acs_exception.exceptions import ClientExceptionfrom aliyunsdkcore.acs_exception.exceptions import ServerExceptionfrom aliyunsdkecs.request.v20140526.InvokeCommandRequest import InvokeCommandRequestclient = 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.1Host: ecs.aliyuncs.comUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-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.2Accept-Encoding: gzip, deflateContent-Type: application/x-www-form-urlencodedContent-Length: 0Action=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

看完记得点赞,关注哟,爱您!

请严格遵守网络安全法相关条例!此分享主要用于学习,切勿走上违法犯罪的不归路,一切后果自付!

声明

本公众号部分资源来源于网络,版权归原作者或者来源机构所有,如果有涉及任何版权方面的问题,请与及时与我们联系,我们将尽快妥善处理!
谢谢关注↓↓↓

V安全资讯-为网络安全保驾护航


文章来源: http://mp.weixin.qq.com/s?__biz=MzI4MDQ1MzQ0NA==&mid=2247485330&idx=3&sn=ef6e942632cfffdd2ce448c7ce6217a2&chksm=ebb90fb9dcce86af5424a979b1aeee3fac7bfd608ae31c7c7497940fe50bb3254cb2e088a46f&mpshare=1&scene=24&srcid=1224Jmaea8nMD5TzhEikxKea&sharer_sharetime=1608817399850&sharer_shareid=5191b3dcb328f693d5261ba6bca8d267#rd
如有侵权请联系:admin#unsafe.sh