import requests import base64 #########需要操作的ip群组名称,和添加的ip # add_ipaddress = "7.7.7.7" add_ipaddress= "10.32."+ input("输入IP---> 10.32.",) #前端传入,判断只能为单ip, # 1、腾讯会议前面二位固定为10.32.x.x, x为int 0<= x >255, #2、安全部黑名单为单个ip,x.x.x.x,x为int 0<= x >255, ipqunzu_name = 'aaa' #ip群组名称,一般固定不变,一个应用对应一个ip群组 server_ip = "ip" #主墙ip,固定值 #server_ip = "ip" #备墙ip, ###################### headers = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) \ AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36", \ 'Content-type': 'text/html',} url = "http://{}:8090/cgi-bin/sendDoLogin".format(server_ip) rq = requests.post(url=url, data={"chkport":"密码"},headers=headers) #"chkport":{"sUserCode":"用户","sPwd":"密码"}, #需要修改密码vi /conf/App/restmgd/user/admin/password # print(str(rq.content ,encoding = "utf8")) ret_val = eval(str(rq.content ,encoding = "utf8")).get("data").get('token') # print(ret_val,type(ret_val)) # #---------------以上头部取值token字段,以下为查找ip群组名后添加ip地址-------------------- url3 = "http://{}:8090/cgi-bin/sendIPTableList/?token={}".format(server_ip,ret_val) req = requests.post(url3, headers=headers).content.decode("gbk") ##req类型str,取data的values进行遍历{"msg":"success.","code":0,"data":[{"tbid":1,"sName":"bgggg333"},{"tbid":2,"sName":"aaa"}]} ret_val1 = eval(req).get("data") add_canshu ='' for add_canshu in ret_val1: if add_canshu.get("sName") == ipqunzu_name: add_canshu['ip'] = add_ipaddress break url2 = "http://{}:8090/cgi-bin/sendIPTableAddIP/?token={}".format(server_ip,ret_val) req = requests.post(url2, data=add_canshu, headers=headers).content.decode("utf8") print("添加腾讯会议加速ip地址:%s 成功"%add_ipaddress) if eval(req).get('msg') == "success." else print("异常,没有该ip群组或者ip地址错误")
python- panabit添加黑白名单
最新推荐文章于 2024-07-04 21:56:25 发布