Commit a2ab93d7 authored by 王明明's avatar 王明明

222

parent de7a57d0
...@@ -6,9 +6,11 @@ import ctypes ...@@ -6,9 +6,11 @@ import ctypes
import tls_client import tls_client
from py_mini_racer import MiniRacer from py_mini_racer import MiniRacer
from loguru import logger from loguru import logger
with open('test.js', 'r', encoding='utf-8')as f:
with open('test.js', 'r', encoding='utf-8') as f:
jsCode = f.read() jsCode = f.read()
def get_timestamp(): def get_timestamp():
return int(time.time() * 1000) return int(time.time() * 1000)
...@@ -20,18 +22,28 @@ def unsinged_right_shift(x, y): ...@@ -20,18 +22,28 @@ def unsinged_right_shift(x, y):
class PxBypass(): class PxBypass():
session = tls_client.Session(client_identifier='chrome_112') session = tls_client.Session(client_identifier='chrome_112')
session.proxies = {
'http': 'http://127.0.0.1:7890',
'https': 'http://127.0.0.1:7890',
}
session.proxies = {
'http': "http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600",
'https': "http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600",
}
def __init__(self, target_url): def __init__(self, target_url):
self.target_url = target_url self.target_url = target_url
self.log = logger.bind(module_name='px') self.log = logger.bind(module_name='px')
def run(self): def run(self):
print(self._step_1()) self._init()
# self._init()
self._step_1()
self.__token()
def _init(self): def _init(self):
headers = { headers = {
"authority": "www.chegg.com", "authority": "www.spirit.com",
"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": "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-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7", "accept-language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
"cache-control": "no-cache", "cache-control": "no-cache",
...@@ -48,7 +60,10 @@ class PxBypass(): ...@@ -48,7 +60,10 @@ class PxBypass():
} }
res = self.session.get(self.target_url, headers=headers) res = self.session.get(self.target_url, headers=headers)
self.log.info(f"初始化请求 res {res.status_code}") self.log.info(f"初始化请求 res {res.status_code}")
self.log.info(f"init cookie {self.session.cookies}") self.params = {}
for k, v in self.session.cookies.items():
self.params[k] = v
self.log.info(f"init cookie {self.params}")
def __uuid(self): def __uuid(self):
r = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", r = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11",
...@@ -68,6 +83,7 @@ class PxBypass(): ...@@ -68,6 +83,7 @@ class PxBypass():
"fc", "fd", "fe", "ff"] "fc", "fd", "fe", "ff"]
bs = 0 bs = 0
ys = [63, 161, 165, 50, 14, 19] ys = [63, 161, 165, 50, 14, 19]
random.shuffle(ys)
Gs = 8057 Gs = 8057
Ws = 0 Ws = 0
s = Gs s = Gs
...@@ -106,56 +122,138 @@ class PxBypass(): ...@@ -106,56 +122,138 @@ class PxBypass():
t1 = int(time.time() * 1000) t1 = int(time.time() * 1000)
t2 = t1 + random.randint(3, 12) t2 = t1 + random.randint(3, 12)
_uuid = self.__uuid() _uuid = self.__uuid()
data = [ data = [{"t": "PX12095",
{ "d": {"PX11645": "https://www.spirit.com/", "PX12207": 0, "PX12458": "Win32", "PX11902": 0,
"t": "PX10816", "PX11560": random.randint(8549, 8549 * 3), "PX12248": 3600, "PX11385": t1, "PX12280": t2,
"d": { "PX11496": _uuid, "PX12564": None, "PX12565": -1,
"PX10360": "https://www.chegg.com/", "PX11379": True}}]
"PX10929": 0, data_str = json.dumps(data, separators=(',', ':'))
"PX11186": "Win32",
"PX10622": 0, # index ++
"PX10272": 6869, # Math.round(performance.now())
"PX10970": 3600,
"PX10094": t1,
"PX11004": t2,
"PX10206": _uuid,
"PX10088": False
}
}
]
data_str = json.dumps(data, separators=('"', ':'))
self.log.info(f'data_str {data_str}') self.log.info(f'data_str {data_str}')
o = self.encrypt(base64.b64encode('1604064986000'.encode()).decode(), 10)
payload = base64.b64encode(self.__encrypt(data_str, 50)).decode() payload = base64.b64encode(self.encrypt(data_str, 50)).decode()
ctx = MiniRacer()
ctx.eval(jsCode)
payload = ctx.call('enc', payload, _uuid)
self.log.info(f'payload {payload}') self.log.info(f'payload {payload}')
tag = "v7.6.2" tag = "v8.6.4"
ft = "263" ft = "314"
pc = self.__gen_pc(data_str, f'{_uuid}:{tag}:{ft}') pc = self.__gen_pc(data_str, f'{_uuid}:{tag}:{ft}')
print(pc)
body = { body = {
"payload": payload, "payload": payload,
"appId": "PXzYvFOXaC", "appId": "PXkp4CLSb5",
"tag": tag, "tag": tag,
"uuid": _uuid, "uuid": _uuid,
"ft": ft, "ft": ft,
"seq": "0", "seq": "0",
"en": "NTA", "en": "NTA",
"pc": "7074408855928128", "pc": pc,
"p1": "5268602cc413e604a21b412a3fa6118c64c205f92f5602.78118214", "pxhd": self.params['_pxhd'],
"rsc": "1" "rsc": "1"
} }
def __encrypt(self, data_str, param): url = "https://collector-pxkp4clsb5.px-cloud.net/api/v2/collector"
headers = {
"authority": "collector-pxkp4clsb5.px-cloud.net",
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"origin": "https://www.spirit.com",
"pragma": "no-cache",
"referer": "https://www.spirit.com/",
"sec-ch-ua": "\"Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Chromium\";v=\"115\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "cross-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
}
response = self.session.post(url, headers=headers, data=body)
self.log.info(f'collector1 {response.text}')
resp = response.json()
if 'ob' in resp:
cookies = self.encrypt(base64.b64decode(resp['ob'].encode()), 96).decode()
print(cookies.split('~~~~'))
for i in cookies.split('~~~~'):
tmp = i.split('|')
if 'pxde' in i:
self.session.cookies.update({
'_pxde': tmp[3]
})
elif '_px2' in i:
self.session.cookies.update({
'_px2': tmp[3]
})
elif '31536000' in i:
self.session.cookies.update({
'_pxvid': tmp[1]
})
else:
for i in resp['do']:
tmp = i.split('|')
print(len(tmp), tmp)
if len(tmp) == 6 and tmp[1] in ['_px', '_px3', '_pxde']:
self.session.cookies.update({
tmp[1]: tmp[3]
})
elif len(tmp) in [3, 4] and tmp[1] in ['cts', 'vid']:
self.session.cookies.update({
tmp[0]: tmp[1]
})
self.log.info(self.session.cookies.keys())
def encrypt(self, data, param):
n = bytearray() n = bytearray()
for i in data_str.encode(): if isinstance(data, str):
n.append(i ^ 50) bytess = data.encode()
else:
bytess = data
for i in bytess:
n.append(i ^ param)
return n return n
def __gen_pc(self, data_str, param): def __gen_pc(self, data_str, param):
# self.log.info(f'genpc {data_str} {param}')
ctx = MiniRacer()
ctx.eval(jsCode)
return ctx.call('Jt', param, data_str)
def __token(self):
headers = {
"authority": "www.spirit.com",
"accept": "application/json, text/plain, */*",
"accept-language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
"cache-control": "no-cache",
"content-type": "application/json",
"ocp-apim-subscription-key": "dc6844776fe84b1c8b68affe7deb7916",
"origin": "https://www.spirit.com",
"pragma": "no-cache",
"referer": "https://www.spirit.com/",
"sec-ch-ua": "\"Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Chromium\";v=\"115\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
}
url = "https://www.spirit.com/api/prod-token/api/v1/token"
data = {
"applicationName": "dotRezWeb"
}
data = json.dumps(data, separators=(',', ':'))
response = self.session.post(url, headers=headers, data=data)
print(response.text)
if __name__ == '__main__': if __name__ == '__main__':
px = PxBypass('https://www.chegg.com/') url = "https://www.spirit.com/"
px = PxBypass(url)
px.run() px.run()
print(unsinged_right_shift(275404960, 24) & 255) print(unsinged_right_shift(275404960, 24) & 255)
...@@ -81,8 +81,6 @@ function j(t) { ...@@ -81,8 +81,6 @@ function j(t) {
return n return n
} }
let t = '7f338930-2c4a-11ee-b4af-75cb5563a0c5:v7.6.2:263'
let e = '[{"t":"PX10816","d":{"PX10360":"https://www.chegg.com/","PX10929":0,"PX11186":"Win32","PX10622":0,"PX10272":38485,"PX10970":3600,"PX10094":1690440897986,"PX11004":1690440897987,"PX10206":"7f338930-2c4a-11ee-b4af-75cb5563a0c5","PX10088":false}}]'
function Y(t, e) { function Y(t, e) {
return j(N(t, e)) return j(N(t, e))
...@@ -106,4 +104,234 @@ function Jt(t, e) { ...@@ -106,4 +104,234 @@ function Jt(t, e) {
} }
} }
console.log(Jt(t, e)) let t = 'd83eb229-6870-1031-9f79-3fa1a5320e13:v7.6.2:263'
\ No newline at end of file let e = '[{"t":"PX10816"""d":{"PX10360":"https://www.chegg.com/"""PX10929":0""PX11186":"Win32"""PX10622":0""PX10272":6869""PX10970":3600""PX10094":1690441304937""PX11004":1690441304948""PX10206":"d83eb229-6870-1031-9f79-3fa1a5320e13"""PX10088":false}}]'
e = '[{"t":"PX10816"""d":{"PX10360":"https://www.chegg.com/"""PX10929":0""PX11186":"Win32"""PX10622":0""PX10272":6869""PX10970":3600""PX10094":1690441360963""PX11004":1690441360969""PX10206":"db9599a1-6870-1031-9f79-3fa1a5320e13"""PX10088":false}}]'
t = 'db9599a1-6870-1031-9f79-3fa1a5320e13:v7.6.2:263'
console.log(Jt(t, e))
function Base64() {
// private property
_keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
// public method for encoding
this.encode = function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = _utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
_keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
_keyStr.charAt(enc3) + _keyStr.charAt(enc4);
}
return output;
}
// public method for decoding
this.decode = function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = _keyStr.indexOf(input.charAt(i++));
enc2 = _keyStr.indexOf(input.charAt(i++));
enc3 = _keyStr.indexOf(input.charAt(i++));
enc4 = _keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = _utf8_decode(output);
return output;
}
// private method for UTF-8 encoding
_utf8_encode = function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
} else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
// private method for UTF-8 decoding
_utf8_decode = function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
} else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}
let btoa = function (string){
return new Base64().encode(string)
}
function sss(t) {
return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g, (function (t, e) {
return String.fromCharCode("0x" + e)
}
)))
}
console.log(sss('1604064986000'))
function yl() {
var t = [
"171942oARFUk",
"7yRtXhk",
"floor",
"144847yKlojB",
"1226080GxvQRV",
"indexOf",
"split",
"slice",
"length",
"275532BAADdl",
"charCodeAt",
"1604064986000",
"1200393dOHuyA",
"97227jRXOWB",
"8MTVeQo",
"264496VgbcvF",
"substring",
"15YAslii",
"push",
"sort"
]
return (yl = function () {
return t
}
)()
}
function vl(t, n) {
var e = yl();
return (vl = function (t, n) {
return e[t -= 376]
}
)(t, n)
}
function Bn(t, n) {
for (var e = "", r = 0; r < t.length; r++)
e += String.fromCharCode(n ^ t.charCodeAt(r));
return e
}
$ = function (t) {
return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g, (function (t, n) {
return String.fromCharCode("0x" + n)
}
)))
}
var Zl = function (t, n, e, r, a) {
return Math[vl(378)]((t - n) / (e - n) * (a - r) + r)
}
u = function (t, n, e) {
var r = 384, a = 378, o = 384, i = 386, c = 386, u = 384, f = 386, l = 381, s = 394, h = 395, y = vl,
Z = Bn($(e), 10), d = [], v = -1
for (var p = 0; p < t[y(r)]; p++) {
var w = Math[y(a)](p / Z[y(r)] + 1)
, m = p >= Z[y(o)] ? p % Z[y(r)] : p
, g = Z[y(i)](m) * Z[y(c)](w);
g > v && (v = g)
}
for (var X = 0; t[y(o)] > X; X++) {
var b = Math[y(a)](X / Z[y(o)]) + 1
, T = X % Z[y(u)]
, R = Z[y(i)](T) * Z[y(f)](b);
for (R >= n && (R = Zl(R, 0, v, 0, n - 1)); -1 !== d[y(l)](R);)
R += 1;
d[y(s)](R)
}
var A = d[y(h)]((function (t, n) {
return t - n
}
));
return A
}
o = 'G^S}DNK8DNa>D`K}GK77'
ur = u(o
, 364, '632ced90-2c62-11ee-9f7e-270e803e7664')
console.log(ur)
function rrr(t, n, e) {
var r = {
v: 382,
K: 384,
X: 392,
d: 392
}
, a = vl;
for (var o = "", i = 0, c = t['split'](""), u = 0; u < t[a(r.K)]; u++)
o += n[a(r.X)](i, e[u] - u - 1) + c[u],
i = e[u] - u - 1;
return o + n[a(r.d)](i)
}
let aa = 'aUkQRhAIEGJqAwACCwcQHhBWEAhJEGJqAwMEBgcQCBBaRkZCQQgdHUVFRRxBQltAW0YcUV1fHRAeEGJqAwAAAgUQCAIeEGJqAwAGBwoQCBBlW1wBABAeEGJqAwMLAgAQCAIeEGJqAwMHBAIQCAADBgYFHhBiagMAAAYKEAgBBAICHhBiagMDAQoHEAgDBAsCBgYKAQUBAgcLHhBiagMAAAoCEAgDBAsCBgYKAQUBAgoGHhBiagMDBgsEEAgQVlZWAlYDCgIfAFEHUB8DA1dXH1ABUFMfB1QKBlcFBQpUBVEDEB4QYmoDAAcEBhAIXEdeXh4QYmoDAAcEBxAIHwMeEGJqAwMBBQsQCEZAR1dPT28='
console.log(rrr(o, aa, ur))
function enc(payload, uuid) {
o = 'G^S}DNK8DNa>D`K}GK77'
ur = u(o
, 364, uuid)
console.log(ur)
return rrr(o, payload, ur)
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment