├── PubilcAssetInfo.py ├── README.md ├── Screenshot.png ├── conf └── info.conf ├── lib ├── AliYunDns_doamin.py ├── AliYun_IP.py ├── BaiDu_BCD_domain.py ├── BaiDu_IP.py ├── DNSPod.py ├── Log.py ├── Main.py ├── Nginx_Server_Name.py ├── Tencent_IP.py ├── __init__.py └── tencent_src │ ├── QcloudApi │ ├── __init__.py │ ├── __init__.pyc │ ├── common │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── request.py │ │ ├── request.pyc │ │ ├── sign.py │ │ └── sign.pyc │ ├── modules │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── account.py │ │ ├── base.py │ │ ├── base.pyc │ │ ├── bill.py │ │ ├── bm.py │ │ ├── cbs.py │ │ ├── cdb.py │ │ ├── cdn.py │ │ ├── cmem.py │ │ ├── cvm.py │ │ ├── cvm.pyc │ │ ├── dfw.py │ │ ├── eip.py │ │ ├── eip.pyc │ │ ├── image.py │ │ ├── lb.py │ │ ├── live.py │ │ ├── market.py │ │ ├── monitor.py │ │ ├── redis.py │ │ ├── scaling.py │ │ ├── sec.py │ │ ├── snapshot.py │ │ ├── tdsql.py │ │ ├── trade.py │ │ ├── vod.py │ │ ├── vpc.py │ │ ├── wenzhi.py │ │ └── yunsou.py │ ├── qcloudapi.py │ └── qcloudapi.pyc │ ├── __init__.py │ └── __init__.pyc └── requirements.txt /PubilcAssetInfo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import ConfigParser 3 | from lib.Main import * 4 | 5 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 6 | 7 | # 支持获取如下域名服务 8 | # 1、nginx文件配置解析 9 | # 2、腾讯云 DNSPod域名解析 10 | # 3、阿里云 万网域名解析 11 | # 4、百度云 BCD域名解析 12 | 13 | # 支持公网IP获取服务 14 | # 1、阿里云:支持ECS的专有网络、经典网络两种类型;支持SLB负载均衡服务;支持弹性公网IP服务 15 | # 2、百度云:支持弹性公网IP服务,由于百度api的问题,其中 华东-苏州 地域不支持,等待api更新 16 | # 3、腾讯云:支持弹性公网IP服务、CVM云服务器 17 | 18 | if __name__ == '__main__': 19 | conf_info = {} 20 | conf = ConfigParser.ConfigParser() 21 | conf.read("conf/info.conf") 22 | # read by conf 23 | conf_info['Nginx_file'] = conf.get("Nginx", "Nginx_file").strip() 24 | conf_info['Nginx_dir'] = conf.get("Nginx", "Nginx_dir").strip() 25 | conf_info['AliYun_AccessKeyId'] = conf.get("AliYun", "AliYun_AccessKeyId").strip() 26 | conf_info['AliYun_AccessKeySecret'] = conf.get("AliYun", "AliYun_AccessKeySecret").strip() 27 | conf_info['DNSPod_Login_Token'] = conf.get("DNSPod", "DNSPod_Login_Token").strip() 28 | conf_info['BaiDuYun_AccessKey'] = conf.get("BaiDuYun", "BaiDuYun_AccessKey").strip() 29 | conf_info['BaiDuYun_AccessKeySecret'] = conf.get("BaiDuYun", "BaiDuYun_AccessKeySecret").strip() 30 | conf_info['Baidu_ROOT_Domain_List'] = conf.get("BaiDuYun", "Baidu_ROOT_Domain_List").strip().strip(',').split(',') 31 | conf_info['Tencent_SecretId'] = conf.get("Tencent", "Tencent_SecretId").strip() 32 | conf_info['Tencent_SecretKey'] = conf.get("Tencent", "Tencent_SecretKey").strip() 33 | 34 | conf_info['output'] = conf.get("OPTIONS", "output").strip() 35 | conf_info['filter_domain'] = conf.get("OPTIONS", "filter_domain").strip() 36 | conf_info['type'] = conf.get("OPTIONS", "type").strip() 37 | conf_info['logfile'] = conf.get("OPTIONS", "log").strip() 38 | conf_info['details_info'] = True if conf.get("OPTIONS", "details_info").strip() =='True' else False 39 | 40 | main(conf_info) 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PubilcAssetInfo 0.1 2 | 3 | 这个脚本的主要目标是以甲方安全人员的视角,尽可能收集发现企业的域名和服务器公网IP资产。如百度云、阿里云、腾讯云等。 4 | 5 | ## Author ## 6 | 7 | 咚咚呛 8 | 9 | 如有其他建议,可联系微信280495355 10 | 11 | ## Support ## 12 | 13 | 支持获取如下域名服务 14 | 15 | 1、nginx(openresty、tengine)配置文件解析 16 | 2、腾讯云 DNSPod域名解析 17 | 3、阿里云 万网域名解析 18 | 4、百度云 BCD域名解析 19 | 20 | 支持公网IP获取服务 21 | 22 | 1、阿里云:支持ECS云主机服务;支持SLB负载均衡服务;支持弹性公网IP服务 23 | 2、百度云:支持弹性公网IP服务;(百度大部分服务都是基于弹性公网来对外提供IP) 24 | 3、腾讯云:支持弹性公网IP服务、CVM云服务器 25 | 26 | 27 | ## Dependencies ## 28 | > sudo pip install -r requirements 29 | 30 | ## Tree ## 31 | 32 | PubilcAssetInfo 33 | ----conf #配置目录 34 | ----lib #模块库文件 35 | ----log #日志目录 36 | ----out #输出目录 37 | ----PubilcAssetInfo.py #主程序 38 | 39 | 40 | ## Config ## 41 | 42 | 配置目录:./conf/info.conf 43 | 44 | #以下相关配置信息不填写则不进行检测 45 | 46 | [Nginx] 47 | # Nginx 配置文件如 /opt/nginx/conf/nginx.conf 48 | Nginx_file = 49 | # Nginx 配置目录如 /opt/nginx/conf 50 | Nginx_dir = 51 | 52 | [AliYun] 53 | # AccessKey需开通AliyunDNSReadOnlyAccess、AliyunSLBReadOnlyAccess、AliyunEIPReadOnlyAccess、AliyunDNSReadOnlyAccess权限 54 | AliYun_AccessKeyId = 55 | AliYun_AccessKeySecret = 56 | 57 | [DNSPod] 58 | # DNSPOD的用户login_token 59 | DNSPod_Login_Token = 60 | 61 | [BaiDuYun] 62 | # 需开工单对客服申请域名服务API权限 63 | BaiDuYun_AccessKey = 64 | BaiDuYun_AccessKeySecret = 65 | # 由于百度API/SDK 接口并不支持根域名列表获取,故只能事先填入根域名列表,如 66 | Baidu_ROOT_Domain_List = graygdd.top,grayddq.top 67 | 68 | [Tencent] 69 | Tencent_SecretId = 70 | Tencent_SecretKey = 71 | 72 | [OPTIONS] 73 | #输出文件,默认不填写为当前目录 74 | output = 75 | #过滤域名,默认不填写则不过滤 76 | filter_domain = 77 | #不填则为域名和公网IP,可选 domain/ip 78 | type = 79 | #日志路径,默认本目录/log/process.log 80 | log = 81 | #各环节结果详情 True/False 82 | details_info = 83 | 84 | ## Log ## 85 | 86 | 日志目录默认:./conf/info.conf 87 | 88 | 89 | ## Screenshot ## 90 | 91 | ![Screenshot](Screenshot.png) 92 | 93 | 94 | 95 | ## DNSPod ## 96 | 97 | >DNSPod_Login_Token 是由 ID,Token 组合而成的,用英文的逗号分割 98 | > 99 | >参考:https://support.dnspod.cn/Kb/showarticle/tsid/227/ 100 | 101 | ## Aliyun ## 102 | 103 | >AccessKeyId参考:https://help.aliyun.com/document_detail/60884.html 104 | > 105 | >建议开通AliyunDNSReadOnlyAccess、AliyunSLBReadOnlyAccess、AliyunEIPReadOnlyAccess、AliyunDNSReadOnlyAccess权限 106 | 107 | 108 | ## Baiduyun ## 109 | 110 | >AccessKey参考:https://cloud.baidu.com/doc/Reference/GetAKSK.html 111 | 112 | >需开工单对客服申请域名服务API权限,由于百度API/SDK 接口并不支持跟域名列表获取,故只能事先填入根域名列表 113 | 114 | 115 | ## Tencent ## 116 | 117 | >AccessKey生成:云产品->管理工具->云API密钥 118 | -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/Screenshot.png -------------------------------------------------------------------------------- /conf/info.conf: -------------------------------------------------------------------------------- 1 | [Nginx] 2 | Nginx_file = 3 | Nginx_dir = 4 | 5 | [AliYun] 6 | AliYun_AccessKeyId = 7 | AliYun_AccessKeySecret = 8 | 9 | [DNSPod] 10 | DNSPod_Login_Token = 11 | #DNSPod_Login_Token = 12 | 13 | [BaiDuYun] 14 | BaiDuYun_AccessKey = 15 | BaiDuYun_AccessKeySecret = 16 | Baidu_ROOT_Domain_List = 17 | 18 | [Tencent] 19 | Tencent_SecretId = 20 | Tencent_SecretKey = 21 | 22 | [OPTIONS] 23 | output = 24 | filter_domain = 25 | #不填则为域名和公网IP,可选 domain/ip 26 | type = ip 27 | log = 28 | details_info = -------------------------------------------------------------------------------- /lib/AliYunDns_doamin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from aliyunsdkcore import client 3 | from aliyunsdkcore.request import RpcRequest 4 | import json 5 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 6 | 7 | # 获取阿里域名列表 8 | class AliYunDns_doamin: 9 | def __init__(self, AccessKeyId, AccessKeySecret, filter_domain, Debug=True): 10 | self.domain_list, self.temp_domain_list, self.regex_domain_list = [], [], [] 11 | self.AccessKeyId, self.AccessKeySecret = AccessKeyId, AccessKeySecret 12 | self.filter_domain = '' if not filter_domain else filter_domain 13 | self.Debug = Debug 14 | self.get_domain() 15 | 16 | def get_reslut(self, type, domain=None, PageNumber=1): 17 | try: 18 | clt = client.AcsClient(self.AccessKeyId, self.AccessKeySecret, 'cn-shanghai') 19 | if type == "domain": 20 | request = RpcRequest('Alidns', '2015-01-09', 'DescribeDomains') 21 | request.add_query_param("PageSize", 100) 22 | else: 23 | request = RpcRequest('Alidns', '2015-01-09', 'DescribeDomainRecords') 24 | request.add_query_param("DomainName", domain) 25 | request.add_query_param("PageSize", 500) 26 | request.add_query_param("PageNumber", PageNumber) 27 | request.set_accept_format('json') 28 | json_response = json.loads(clt.do_action_with_exception(request)) 29 | except: 30 | json_response = None 31 | return json_response 32 | 33 | def get_domain(self): 34 | response = self.get_reslut('domain') 35 | if response == None: return 36 | if response['TotalCount'] > 0: 37 | for data in response['Domains']['Domain']: 38 | page = 1 39 | while True: 40 | if page == 10: break 41 | sub_response = self.get_reslut('sub_domain', data['DomainName'], page) 42 | if sub_response == None: continue 43 | if sub_response['TotalCount'] > 0 and len(sub_response['DomainRecords']['Record']) > 0: 44 | for records_data in sub_response['DomainRecords']['Record']: 45 | if records_data['Type'] in ['A', 'CNAME'] and records_data['RR'] != '@' and records_data[ 46 | 'Status'] == 'ENABLE': 47 | if records_data['RR'].replace('.', '').isalnum(): 48 | self.temp_domain_list.append(records_data['RR'] + "." + records_data['DomainName']) 49 | else: 50 | self.regex_domain_list.append(records_data['RR'] + "." + records_data['DomainName']) 51 | else: 52 | break 53 | page += 1 54 | self.domain_list = self.temp_domain_list + self.regex_domain_list 55 | 56 | 57 | def run(self): 58 | if self.Debug: print u"\n阿里云常规DNS解析域名如下:" if len(self.temp_domain_list)>0 else u'阿里云常规DNS解析域名:未发现' 59 | for domain in list(set(self.temp_domain_list)): 60 | if self.Debug: print domain 61 | if self.Debug: print u"\n阿里云DNS解析带有泛解析域名如下:" if len(self.regex_domain_list) > 0 else u'阿里云DNS带有泛解析域名:未发现' 62 | for domain in list(set(self.regex_domain_list)): 63 | if self.Debug: print domain 64 | return self.temp_domain_list, self.regex_domain_list 65 | -------------------------------------------------------------------------------- /lib/AliYun_IP.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from aliyunsdkcore import client 3 | from aliyunsdkecs.request.v20140526 import DescribeEipAddressesRequest 4 | from aliyunsdkecs.request.v20140526 import DescribeRegionsRequest 5 | from aliyunsdkecs.request.v20140526 import DescribeInstancesRequest 6 | from aliyunsdkslb.request.v20140515 import DescribeLoadBalancersRequest 7 | import json 8 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 9 | 10 | class AliYun_IP: 11 | def __init__(self, AccessKeyId, AccessKeySecret, Debug=True): 12 | self.AccessKeyId, self.AccessKeySecret, self.ip_list, self.regions_list = AccessKeyId, AccessKeySecret, [], [] 13 | self.Debug = Debug 14 | self.get_regions() 15 | 16 | def get_ecs_pubilcIP(self, regions_id): 17 | page = 1 18 | errornum = 0 19 | while True: 20 | if errornum == 5: break 21 | try: 22 | clt = client.AcsClient(self.AccessKeyId, self.AccessKeySecret, regions_id) 23 | request = DescribeInstancesRequest.DescribeInstancesRequest() 24 | request.set_accept_format('json') 25 | request.set_PageSize(100) 26 | request.set_PageNumber(page) # 设置页数 27 | json_response = json.loads(clt.do_action_with_exception(request)) 28 | if json_response['TotalCount'] > 0 and len(json_response['Instances']['Instance']) > 0: 29 | for instance in json_response['Instances']['Instance']: 30 | if len(instance['PublicIpAddress']['IpAddress']) > 0: 31 | for IpAddress in instance['PublicIpAddress']['IpAddress']: 32 | self.ip_list.append(IpAddress) 33 | elif len(instance['EipAddress']) > 0: 34 | if instance['EipAddress']['IpAddress']: 35 | self.ip_list.append(instance['EipAddress']['IpAddress']) 36 | else: 37 | break 38 | page += 1 39 | except: 40 | errornum += 1 41 | continue 42 | return 43 | 44 | def get_eip_publicIP(self, regions_id): 45 | page = 1 46 | errornum = 0 47 | while True: 48 | if errornum == 5: break 49 | try: 50 | clt = client.AcsClient(self.AccessKeyId, self.AccessKeySecret, regions_id) 51 | request = DescribeEipAddressesRequest.DescribeEipAddressesRequest() 52 | request.set_accept_format('json') 53 | request.set_PageSize(100) 54 | request.set_PageNumber(page) # 设置页数 55 | json_response = json.loads(clt.do_action_with_exception(request)) 56 | if json_response['TotalCount'] > 0 and len(json_response['EipAddresses']['EipAddress']) > 0: 57 | for eipaddress in json_response['EipAddresses']['EipAddress']: 58 | if eipaddress['IpAddress']: 59 | self.ip_list.append(eipaddress['IpAddress']) 60 | else: 61 | break 62 | page += 1 63 | except: 64 | errornum += 1 65 | continue 66 | 67 | def get_slb_publicIP(self, regions_id): 68 | page = 1 69 | errornum = 0 70 | while True: 71 | if errornum == 5: break 72 | try: 73 | clt = client.AcsClient(self.AccessKeyId, self.AccessKeySecret, regions_id) 74 | request = DescribeLoadBalancersRequest.DescribeLoadBalancersRequest() 75 | request.set_accept_format('json') 76 | request.set_PageSize(100) 77 | request.set_PageNumber(page) # 设置页数 78 | request.add_query_param('RegionId', regions_id) 79 | json_response = json.loads(clt.do_action_with_exception(request)) 80 | if json_response['TotalCount'] > 0 and len(json_response['LoadBalancers']['LoadBalancer']) > 0: 81 | for LoadBalancer in json_response['LoadBalancers']['LoadBalancer']: 82 | if LoadBalancer['Address']: 83 | self.ip_list.append(LoadBalancer['Address']) 84 | else: 85 | break 86 | page += 1 87 | except: 88 | errornum += 1 89 | continue 90 | 91 | # 得到地域信息 92 | def get_regions(self): 93 | clt = client.AcsClient(self.AccessKeyId, self.AccessKeySecret, 'cn-hangzhou') 94 | request = DescribeRegionsRequest.DescribeRegionsRequest() 95 | request.set_accept_format('json') 96 | json_response = json.loads(clt.do_action_with_exception(request)) 97 | for regions in json_response['Regions']['Region']: 98 | self.regions_list.append(regions['RegionId']) 99 | return self.regions_list 100 | 101 | def run(self): 102 | for regions_id in self.regions_list: 103 | self.get_ecs_pubilcIP(regions_id) 104 | self.get_eip_publicIP(regions_id) 105 | self.get_slb_publicIP(regions_id) 106 | 107 | if self.Debug: print u"\n阿里云公网IP如下:" if len(self.ip_list) > 0 else u'阿里云公网IP:未发现' 108 | for ip in list(set(self.ip_list)): 109 | if self.Debug: print ip 110 | return list(set(self.ip_list)) 111 | -------------------------------------------------------------------------------- /lib/BaiDu_BCD_domain.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import urllib, json, hmac, hashlib, urllib2 3 | from datetime import datetime 4 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 5 | 6 | # 百度域名获取 7 | class BaiDu_BCD_domain: 8 | def __init__(self, AccessKeyId, AccessKeySecret, root_domain_list, filter_domain=None, Debug=True): 9 | self.domain_list, self.temp_domain_list, self.regex_domain_list = [], [], [] 10 | self.AccessKeyId, self.AccessKeySecret, self.root_domain_list = AccessKeyId, AccessKeySecret, root_domain_list 11 | self.Debug = Debug 12 | self.filter_domain = '' if not filter_domain else filter_domain 13 | 14 | def digest(self, key, msg): 15 | """消息摘要算法(加盐)""" 16 | digester = hmac.new(key, msg, hashlib.sha256) 17 | HMAC_SHA256 = digester.hexdigest() 18 | return HMAC_SHA256 19 | 20 | def querystring_be_canonical(self, string): 21 | """ 22 | test case 23 | string = 'text&text1=测试&text10=test' 24 | string = '' 25 | """ 26 | if string != '': 27 | lst = string.split('&') 28 | string_lst = [] 29 | for i in lst: 30 | 31 | if '=' in i: 32 | string_lst.append(urllib.quote(i, safe='=')) 33 | else: 34 | string_lst.append(urllib.quote(i, safe='') + '=') 35 | 36 | string_lst.sort() 37 | qs_canonical = '&'.join(string_lst) 38 | else: 39 | qs_canonical = '' 40 | 41 | return qs_canonical 42 | 43 | def headers_be_canonical(self, headers): 44 | keys = [] 45 | items = [] 46 | 47 | for k, v in headers.items(): 48 | keys.append(k.lower()) 49 | 50 | item = "{}:{}".format(urllib.quote(k.lower(), safe=''), urllib.quote(v.strip(), safe='')) 51 | items.append(item) 52 | 53 | # "注意相关举例2: CanonicalHeaders的排序和signedHeaders排序不一致。" 54 | keys.sort() 55 | keys = ';'.join(keys) 56 | 57 | items.sort() 58 | headers_plain = '\n'.join(items) 59 | 60 | return keys, headers_plain 61 | 62 | def get_headers_with_auth(self, conf, payload, querystring): 63 | contentLength = str(len(payload)) 64 | time_bce = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') 65 | 66 | # 自行评估哪些header会出现在提交的请求内,继而在此对这些headers进行声明 67 | req_headers = {'Host': conf['host'], 68 | 'Content-Type': conf['contentType'], 69 | 'Content-Length': contentLength, 70 | 'x-bce-date': time_bce 71 | } 72 | 73 | # 获取已编码并扁平化的Headers字串 74 | headers_signed, headers_canonical = self.headers_be_canonical(req_headers) 75 | 76 | # 对请求的资源路径编码 77 | uri_canonical = urllib.quote(conf['path'], safe='/') 78 | 79 | # 对请求携带的查询参数编码 80 | querystring_canonical = self.querystring_be_canonical(querystring) 81 | 82 | # 构造合规化请求字串 83 | request_canonical = '\n'.join([conf['method'].upper(), uri_canonical, querystring_canonical, headers_canonical]) 84 | 85 | # 认证字串前缀 86 | authStringPrefix = conf['auth_version'] + '/' + conf['ak'] + '/' + time_bce + '/' + '1800' 87 | 88 | # 摘要算法需用到的key 89 | signing_key = self.digest(conf['sk'], authStringPrefix) 90 | 91 | # 摘要 92 | signature = self.digest(signing_key, request_canonical) 93 | 94 | # 构造认证字串(显式声明已参与签名的所有header,而非采用由百度定义的缺省方式) 95 | authorization = authStringPrefix + '/' + headers_signed + '/' + signature 96 | 97 | # 为原始请求headers附加认证字串header 98 | req_headers['Authorization'] = authorization 99 | 100 | return req_headers 101 | 102 | def get_sub_reslut(self, root_domain, pageNo=1, pageSize=100): 103 | conf = {'ak': self.AccessKeyId, 104 | 'sk': self.AccessKeySecret, 105 | 'host': 'bcd.baidubce.com', 106 | 'protocol': 'http', 107 | 'method': 'post', 108 | 'path': '/v1/domain/resolve/list', 109 | 'auth_version': 'bce-auth-v1', 110 | 'contentType': 'application/json' 111 | } 112 | domain = { 113 | 'domain': '%s' % root_domain, 114 | 'pageNo': pageNo, 115 | 'pageSize': pageSize 116 | } 117 | payload = json.dumps(domain) 118 | querystring = '' 119 | token_obj = self.get_headers_with_auth(conf, payload, querystring) 120 | 121 | url = "http://bcd.baidubce.com/v1/domain/resolve/list" 122 | send_headers = { 123 | 'Host': 'bcd.baidubce.com', 124 | 'x-bce-date': '%s' % token_obj['x-bce-date'], 125 | 'Authorization': '%s' % token_obj['Authorization'], 126 | 'Content-Type': 'application/json' 127 | } 128 | try: 129 | request = urllib2.Request(url, data=payload, headers=send_headers) 130 | json_response = json.loads(urllib2.urlopen(request).read()) 131 | except: 132 | json_response = None 133 | return json_response 134 | 135 | def get_sub_domain(self, domain): 136 | page = 1 137 | while True: 138 | if page == 10: break 139 | json_response = self.get_sub_reslut(domain, page, 100) 140 | if json_response == None: return 141 | if json_response['totalCount'] > 0 and len(json_response['result']) > 0: 142 | for data in json_response['result']: 143 | if data['rdtype'] in ['A', 'CNAME'] and data['domain'] != '@' and data['status'] == 'RUNNING': 144 | if data['domain'].replace('.', '').isalnum(): 145 | self.temp_domain_list.append(data['domain'] + '.' + data['zoneName']) 146 | else: 147 | self.regex_domain_list.append(data['domain'] + '.' + data['zoneName']) 148 | else: 149 | break 150 | page += 1 151 | 152 | def run(self): 153 | for domain in self.root_domain_list: 154 | self.get_sub_domain(domain) 155 | self.domain_list = self.temp_domain_list + self.regex_domain_list 156 | 157 | if self.Debug: print u"\n百度云常规DNS解析域名如下:" if len(self.temp_domain_list) > 0 else u'百度云常规DNS解析域名:未发现' 158 | for domain in list(set(self.temp_domain_list)): 159 | if self.Debug: print domain 160 | if self.Debug: print u"\n百度云DNS带有泛解析域名如下:" if len(self.regex_domain_list) > 0 else u'百度云DNS带有泛解析域名:未发现' 161 | for domain in list(set(self.regex_domain_list)): 162 | if self.Debug: print domain 163 | 164 | return self.temp_domain_list, self.regex_domain_list 165 | -------------------------------------------------------------------------------- /lib/BaiDu_IP.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import urllib, json, hmac, hashlib, urllib2 3 | from datetime import datetime 4 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 5 | 6 | # 百度域名获取 7 | class BaiDu_IP: 8 | def __init__(self, AccessKeyId, AccessKeySecret, Debug=True): 9 | self.AccessKeyId, self.AccessKeySecret, self.ip_list = AccessKeyId, AccessKeySecret, [] 10 | # 弹性公网IP暂时支持两个两个区域:华南-广州、华北-北京 11 | self.Region_list = ['eip.bj.baidubce.com', 'eip.gz.baidubce.com'] 12 | self.Debug = Debug 13 | 14 | def digest(self, key, msg): 15 | """消息摘要算法(加盐)""" 16 | digester = hmac.new(key, msg, hashlib.sha256) 17 | HMAC_SHA256 = digester.hexdigest() 18 | return HMAC_SHA256 19 | 20 | def querystring_be_canonical(self, string): 21 | """ 22 | test case 23 | string = 'text&text1=测试&text10=test' 24 | string = '' 25 | """ 26 | if string != '': 27 | lst = string.split('&') 28 | string_lst = [] 29 | for i in lst: 30 | 31 | if '=' in i: 32 | string_lst.append(urllib.quote(i, safe='=')) 33 | else: 34 | string_lst.append(urllib.quote(i, safe='') + '=') 35 | 36 | string_lst.sort() 37 | qs_canonical = '&'.join(string_lst) 38 | else: 39 | qs_canonical = '' 40 | 41 | return qs_canonical 42 | 43 | def headers_be_canonical(self, headers): 44 | keys = [] 45 | items = [] 46 | 47 | for k, v in headers.items(): 48 | keys.append(k.lower()) 49 | 50 | item = "{}:{}".format(urllib.quote(k.lower(), safe=''), urllib.quote(v.strip(), safe='')) 51 | items.append(item) 52 | 53 | # "注意相关举例2: CanonicalHeaders的排序和signedHeaders排序不一致。" 54 | keys.sort() 55 | keys = ';'.join(keys) 56 | 57 | items.sort() 58 | headers_plain = '\n'.join(items) 59 | 60 | return keys, headers_plain 61 | 62 | def get_headers_with_auth(self, conf, payload, querystring): 63 | time_bce = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') 64 | 65 | # 自行评估哪些header会出现在提交的请求内,继而在此对这些headers进行声明 66 | req_headers = {'Host': conf['host'], 67 | 'Content-Type': conf['contentType'], 68 | 'x-bce-date': time_bce 69 | } 70 | 71 | # 获取已编码并扁平化的Headers字串 72 | headers_signed, headers_canonical = self.headers_be_canonical(req_headers) 73 | 74 | # 对请求的资源路径编码 75 | uri_canonical = urllib.quote(conf['path'], safe='/') 76 | 77 | # 对请求携带的查询参数编码 78 | querystring_canonical = self.querystring_be_canonical(querystring) 79 | 80 | # 构造合规化请求字串 81 | request_canonical = '\n'.join([conf['method'].upper(), uri_canonical, querystring_canonical, headers_canonical]) 82 | 83 | # 认证字串前缀 84 | authStringPrefix = conf['auth_version'] + '/' + conf['ak'] + '/' + time_bce + '/' + '1800' 85 | 86 | # 摘要算法需用到的key 87 | signing_key = self.digest(conf['sk'], authStringPrefix) 88 | 89 | # 摘要 90 | signature = self.digest(signing_key, request_canonical) 91 | 92 | # 构造认证字串(显式声明已参与签名的所有header,而非采用由百度定义的缺省方式) 93 | authorization = authStringPrefix + '/' + headers_signed + '/' + signature 94 | 95 | # 为原始请求headers附加认证字串header 96 | req_headers['Authorization'] = authorization 97 | 98 | return req_headers 99 | 100 | def get_reslut(self, host, marker=''): 101 | conf = {'ak': self.AccessKeyId, 102 | 'sk': self.AccessKeySecret, 103 | 'host': '%s' % host, 104 | 'protocol': 'http', 105 | 'method': 'get', 106 | 'path': '/v1/eip', 107 | 'auth_version': 'bce-auth-v1', 108 | 'contentType': 'application/json' 109 | } 110 | body_post = {} 111 | payload = json.dumps(body_post) 112 | querystring = 'maxKeys=1' if not marker else 'marker=%s&maxKeys=1' % marker 113 | token_obj = self.get_headers_with_auth(conf, payload, querystring) 114 | 115 | url = "http://%s/v1/eip?maxKeys=1" % host if not marker else "http://%s/v1/eip?marker=%s&maxKeys=1" % ( 116 | host, marker) 117 | send_headers = { 118 | 'Host': '%s' % host, 119 | 'x-bce-date': '%s' % token_obj['x-bce-date'], 120 | 'Authorization': '%s' % token_obj['Authorization'], 121 | 'Content-Type': 'application/json' 122 | } 123 | try: 124 | request = urllib2.Request(url, headers=send_headers) 125 | json_response = json.loads(urllib2.urlopen(request).read()) 126 | except: 127 | json_response = None 128 | return json_response 129 | 130 | def get_ip(self): 131 | for Region in self.Region_list: 132 | marker, errornum = '', 0 133 | while True: 134 | if errornum == 5: break 135 | json_response = self.get_reslut(Region, marker) 136 | if json_response: 137 | if len(json_response['eipList']) > 0: 138 | for eipList in json_response['eipList']: 139 | self.ip_list.append(eipList['eip']) 140 | if json_response['isTruncated']: 141 | marker = json_response['nextMarke'] 142 | else: 143 | break 144 | else: 145 | errornum += 1 146 | 147 | def run(self): 148 | self.get_ip() 149 | if self.Debug: print u"\n百度云公网IP如下:" if len(self.ip_list) > 0 else u'百度云公网IP:未发现' 150 | for ip in list(set(self.ip_list)): 151 | if self.Debug: print ip 152 | return self.ip_list 153 | -------------------------------------------------------------------------------- /lib/DNSPod.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import json, urllib2 3 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 4 | 5 | # 获取DNSPOD的域名列表 6 | # 只要A记录和CNAME 如需要其他的请修改代码['A','CANME'] 7 | class DNSPod_domain: 8 | def __init__(self, login_token, filter_domain, Debug=True): 9 | self.domain_list, self.login_token, self.temp_domain_list, self.regex_domain_list = [], login_token, [], [] 10 | self.filter_domain = '' if not filter_domain else filter_domain 11 | self.Debug = Debug 12 | self.get_domain() 13 | 14 | def get_reslut(self, type, domain_id=None): 15 | try: 16 | body_data = 'login_token=' + self.login_token + '&format=json' 17 | if domain_id: body_data += "&domain_id=" + str(domain_id) 18 | url = "https://dnsapi.cn/Domain.List" if type == "domain" else "https://dnsapi.cn/Record.List" 19 | request = urllib2.Request(url, body_data) 20 | json_response = json.loads(urllib2.urlopen(request).read()) 21 | except: 22 | json_response = None 23 | return json_response 24 | 25 | def get_domain(self): 26 | response = self.get_reslut('domain') 27 | if response == None: return 28 | if response['status']['code'] == '1': 29 | for data in response['domains']: 30 | if data['status'] == 'enable': 31 | sub_response = self.get_reslut('sub_domain', data['id']) 32 | if sub_response == None: continue 33 | if sub_response['status']['code'] == '1': 34 | for records_data in sub_response['records']: 35 | if records_data['type'] in ['A', 'CNAME'] and records_data['name'] != '@': 36 | if records_data['name'].replace('.', '').isalnum(): 37 | self.temp_domain_list.append(records_data['name'] + "." + data['name']) 38 | else: 39 | self.regex_domain_list.append(records_data['name'] + "." + data['name']) 40 | 41 | self.domain_list = self.temp_domain_list + self.regex_domain_list 42 | 43 | if self.Debug: print u"\nDNSPOD域名如下:" if len(self.temp_domain_list) > 0 else u'DNSPod常规DNS解析域名:未发现' 44 | for domain in list(set(self.temp_domain_list)): 45 | if self.Debug: print domain 46 | if self.Debug: print u"\nDNSPOD带有泛解析域名如下:" if len(self.regex_domain_list)>0 else u'DNSPod带有泛解析域名:未发现' 47 | for domain in list(set(self.regex_domain_list)): 48 | if self.Debug: print domain 49 | 50 | def run(self): 51 | return self.temp_domain_list, self.regex_domain_list 52 | -------------------------------------------------------------------------------- /lib/Log.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import logging 3 | import logging.handlers 4 | 5 | 6 | class LogInfo: 7 | def __init__(self, logfile): 8 | self.log_file = logfile 9 | logging.basicConfig( 10 | level=logging.INFO, 11 | format='%(asctime)s - %(name)s - %(message)s' 12 | ) 13 | self.logger = logging.getLogger('LogInfo') 14 | fh = logging.FileHandler(self.log_file) 15 | fh.setLevel(logging.INFO) 16 | formatter = logging.Formatter('%(asctime)s - %(name)s - %(message)s') 17 | fh.setFormatter(formatter) 18 | self.logger.addHandler(fh) 19 | 20 | def infostring(self, infostring): 21 | self.logger.info(infostring) 22 | -------------------------------------------------------------------------------- /lib/Main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import datetime, os 3 | from AliYunDns_doamin import * 4 | from DNSPod import * 5 | from Nginx_Server_Name import * 6 | from BaiDu_BCD_domain import * 7 | from AliYun_IP import * 8 | from BaiDu_IP import * 9 | from Tencent_IP import * 10 | from Log import * 11 | 12 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 13 | 14 | 15 | def main(conf_info): 16 | domain_list, temp_domain_list, regex_domain_list, ip_list = [], [], [], [] 17 | if not os.path.exists('out'): 18 | os.mkdir('out') 19 | if not os.path.exists('log'): 20 | os.mkdir('log') 21 | 22 | outfile = 'out/' + str(datetime.now().strftime('%Y-%m-%d_%H_%M_%S')) + 'info.txt' if not conf_info[ 23 | 'output'] else conf_info['output'] 24 | logger = LogInfo('%s' % conf_info['logfile'] if conf_info['logfile'] else 'log/process.log') 25 | logger.infostring('read conf success') 26 | if not conf_info['type'] or conf_info['type'] == 'domain': 27 | if conf_info['Nginx_file'] or conf_info['Nginx_dir']: 28 | logger.infostring( 29 | 'start analysis nginx file/dir: %s...' % conf_info['Nginx_file'] if conf_info['Nginx_file'] else 30 | conf_info[ 31 | 'Nginx_dir']) 32 | temp_nginx_domain, temp_nginx_regex = Nginx_Server_Name(conf_info['Nginx_dir'], 33 | conf_info['filter_domain'], 34 | Debug=conf_info['details_info'] 35 | ).run() if conf_info[ 36 | 'Nginx_dir'] else Nginx_Server_Name(conf_info['Nginx_file'], 37 | conf_info['filter_domain'], 38 | Debug=conf_info['details_info'] 39 | ).run() 40 | temp_domain_list += temp_nginx_domain 41 | regex_domain_list += temp_nginx_regex 42 | logger.infostring( 43 | 'finsh nginx dns parsing,find conventional domain num: %d, regular expression domain num: %d' % ( 44 | len(temp_nginx_domain), len(temp_nginx_regex))) 45 | 46 | if conf_info['DNSPod_Login_Token']: 47 | logger.infostring('start analysis dnspod dns parsing...') 48 | temp_dnspod_domain, temp_dnspod_regex = DNSPod_domain(conf_info['DNSPod_Login_Token'], 49 | conf_info['filter_domain'], 50 | Debug=conf_info['details_info'] 51 | ).run() 52 | temp_domain_list += temp_dnspod_domain 53 | regex_domain_list += temp_dnspod_regex 54 | logger.infostring( 55 | 'finsh dnspod dns parsing,find conventional domain num: %d, regular expression domain num: %d' % ( 56 | len(temp_dnspod_domain), len(temp_dnspod_regex))) 57 | 58 | if conf_info['AliYun_AccessKeySecret']: 59 | logger.infostring('start analysis ali cloud dns parsing...') 60 | temp_aliyun_domain, temp_aliyun_regex = AliYunDns_doamin(conf_info['AliYun_AccessKeyId'], 61 | conf_info['AliYun_AccessKeySecret'], 62 | conf_info['filter_domain'], 63 | Debug=conf_info['details_info'] 64 | ).run() 65 | temp_domain_list += temp_aliyun_domain 66 | regex_domain_list += temp_aliyun_regex 67 | logger.infostring( 68 | 'finsh dnspod dns parsing,conventional domain num: %d, regular expression domain num: %d' % ( 69 | len(temp_aliyun_domain), len(temp_aliyun_regex))) 70 | 71 | if conf_info['BaiDuYun_AccessKey']: 72 | logger.infostring('start analysis baidu cloud dns parsing...') 73 | temp_baiduyun_domain, temp_baiduyun_regex = BaiDu_BCD_domain(conf_info['BaiDuYun_AccessKey'], 74 | conf_info['BaiDuYun_AccessKeySecret'], 75 | conf_info['Baidu_ROOT_Domain_List'], 76 | conf_info['filter_domain'], 77 | Debug=conf_info['details_info'] 78 | ).run() 79 | temp_domain_list += temp_baiduyun_domain 80 | regex_domain_list += temp_baiduyun_regex 81 | logger.infostring( 82 | 'finsh baidu dns parsing,conventional domain num: %d, regular expression domain num: %d' % ( 83 | len(temp_baiduyun_domain), len(temp_baiduyun_regex))) 84 | if not conf_info['type'] or conf_info['type'] == 'ip': 85 | if conf_info['AliYun_AccessKeySecret']: 86 | logger.infostring('start analysis ali cloud public ip...') 87 | temp_ip_list = AliYun_IP(conf_info['AliYun_AccessKeyId'], 88 | conf_info['AliYun_AccessKeySecret'], 89 | Debug=conf_info['details_info'] 90 | ).run() 91 | ip_list += temp_ip_list 92 | logger.infostring('finsh ali public ip,num: %d' % (len(temp_ip_list))) 93 | 94 | if conf_info['BaiDuYun_AccessKeySecret']: 95 | logger.infostring('start analysis baidu cloud public ip...') 96 | temp_ip_list = BaiDu_IP(conf_info['BaiDuYun_AccessKey'], 97 | conf_info['BaiDuYun_AccessKeySecret'], 98 | Debug=conf_info['details_info'] 99 | ).run() 100 | ip_list += temp_ip_list 101 | logger.infostring('finsh baidu public ip,num: %d' % (len(temp_ip_list))) 102 | 103 | if conf_info['Tencent_SecretKey']: 104 | logger.infostring('start analysis tencent cloud public ip...') 105 | temp_ip_list = Tencent_IP(conf_info['Tencent_SecretId'], 106 | conf_info['Tencent_SecretKey'], 107 | Debug=conf_info['details_info'] 108 | ).run() 109 | ip_list += temp_ip_list 110 | logger.infostring('finsh tencent public ip,num: %d' % (len(temp_ip_list))) 111 | 112 | out = open(outfile, 'w') 113 | if conf_info['type'] != 'ip': out.write("完整域名如下\n") 114 | for domain in list(set(temp_domain_list)): 115 | out.write(domain + "\n") 116 | if conf_info['type'] != 'ip': out.write("\n带有正则或者通配符域名如下\n") 117 | for domain in list(set(regex_domain_list)): 118 | out.write(domain + "\n") 119 | if conf_info['type'] != 'ip': out.write("\nIP信息如下\n") 120 | for ip in list(set(ip_list)): 121 | out.write(ip + "\n") 122 | out.close() 123 | logger.infostring('Finsh current task, Domain: %d, IP: %d, results path: %s' % ( 124 | len(list(set(temp_domain_list)) + list(set(regex_domain_list))), len(ip_list), outfile)) 125 | -------------------------------------------------------------------------------- /lib/Nginx_Server_Name.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import re, os 3 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 4 | 5 | class Nginx_Server_Name: 6 | def __init__(self, target, filter_domain, Debug=True): 7 | self.target, self.conf_list, self.domain_list, self.temp_domain_list, self.regex_domain_list = target, [], [], [], [] 8 | self.filter_domain = '' if not filter_domain else filter_domain 9 | self.Debug = Debug 10 | 11 | def run(self): 12 | self.get_conf_list() 13 | return self.temp_domain_list, self.regex_domain_list 14 | 15 | def get_conf_list(self): 16 | if not os.path.exists(self.target): return 17 | if os.path.isfile(self.target): 18 | self.conf_list.append(self.target) 19 | else: 20 | for path, d, filelist in os.walk(self.target): 21 | for filename in filelist: 22 | if os.path.splitext(filename)[1] == '.conf': self.conf_list.append(os.path.join(path, filename)) 23 | for file in self.conf_list: 24 | server_list, re_list = self.get_domain(file, self.filter_domain) 25 | self.temp_domain_list += server_list 26 | self.regex_domain_list += re_list 27 | self.domain_list = list(set(self.temp_domain_list)) + list(set(self.regex_domain_list)) 28 | 29 | if self.Debug: 30 | print u"\nNginx非正则域名如下:" if len(self.temp_domain_list) > 0 else u'Nginx非正则域名:未发现' 31 | for domain in list(set(self.temp_domain_list)): 32 | if self.Debug: print domain 33 | if self.Debug: 34 | print u"\nNginx正则或通配符域名如下:" if len(self.regex_domain_list) > 0 else u'Nginx正则或通配符域名:未发现' 35 | for domain in list(set(self.regex_domain_list)): 36 | if self.Debug: print domain 37 | 38 | # 获取指定conf文件的server_name 39 | # file 文件绝对路径 40 | # 输出两个list 41 | # server_list:绝对域名列表 42 | # re_list:带有正则或者通配符的域名 43 | def get_domain(self, file, filter_domain): 44 | server_list, re_list = [], [] # 域名 45 | f = open(file, 'rb') 46 | try: 47 | for line in f: 48 | if re.compile('server_name').search(line.strip()): 49 | l = ' '.join(line.strip().split()) # 去掉多余空格和tab 50 | if not l.replace(' ', '').lower().startswith('server_name'): continue 51 | domain_list = re.split(' +|;', l) 52 | for domain in domain_list: 53 | if not domain.lower() in ['', 'localhost', 'server_name']: 54 | # nginx 配置中如果server_name需要填写正则,则第一个字符必然为 ~ 55 | # 存在带有~^xxxx.xxx.com这样写域名的写法,匹配除了~ ^ .其他特殊符都为正则匹配 56 | if domain.replace('~', '').replace('^', '').replace('.', '').isalnum(): 57 | if filter_domain in domain: server_list.append(domain.replace('~', '').replace('^', '')) 58 | else: 59 | if filter_domain in domain: re_list.append(domain) 60 | f.close() 61 | except: 62 | f.close() 63 | return server_list, re_list 64 | -------------------------------------------------------------------------------- /lib/Tencent_IP.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from tencent_src.QcloudApi.qcloudapi import QcloudApi 3 | import json 4 | NAME, VERSION, AUTHOR, LICENSE = "Assets Info", "V0.1", "咚咚呛", "Public (FREE)" # 版本信息 5 | 6 | class Tencent_IP: 7 | def __init__(self, AccessKeyId, AccessKeySecret, Debug=True): 8 | self.AccessKeyId, self.AccessKeySecret, self.ip_list, self.Region_list = AccessKeyId, AccessKeySecret, [], [] 9 | self.Debug = Debug 10 | self.get_region_list() 11 | 12 | def get_region_list(self): 13 | config = { 14 | 'Region': 'ap-beijing', 15 | 'secretId': self.AccessKeyId, 16 | 'secretKey': self.AccessKeySecret, 17 | 'method': 'get' 18 | } 19 | service = QcloudApi('cvm', config) 20 | service.generateUrl('DescribeRegions', {}) 21 | json_response = json.loads(service.call('DescribeRegions', {})) 22 | for region in json_response['regionSet']: 23 | self.Region_list.append(region['region']) 24 | 25 | def get_eip(self, Region, limit=100): 26 | offset, errornum = 0, 0 27 | while True: 28 | if errornum == 5: break 29 | try: 30 | config = { 31 | 'Region': Region, 32 | 'secretId': self.AccessKeyId, 33 | 'secretKey': self.AccessKeySecret, 34 | 'method': 'get' 35 | } 36 | service = QcloudApi('eip', config) 37 | service.generateUrl('DescribeEip', {'limit': limit, 'offset': offset}) 38 | json_response = json.loads(service.call('DescribeEip', {'limit': limit, 'offset': offset})) 39 | if json_response['codeDesc'] == 'Success': 40 | if json_response['totalCount'] > 0 and len(json_response['data']['eipSet']) > 0: 41 | for eipSet in json_response['data']['eipSet']: 42 | if eipSet['eip']: self.ip_list.append(eipSet['eip']) 43 | if len(json_response['data']['eipSet']) == limit: 44 | offset += limit 45 | continue 46 | break 47 | except: 48 | errornum += 1 49 | continue 50 | 51 | def get_cvm(self, Region, limit=100): 52 | offset, errornum = 0, 0 53 | while True: 54 | if errornum == 5: break 55 | try: 56 | config = { 57 | 'Region': Region, 58 | 'secretId': self.AccessKeyId, 59 | 'secretKey': self.AccessKeySecret, 60 | 'method': 'get' 61 | } 62 | service = QcloudApi('cvm', config) 63 | service.generateUrl('DescribeInstances', {'limit': limit, 'offset': offset}) 64 | json_response = json.loads(service.call('DescribeInstances', {'limit': limit, 'offset': offset})) 65 | if json_response['codeDesc'] == 'Success': 66 | if json_response['totalCount'] > 0 and len(json_response['instanceSet']) > 0: 67 | for instanceSet in json_response['instanceSet']: 68 | for wanIpSet in instanceSet['wanIpSet']: 69 | self.ip_list.append(wanIpSet) 70 | if len(json_response['instanceSet']) == limit: 71 | offset += limit 72 | continue 73 | break 74 | except: 75 | errornum += 1 76 | continue 77 | 78 | def run(self): 79 | for Region in self.Region_list: 80 | self.get_eip(Region) 81 | self.get_cvm(Region) 82 | 83 | if self.Debug: print u"\n腾讯云公网IP如下:" if len(self.ip_list) > 0 else u'腾讯云公网IP:未发现' 84 | for ip in list(set(self.ip_list)): 85 | if self.Debug: print ip 86 | 87 | return list(set(self.ip_list)) 88 | -------------------------------------------------------------------------------- /lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/__init__.py -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/__init__.py -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/__init__.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/common/__init__.py -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/common/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/common/__init__.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/common/request.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | import urllib 5 | import requests 6 | from sign import Sign 7 | 8 | class Request: 9 | timeout = 10 10 | version = 'SDK_PYTHON_1.1' 11 | def __init__(self, secretId, secretKey): 12 | self.secretId = secretId 13 | self.secretKey = secretKey 14 | 15 | def generateUrl(self, requestHost, requestUri, params, method = 'GET'): 16 | params['RequestClient'] = Request.version 17 | sign = Sign(self.secretId, self.secretKey) 18 | params['Signature'] = sign.make(requestHost, requestUri, params, method) 19 | params = urllib.urlencode(params) 20 | 21 | url = 'https://%s%s' % (requestHost, requestUri) 22 | if (method.upper() == 'GET'): 23 | url += '?' + params 24 | 25 | return url 26 | 27 | def send(self, requestHost, requestUri, params, files = {}, method = 'GET', debug = 0): 28 | params['RequestClient'] = Request.version 29 | sign = Sign(self.secretId, self.secretKey) 30 | params['Signature'] = sign.make(requestHost, requestUri, params, method) 31 | 32 | url = 'https://%s%s' % (requestHost, requestUri) 33 | 34 | if (method.upper() == 'GET'): 35 | req = requests.get(url, params=params, timeout=Request.timeout, verify=False) 36 | if (debug): 37 | print 'url:', req.url, '\n' 38 | else: 39 | req = requests.post(url, data=params, files=files, timeout=Request.timeout, verify=False) 40 | if (debug): 41 | print 'url:', req.url, '\n' 42 | 43 | if req.status_code != requests.codes.ok: 44 | req.raise_for_status() 45 | 46 | return req.text 47 | 48 | def main(): 49 | secretId = 123 50 | secretKey = 'test' 51 | params = {} 52 | request = Request(secretId, secretKey) 53 | print request.generateUrl('cvm.api.qcloud.com', '/v2/index.php', params) 54 | print request.send('cvm.api.qcloud.com', '/v2/index.php', params) 55 | 56 | if (__name__ == '__main__'): 57 | main() 58 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/common/request.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/common/request.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/common/sign.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | import binascii 5 | import hashlib 6 | import hmac 7 | 8 | class Sign: 9 | def __init__(self, secretId, secretKey): 10 | self.secretId = secretId 11 | self.secretKey = secretKey 12 | 13 | def make(self, requestHost, requestUri, params, method = 'GET'): 14 | list = {} 15 | flag_sha256 = 0 16 | for param_key in params: 17 | if method == 'post' and str(params[param_key])[0:1] == "@": 18 | continue 19 | if param_key == 'SignatureMethod' and params[param_key] == 'HmacSHA256': 20 | flag_sha256 = 1 21 | list[param_key] = params[param_key] 22 | srcStr = method.upper() + requestHost + requestUri + '?' + "&".join(k.replace("_",".") + "=" + str(list[k]) for k in sorted(list.keys())) 23 | if flag_sha256 == 1: 24 | hashed = hmac.new(self.secretKey, srcStr, hashlib.sha256) 25 | else: 26 | hashed = hmac.new(self.secretKey, srcStr, hashlib.sha1) 27 | return binascii.b2a_base64(hashed.digest())[:-1] 28 | 29 | def main(): 30 | secretId = 123 31 | secretKey = 'xxx' 32 | params = {} 33 | sign = Sign(secretId, secretKey) 34 | print sign.make('https://cvm.api.qcloud.com', '/v2/index.php', params) 35 | 36 | if (__name__ == '__main__'): 37 | main() 38 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/common/sign.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/common/sign.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/modules/__init__.py -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/modules/__init__.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/account.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Account(Base): 7 | requestHost = 'account.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'AddProject' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Account(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/base.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | import copy 5 | import time 6 | import random 7 | import sys 8 | import os 9 | import warnings 10 | warnings.filterwarnings("ignore") 11 | 12 | sys.path.append(os.path.split(os.path.realpath(__file__))[0] + os.sep + '..') 13 | from common.request import Request 14 | 15 | class Base: 16 | debug = 0 17 | requestHost = '' 18 | requestUri = '/v2/index.php' 19 | _params = {} 20 | 21 | def __init__(self, config): 22 | self.secretId = config['secretId'] 23 | self.secretKey = config['secretKey'] 24 | self.defaultRegion = config['Region'] 25 | self.method = config['method'] 26 | 27 | def _checkParams(self, action, params): 28 | self._params = copy.deepcopy(params) 29 | self._params['Action'] = action[0].upper() + action[1:] 30 | 31 | if (self._params.has_key('Region') != True): 32 | self._params['Region'] = self.defaultRegion 33 | 34 | if (self._params.has_key('SecretId') != True): 35 | self._params['SecretId'] = self.secretId 36 | 37 | if (self._params.has_key('Nonce') != True): 38 | self._params['Nonce'] = random.randint(1, sys.maxint) 39 | 40 | if (self._params.has_key('Timestamp') != True): 41 | self._params['Timestamp'] = int(time.time()) 42 | 43 | return self._params 44 | 45 | def generateUrl(self, action, params): 46 | self._checkParams(action, params) 47 | request = Request(self.secretId, self.secretKey) 48 | return request.generateUrl(self.requestHost, self.requestUri, self._params, self.method) 49 | 50 | def call(self, action, params, files = {}): 51 | self._checkParams(action, params) 52 | request = Request(self.secretId, self.secretKey) 53 | return request.send(self.requestHost, self.requestUri, self._params, files, self.method, self.debug) 54 | 55 | def main(): 56 | action = 'DescribeInstances' 57 | config = { 58 | 'Region': 'gz', 59 | 'secretId': '你的secretId', 60 | 'secretKey': '你的secretKey', 61 | 'method': 'get', 62 | } 63 | params = {} 64 | base = Base(config) 65 | print base.call(action, params) 66 | 67 | if (__name__ == '__main__'): 68 | main() 69 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/base.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/modules/base.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/bill.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Bill(Base): 7 | requestHost = 'bill.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeBills' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Bill(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/bm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Bm(Base): 7 | requestHost = 'bm.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeDeviceClass' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Bm(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/cbs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Cbs(Base): 7 | requestHost = 'cbs.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeCbsStorages' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Cbs(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/cdb.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Cdb(Base): 7 | requestHost = 'cdb.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeCdbInstances' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Cdb(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/cdn.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import hashlib 4 | import os 5 | from base import Base 6 | 7 | class Cdn(Base): 8 | requestHost = 'cdn.api.qcloud.com' 9 | 10 | def UploadCdnEntity(self, params): 11 | action = 'UploadCdnEntity' 12 | if (params.get('entityFile') == None): 13 | raise ValueError, 'entityFile can not be empty.' 14 | if (os.path.isfile(params['entityFile']) == False): 15 | raise ValueError, 'entityFile is not exist.' 16 | 17 | file = params.pop('entityFile') 18 | if ('entityFileMd5' not in params): 19 | params['entityFileMd5'] = hashlib.md5(open(file, 'rb').read()).hexdigest() 20 | 21 | files = { 22 | 'entityFile': open(file, 'rb') 23 | } 24 | 25 | return self.call(action, params, files) 26 | 27 | def main(): 28 | config = { 29 | 'Region': 'gz', 30 | 'secretId': '你的secretId', 31 | 'secretKey': '你的secretKey', 32 | 'method': 'post' 33 | } 34 | params = { 35 | 'entityFileName': '/test.txt', 36 | 'entityFile': '/tmp/test.txt' 37 | } 38 | service = Cdn(config) 39 | print service.UploadCdnEntity(params) 40 | 41 | if (__name__ == '__main__'): 42 | main() 43 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/cmem.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Cmem(Base): 7 | requestHost = 'cmem.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeCmem' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Cmem(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/cvm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Cvm(Base): 7 | requestHost = 'cvm.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeInstances' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Cvm(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/cvm.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/modules/cvm.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/dfw.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Dfw(Base): 7 | requestHost = 'dfw.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeSecurityGroups' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Dfw(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/eip.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Eip(Base): 7 | requestHost = 'eip.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeEip' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Eip(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/eip.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/modules/eip.pyc -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/image.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Image(Base): 7 | requestHost = 'image.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeCdbInstances' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Image(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/lb.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Lb(Base): 7 | requestHost = 'lb.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeLoadBalancers' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Lb(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/live.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Live(Base): 7 | requestHost = 'live.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeLVBOnlineUsers' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Live(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/market.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Market(Base): 7 | requestHost = 'market.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'QueryVoucherData' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Market(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/monitor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Monitor(Base): 7 | requestHost = 'monitor.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeMetrics' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Monitor(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/redis.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Redis(Base): 7 | requestHost = 'redis.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeRedis' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Redis(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/scaling.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Scaling(Base): 7 | requestHost = 'scaling.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeScalingConfiguration' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Scaling(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/sec.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Sec(Base): 7 | requestHost = 'csec.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'CaptchaQuery' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = { 18 | 'userIp': '127.0.0.1', 19 | 'businessId': 1, 20 | 'captchaType': 1, 21 | 'script': 0, 22 | } 23 | service = Sec(config) 24 | print service.call(action, params) 25 | 26 | if (__name__ == '__main__'): 27 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/snapshot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Snapshot(Base): 7 | requestHost = 'snapshot.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeSnapshots' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Snapshot(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/tdsql.py: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/python 3 | # -*- coding: utf-8 -*- 4 | 5 | from base import Base 6 | 7 | class Tdsql(Base): 8 | requestHost = 'tdsql.api.qcloud.com' 9 | 10 | def main(): 11 | action = 'CdbTdsqlGetUserList' 12 | config = { 13 | 'Region': 'gz', 14 | 'secretId': '你的secretId', 15 | 'secretKey': '你的secretKey', 16 | 'method': 'get' 17 | } 18 | params = {} 19 | service = Tdsql(config) 20 | print service.call(action, params) 21 | 22 | if (__name__ == '__main__'): 23 | main() 24 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/trade.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Trade(Base): 7 | requestHost = 'trade.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeAccountBalance' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Trade(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/vod.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Vod(Base): 7 | requestHost = 'vod.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeVodPlayUrls' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Vod(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/vpc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Vpc(Base): 7 | requestHost = 'vpc.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DescribeVpcs' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = {} 18 | service = Vpc(config) 19 | print service.call(action, params) 20 | 21 | if (__name__ == '__main__'): 22 | main() 23 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/wenzhi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Wenzhi(Base): 7 | requestHost = 'wenzhi.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'TextSentiment' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = { 18 | "content" : "123", 19 | } 20 | service = Wenzhi(config) 21 | print service.call(action, params) 22 | 23 | if (__name__ == '__main__'): 24 | main() 25 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/modules/yunsou.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | from base import Base 5 | 6 | class Yunsou(Base): 7 | requestHost = 'yunsou.api.qcloud.com' 8 | 9 | def main(): 10 | action = 'DataSearch' 11 | config = { 12 | 'Region': 'gz', 13 | 'secretId': '你的secretId', 14 | 'secretKey': '你的secretKey', 15 | 'method': 'get' 16 | } 17 | params = { 18 | "appId" : "123", 19 | "search_query" : "qq", 20 | "page_id" : 0, 21 | "num_per_page" : 10, 22 | } 23 | service = Yunsou(config) 24 | print service.call(action, params) 25 | 26 | if (__name__ == '__main__'): 27 | main() 28 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/qcloudapi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | class QcloudApi: 5 | def __init__(self, module, config): 6 | self.module = module 7 | self.config = config 8 | 9 | def _factory(self, module, config): 10 | if (module == 'cdb'): 11 | from modules.cdb import Cdb 12 | service = Cdb(config) 13 | elif (module == 'account'): 14 | from modules.account import Account 15 | service = Account(config) 16 | elif (module == 'cvm'): 17 | from modules.cvm import Cvm 18 | service = Cvm(config) 19 | elif (module == 'image'): 20 | from modules.image import Image 21 | service = Image(config) 22 | elif (module == 'lb'): 23 | from modules.lb import Lb 24 | service = Lb(config) 25 | elif (module == 'sec'): 26 | from modules.sec import Sec 27 | service = Sec(config) 28 | elif (module == 'trade'): 29 | from modules.trade import Trade 30 | service = Trade(config) 31 | elif (module == 'bill'): 32 | from modules.bill import Bill 33 | service = Bill(config) 34 | elif (module == 'monitor'): 35 | from modules.monitor import Monitor 36 | service = Monitor(config) 37 | elif (module == 'cdn'): 38 | from modules.cdn import Cdn 39 | service = Cdn(config) 40 | elif (module == 'vpc'): 41 | from modules.vpc import Vpc 42 | service = Vpc(config) 43 | elif (module == 'vod'): 44 | from modules.vod import Vod 45 | service = Vod(config) 46 | elif (module == 'yunsou'): 47 | from modules.yunsou import Yunsou 48 | service = Yunsou(config) 49 | elif (module == 'wenzhi'): 50 | from modules.wenzhi import Wenzhi 51 | service = Wenzhi(config) 52 | elif (module == 'market'): 53 | from modules.market import Market 54 | service = Market(config) 55 | elif (module == 'live'): 56 | from modules.live import Live 57 | service = Live(config) 58 | elif (module == 'eip'): 59 | from modules.eip import Eip 60 | service = Eip(config) 61 | elif (module == 'cbs'): 62 | from modules.cbs import Cbs 63 | service = Cbs(config) 64 | elif (module == 'snapshot'): 65 | from modules.snapshot import Snapshot 66 | service = Snapshot(config) 67 | elif (module == 'scaling'): 68 | from modules.scaling import Scaling 69 | service = Scaling(config) 70 | elif (module == 'cmem'): 71 | from modules.cmem import Cmem 72 | service = Cmem(config) 73 | elif (module == 'tdsql'): 74 | from modules.tdsql import Tdsql 75 | service = Tdsql(config) 76 | elif (module == 'bm'): 77 | from modules.bm import Bm 78 | service = Bm(config) 79 | elif (module == 'redis'): 80 | from modules.redis import Redis 81 | service = Redis(config) 82 | elif (module == 'dfw'): 83 | from modules.dfw import Dfw 84 | service = Dfw(config) 85 | else: 86 | raise ValueError , 'module not exists' 87 | 88 | return service 89 | 90 | def setSecretId(self, secretId): 91 | self.config['secretId'] = secretId 92 | 93 | def setSecretKey(self, secretKey): 94 | self.config['secretKey'] = secretKey 95 | 96 | def setRequestMethod(self, method): 97 | self.config['method'] = method 98 | 99 | def setRegion(self, region): 100 | self.config['region'] = region 101 | 102 | def generateUrl(self, action, params): 103 | service = self._factory(self.module, self.config) 104 | return service.generateUrl(action, params) 105 | 106 | def call(self, action, params): 107 | service = self._factory(self.module, self.config) 108 | 109 | methods = dir(service) 110 | for method in methods: 111 | if (method == action): 112 | func = getattr(service, action) 113 | return func(params) 114 | 115 | return service.call(action, params) 116 | 117 | def main(): 118 | module = 'cdn' 119 | action = 'UploadCdnEntity' 120 | config = { 121 | 'Region': 'gz', 122 | 'secretId': '你的secretId', 123 | 'secretKey': '你的secretKey', 124 | 'method': 'post' 125 | } 126 | params = { 127 | 'entityFileName': '/test_____don.html', 128 | 'entityFile': 'c:/xampp/htdocs/index.html' 129 | } 130 | service = QcloudApi(module, config) 131 | print ('URL:\n' + service.generateUrl(action, params)) 132 | print (service.call(action, params)) 133 | 134 | if (__name__ == '__main__'): 135 | main() 136 | -------------------------------------------------------------------------------- /lib/tencent_src/QcloudApi/qcloudapi.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/QcloudApi/qcloudapi.pyc -------------------------------------------------------------------------------- /lib/tencent_src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/__init__.py -------------------------------------------------------------------------------- /lib/tencent_src/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grayddq/PubilcAssetInfo/fdf1bfb76d8eeb5d3fafbb097d078d59b48ed0d0/lib/tencent_src/__init__.pyc -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aliyun_python_sdk_core==2.6.0 2 | aliyun_python_sdk_ecs==4.4.1 3 | aliyun_python_sdk_slb==3.2.1 4 | Requests==2.18.4 5 | --------------------------------------------------------------------------------