This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbypass_js.py
66 lines (56 loc) · 1.82 KB
/
bypass_js.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from seleniumbase import DriverContext
from threading import Lock
class SingletonDriver:
_instance = None
_lock = Lock()
def __new__(cls, *args, **kwargs):
if not cls._instance:
with cls._lock:
if not cls._instance:
cls._instance = super(SingletonDriver, cls).__new__(cls, *args, **kwargs)
cls._instance.driver_context = DriverContext()
cls._instance.driver = cls._instance.driver_context.__enter__()
return cls._instance
def execute_script(self, chq):
self.driver.execute_script("""
class ChqService {
static execute(value) {
const len = value.length
, bytes = new Uint8Array(len / 2)
, x = 157;
for (let R = 0; R < len; R += 2)
bytes[R / 2] = parseInt(value.substring(R, R + 2), 16);
const xored = bytes.map(R=>R ^ x)
, decoded = new TextDecoder().decode(xored);
return eval(decoded)
}
}
""")
result = self.driver.execute_script(f"""
var chrStub = document.createElement("div");
chrStub.id = "_chr_";
document.body.appendChild(chrStub);
class ChqService {{
static execute(value) {{
const len = value.length
, bytes = new Uint8Array(len / 2)
, x = 157;
for (let R = 0; R < len; R += 2)
bytes[R / 2] = parseInt(value.substring(R, R + 2), 16);
const xored = bytes.map(R=>R ^ x)
, decoded = new TextDecoder().decode(xored);
return eval(decoded)
}}
}}
try {{
return ChqService.execute(`{chq}`);
}} catch (e) {{
console.log(e);
return e;
}}
""")
return result
def __del__(self):
if self.driver_context:
self.driver_context.__exit__(None, None, None)
driver_instance = SingletonDriver()