salt-satck api使用脚本
2021-07-11 05:04
标签:ofo int argv lse htm port href salt cat import requests #首先获得salt的token def salt_command(): if name == ‘main‘: salt-satck api使用脚本 标签:ofo int argv lse htm port href salt cat 原文地址:http://blog.51cto.com/2925718/2176013
import json
import urllib3
import sys
def Get_token():
#准备请求头等各种信息
urllib3.disable_warnings()
URL = ‘https://172.16.185.232/login/‘
Hander = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36",
"Content-type": "application/json"}
Info = {‘username‘:‘salt‘,‘password‘:‘1P9lS57ZaJ59FFdayuiX‘,‘eauth‘:‘pam‘}
request = requests.post(url=URL,data=Info,verify=False)
response = request.json()
return response[‘return‘][0][‘token‘]
urllib3.disable_warnings()
tgt = sys.argv[1]
arg = sys.argv[2]
Url = ‘https://172.16.185.232‘
Hander = {‘X-Auth-Token‘:Get_token()}
Data = {‘client‘: ‘local‘, ‘tgt‘: tgt,‘fun‘: ‘cmd.run‘,‘arg‘:arg}
ret = requests.post(url=Url,data=Data,headers=Hander,verify=False)
print(ret.json())
salt_command()
文章标题:salt-satck api使用脚本
文章链接:http://soscw.com/index.php/essay/103549.html