import requests as rq
import time
#nginxWebUI的host
host = 'nginx-web-ui.xxx.com'
def main():
add_ipv4()
add_ipv6()
add_complete()
def add(ip,name='set_real_ip_from'):
cookies = {#登录后抓取cookie
'SOLONID': '434ecf01a6b04684a1370ed54fe0fd7b',
'SOLONID2': 'eea13621adf4952cdc0b800458feaad7',
}
headers = {
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
}
data = [
('id', ''),
('name', name),
('value', ip),
('param', '75'),
('param', 'on'),
('param', '4'),
('param', '4'),
('type', 'js'),
('type', 'css'),
('type', 'json'),
('type', 'xml'),
('param', '1024'),
('param', '32'),
('param', '8'),
('param', '512'),
('param', '51200'),
('param', '6400'),
]
response = rq.post(f'https://{host}/adminPage/http/addOver', cookies=cookies, headers=headers, data=data)
print(response.text)
def add_ipv4():
ip_list_str = rq.get('https://www.cloudflare.com/ips-v4').text
ip_list = ip_list_str.split('/n')
print(ip_list)
for ip in ip_list:
add(ip)
time.sleep(0.1)
def add_ipv6():
ip_list_str = rq.get('https://www.cloudflare.com/ips-v6').text
ip_list = ip_list_str.split('/n')
print(ip_list)
for ip in ip_list:
add(ip)
time.sleep(0.1)
def add_complete():
add('CF-Connecting-IP','real_ip_header')
if __name__=="__main__":
main()
原创文章,作者:506227337,如若转载,请注明出处:https://blog.ytso.com/271453.html