声明:
该文章为学习使用,严禁用于商业用途和非法用途,违者后果自负,由此产生的一切后果均与作者无关
瑞数动态安全 Botgate(机器人防火墙)以“动态安全”技术为核心,通过动态封装、动态验证、动态混淆、动态令牌等技术对服务器网页底层代码持续动态变换,增加服务器行为的“不可预测性”,实现了从用户端到服务器端的全方位“主动防护”,为各类 Web、HTML5 提供强大的安全保护。
// 代理器封装
function getEnv(proxy_array) {
for(var i=0; i
如果cookie生成之后,有其他接口参数加密,直接使用明文参数一样可以调用成功,因为参数加密是瑞数加密,所以这里解密也是瑞数自己解密的;
测试请求/doc/queryDocList,通过XHR请求拦截,找到明文信息,修改zj.py,请求/doc/queryDocList,会发现即使是明文数据也可以获取成功
delete __filename
delete __dirname
var getEnv = require('./jsProxy')
//补window
window = global
window.top = window
window.clearInterval = function () {
}
window.addEventListener = function (event) {
console.log('window中addEventListener接受的值是:', event)
}
//补document
div = {
getElementsByTagName: function (tag) {
if (tag == 'i') {
return {length: 0}
} else {
console.log('div中getElementsByTagName接受的值是', tag)
return {}
}
}
}
script = {
0: {
getAttribute: function (attr) {
console.log('script-0中getAttribute接受的值是', attr)
if (attr == 'r') {
return 'm'
}
},
parentElement: {
removeChild: function (tag) {
console.log('script-1中的removeChild接受的值:', tag)
}
}
},
1: {
getAttribute: function (attr) {
console.log('script-1中getAttribute接受的值是', attr)
if (attr == 'r') {
return 'm'
}
},
parentElement: {
removeChild: function (tag) {
console.log('script-1中的removeChild接受的值:', tag)
}
}
},
length: 2
}
meta = {
0: {},
1: {
getAttribute: function (attr) {
if (attr == 'r') {
return 'm'
} else {
console.log('meta-1中getAttribute接受的值是', attr)
return {}
}
},
parentNode: {
removeChild: function (tag) {
console.log('meta-1中removeChild接受的值是:', tag)
}
},
content: 'meta_content'
},
length: 2
}
form = {
action: 'https://ucenter.miit.gov.cn/login.jsp',
id: '__Zm9ybS5pZAo__',
}
document = {
createElement: function (tag) {
if (tag == 'div') {
return div
} else if (tag == 'form') {
return form
}
},
appendChild: function (tag) {
console.log('document中appendChild接受的值是', tag)
return tag || {};
},
removeChild: function (tag) {
console.log('document中removeChild接受的值是', tag)
return {}
},
getElementsByTagName: function (tag) {
if (tag == 'script') {
return script
} else if (tag == 'meta') {
return meta
} else {
console.log('document中getElementsByTagName接受的值是', tag)
return {}
}
},
getElementById: function (id) {
console.log('document中的getElementById接受的值是:', id)
if (id == 'root-hammerhead-shadow-ui') {
return null
}
}
}
//补location
location = {
href: "http://www.chinastock.com.cn/newsite/cgs-services/stockFinance/businessAnnc.html",
origin: "http://www.chinastock.com.cn",
protocol: "http:",
host: "www.chinastock.com.cn",
hostname: "www.chinastock.com.cn",
pathname: "/newsite/cgs-services/stockFinance/businessAnnc.html"
}
setTimeout = function () {
}
setInterval = function () {
}
proxy_array = ['window', 'document', 'location', 'navigator', 'history', 'screen', 'target', 'script[0]', 'meta[1]', 'form']
getEnv(proxy_array)
'ts_code'
'js_code'
function get_cookie() {
var EzPGwRUoQaWT = document.cookie.split('1EzPGwRUoQaWT=')[1].split(';')[0]
return EzPGwRUoQaWT
}
console.log(get_cookie())
import requests
from lxml import etree
import execjs
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Language": "en,zh-CN;q=0.9,zh;q=0.8",
"Cache-Control": "no-cache",
"Pragma": "no-cache",
"Proxy-Connection": "keep-alive",
"Referer": "http://www.chinastock.com.cn/newsite/cgs-services/stockFinance/businessAnnc.html",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
}
cookies = {
# "aliyungf_tc": "d0a79762e3a5a1d8fae1f5815c7c8dfee488fd8bb3fe2e271ca7f6b32c4891e4",
# "acw_tc": "ac11000117016103207903338ebe3da6d7f7013a812d4181d1c81f244b0c5e",
# "1EzPGwRUoQaWS": "5Sd_7hNDdsibBtUr2KtaorX.oMnUzRBCHryQ5jRWd5MgFf4243PnXoAZTfhrUTSeItypKYhnttDwtt.8PaZXHhA",
# "1EzPGwRUoQaWT": ".sHyUJtIBQzbbxLniztzoQdA3t20ZaSihfzHSypZM.4g_l7L7FR9B9dAic0hpBh2LoAoyddu75D2fGnxHgxjxvjwzNBjeXFFjmZ9KqNVuffkH3LGfYGIpCKE1zqsINGThR9wd2mY9o87Pu.89nXVRA_j2d.6nedwflKSAAkPCuL6TwVemW_lu.1lelL3uAUjcr2bpV2EQ2pdu6txVpYO1MieHfUtzKoxl2b6pSJgnPA"
}
url = "http://www.chinastock.com.cn/newsite/cgs-services/stockFinance/businessAnnc.html"
request_session = requests.session()
request_session.headers.update(headers)
request_session.cookies.update(cookies)
def get_ts():
response = request_session.get(url)
cookies['acw_tc'] = response.cookies['acw_tc']
cookies['aliyungf_tc'] = response.cookies['aliyungf_tc']
cookies['1EzPGwRUoQaWS'] = response.cookies['1EzPGwRUoQaWS']
request_session.cookies.update(cookies)
html = etree.HTML(response.text)
ts_code = html.xpath('//script[1]/text()')[0]
js_src = html.xpath('//script[2]/@src')[0]
meta_content = html.xpath('//meta[2]/@content')[0]
return ts_code, js_src, meta_content
ts_code, js_src, meta_content = get_ts()
def get_js():
js_url = f'http://www.chinastock.com.cn{js_src}'
response = request_session.get(js_url)
request_session.cookies.update(cookies)
return response.text
js_code = get_js()
with open('zj.js', 'r', encoding='utf-8') as js_file:
js_text = js_file.read()
js_text = js_text.replace('meta_content', meta_content)
js_text = js_text.replace("'ts_code'", ts_code)
js_text = js_text.replace("'js_code'", js_code)
js = execjs.compile(js_text)
cookies['1EzPGwRUoQaWT'] = js.call('get_cookie')
request_session.cookies.update(cookies)
response = request_session.get(url)
response.encoding = 'utf-8'
# print(response.text)
# print(response)
get_data_par = {
'catName': "yhgg_融资融券公告",
'dayLimit': "9000",
'pageNo': 2,
'pageSize': "50",
}
get_data_url = 'http://www.chinastock.com.cn/website2020/doc/queryDocList'
response = request_session.get(get_data_url, params=get_data_par)
print(response.text)
print(response)