forked from NyaMisty/leafxcy_leafTheFish_DeathNote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch_eleme.py
59 lines (48 loc) · 1.51 KB
/
patch_eleme.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
import re
import sys
HEADER = '''
var hpagent = require('hpagent')
var agentOpt = {
keepAlive: true,
keepAliveMsecs: 2000,
maxSockets: Infinity,
maxFreeSockets: 256,
proxy: process.env.HTTP_PROXY
}
var __got = require("got")
var _got_new = __got.extend({
agent: {
http: new hpagent.HttpProxyAgent(Object.assign({}, agentOpt)),
https: new hpagent.HttpsProxyAgent(Object.assign({}, agentOpt)),
}
})
var _require = require
require = (a) => {
if (a == 'got') return _got_new;
return _require(a)
}
function getMin(a, b) {
return a < b ? a : b
}
'''
fn = sys.argv[1]
with open(fn) as f:
content = f.read()
#newcontent = re.sub(r"(\['\\x69\\x64'\])=.*?\+'\\x38',(.*?)=0x3e8", r"\1='178002',\2=950", content)
#assert '178002' in newcontent or newcontent != content
content = content.replace(r"_0x5cae1d[_0x32515a(0x1d7)+'\x6e'](_0x3c2f43", r"getMin(_0x3c2f43")
IDEN_RE = r'_0x[0-9a-f]+?'
#STR_RE = r'[_x0-9a-f()+]+?'
STR_RE = r'[^\[\]]+?'
extraObj, mainReqObj = re.findall(r'(%s)\[%s\]=0x3e8;const (%s)=\{\};' % (IDEN_RE, STR_RE, IDEN_RE), content)[0]
newcontent = re.sub(r'(%s\[%s\]=%s);' % (mainReqObj, STR_RE, extraObj), r"\1;%s['costFoodiePea']=950;%s['supplyInst']='43002|178002';" % (extraObj, mainReqObj), content)
assert newcontent != content
content = newcontent
if True:
newcontent = newcontent.replace(
'*/\n',
#"*/\nvar bootstrap = require('global-agent').bootstrap; bootstrap();\n"
"*/\n" + HEADER
)
with open(fn, 'w') as f:
f.write(newcontent)