Closed an-Underpriviliged-ZJUer closed 11 months ago
我的python:
def send_rpc( group='test_group', name='test_name', funcName=None,param={}, b=None,**leak ): import requests import json url = "http://localhost:12080/go" data = { "group": group, "name": name, "action": "callFunctionByName", "param": json.dumps(merge({"funcName":funcName},param)) } return jsontodict(requests.post(url, data=data).text)['data']
更改后的Js_环境: handler.regAction("callFunctionByName", function (resolve, param) { funcName = param.funcName if (typeof funcName === 'string' && typeof functions[funcName] === 'function') { res = functionsfuncName resolve(res) } }) funciton{}中的两个函数:
e ({ xpath = null }) {
const elements = this.es({ xpath })
if (elements.length === 0) {
console.log(Element with XPath ${xpath} not found.
)
return null
}
return elements[0]
},
es ({ xpath }) {
let attr = null
if (xpath.includes("//@")) {
attr = xpath.split("//@")[1]
xpath = xpath.split("//@")[0]
} else if (xpath.includes("/@")) {
attr = xpath.split("/@")[1]
xpath = xpath.split("/@")[0]
} else if (xpath.includes("/text()")) {
attr = "text"
xpath = xpath.split("/text()")[0]
}
const snapshot = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
const nodes = []
for (let i = 0; i < snapshot.snapshotLength; i++) {
const node = snapshot.snapshotItem(i)
if (attr) {
if (attr === "text") {
nodes.push(node.textContent)
} else {
nodes.push(node.getAttribute(attr))
}
} else {
nodes.push(node)
}
}
console.log(查询元素 ${xpath} 成功,共有 ${nodes.length} 个
)
return nodes
},
这种时候就不能返回原本是数组形式的nodes
改好了。唉浪费我时间去学js Hlclient.prototype.sendResult = function (action, e) { const jsonData = JSON.stringify(e); this.send(action + atob("aGxeX14") + jsonData); }
比如返回数组;似乎得到的总是字符串