123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- from random import choice
- from time import time
- from hashlib import md5
- from copy import deepcopy
- def hex_string(num):
- tmp_string = hex(num)[2:]
- if len(tmp_string) < 2:
- tmp_string = '0' + tmp_string
- return tmp_string
- def reverse(num):
- tmp_string = hex(num)[2:]
- if len(tmp_string) < 2:
- tmp_string = '0' + tmp_string
- return int(tmp_string[1:] + tmp_string[:1], 16)
- def RBIT(num):
- result = ''
- tmp_string = bin(num)[2:]
- while len(tmp_string) < 8:
- tmp_string = '0' + tmp_string
- for i in range(0, 8):
- result = result + tmp_string[7 - i]
- return int(result, 2)
- class XG:
- def __init__(self, debug):
- self.length = 0x14
- self.debug = debug
- # a=choice(range(0, 0xFF))
- # b=8 * choice(range(0, 0x1F))
- # print(a,b)
- # a=231
- # b=64
- # a=195
- # # b=72
- # a=23
- # b=80
- # a=139
- # b=160
- # a=237
- # b=104
- # m=[(231,64),(195,72),(23,80),(139,160)]
- # c=choice(m)
- # a=c[0]
- # b=c[1]
- a=231
- b=64
- self.hex_510 = [0x1E, 0x00, 0xE0, a, 0x93, 0x45, 0x01,b ]
- def addr_920(self):
- tmp = ''
- hex_920 = []
- for i in range(0x0, 0x100):
- hex_920.append(i)
- # check_log(hex_920)
- for i in range(0, 0x100):
- if i == 0:
- A = 0
- elif tmp:
- A = tmp
- else:
- A = hex_920[i - 1]
- B = self.hex_510[i % 0x8]
- if A == 0x55:
- if i != 1:
- if tmp != 0x55:
- A = 0
- C = A + i + B
- while C >= 0x100:
- C = C - 0x100
- if C < i:
- tmp = C
- else:
- tmp = ''
- D = hex_920[C]
- hex_920[i] = D
- # check_log(hex_920)
- return hex_920
- def initial(self, debug, hex_920):
- tmp_add = []
- tmp_hex = deepcopy(hex_920)
- for i in range(self.length):
- A = debug[i]
- if not tmp_add:
- B = 0
- else:
- B = tmp_add[-1]
- C = hex_920[i + 1] + B
- while C >= 0x100:
- C = C - 0x100
- tmp_add.append(C)
- D = tmp_hex[C]
- tmp_hex[i + 1] = D
- E = D + D
- while E >= 0x100:
- E = E - 0x100
- F = tmp_hex[E]
- G = A ^ F
- debug[i] = G
- return debug
- def calculate(self, debug):
- for i in range(self.length):
- A = debug[i]
- B = reverse(A)
- C = debug[(i + 1) % self.length]
- D = B ^ C
- E = RBIT(D)
- F = E ^ self.length
- G = ~F
- while G < 0:
- G += 0x100000000
- H = int(hex(G)[-2:], 16)
- debug[i] = H
- return debug
- def main(self):
- result = ''
- for item in self.calculate(self.initial(self.debug, self.addr_920())):
- result = result + hex_string(item)
- return '0401{}{}0001{}'.format(hex_string(self.hex_510[7]), hex_string(self.hex_510[3]), result)
- def X_Gorgon(url, data, cookie = '', model='utf-8'):
- gorgon = []
- Khronos = hex(int(time()))[2:]
- url_md5 = md5(bytearray(url, 'utf-8')).hexdigest()
- for i in range(0, 4):
- gorgon.append(int(url_md5[2 * i: 2 * i + 2], 16))
- if data:
- if model == 'utf-8':
- data_md5 = md5(bytearray(data, 'utf-8')).hexdigest()
- for i in range(0, 4):
- gorgon.append(int(data_md5[2 * i: 2 * i + 2], 16))
- elif model == 'octet':
- data_md5 = md5(data).hexdigest()
- for i in range(0, 4):
- gorgon.append(int(data_md5[2 * i: 2 * i + 2], 16))
- else:
- for i in range(0, 4):
- gorgon.append(0x0)
- if cookie:
- cookie_md5 = md5(bytearray(cookie, 'utf-8')).hexdigest()
- for i in range(0, 4):
- gorgon.append(int(cookie_md5[2 * i: 2 * i + 2], 16))
- else:
- for i in range(0, 4):
- gorgon.append(0x0)
- for i in range(0, 4):
- gorgon.append(0x0)
- for i in range(0, 4):
- gorgon.append(int(Khronos[2 * i: 2 * i + 2], 16))
- return {'X-Gorgon': XG(gorgon).main(), 'X-Khronos': str(int(Khronos, 16))}
- if __name__ == "__main__":
- url = 'os_api=22&device_type=OPPO%20R17%20Pro&ssmix=a&manifest_version_code=110901&dpi=320&uuid=866174816715680&app_name=aweme&version_name=11.9.0&ts=1606715214&cpu_support64=false&storage_type=0&app_type=normal&ac=wifi&host_abi=armeabi-v7a&update_version_code=11909900&channel=lephone_1128_1&_rticket=1606715214501&device_platform=android&iid=3606038575327836&version_code=110900&mac_address=7C%3AB2%3A7D%3A15%3A68%3A46&cdid=f84bf379-019e-44a6-8426-0fd2bc3f8278&openudid=764841d6f5377125&device_id=3579659689950456&resolution=1080*1920&os_version=5.1.1&language=zh&device_brand=OPPO&aid=1128&mcc_mnc=46007'
- data = 'promotion_id=3448966412629092080&product_id=3448963960152394964&aweme_id=0&author_id=1626898700712935&meta_param=%7B%22enter_from%22%3A%22live%22%2C%22live_room_id%22%3A%226900732511879039758%22%2C%22entrance_info%22%3A%22%7B%5C%22_param_live_platform%5C%22%3A%5C%22live%5C%22%2C%5C%22action_type%5C%22%3A%5C%22click%5C%22%2C%5C%22anchor_id%5C%22%3A%5C%221626898700712935%5C%22%2C%5C%22carrier_source%5C%22%3A%5C%22homepage_hot%5C%22%2C%5C%22carrier_type%5C%22%3A%5C%22live_list_card%5C%22%2C%5C%22category_name%5C%22%3A%5C%22homepage_hot_temai_video_head%5C%22%2C%5C%22ecom_group_type%5C%22%3A%5C%22live%5C%22%2C%5C%22enter_from%5C%22%3A%5C%22live%5C%22%2C%5C%22enter_from_merge%5C%22%3A%5C%22homepage_hot%5C%22%2C%5C%22enter_method%5C%22%3A%5C%22video_head%5C%22%2C%5C%22follow_status%5C%22%3A%5C%220%5C%22%2C%5C%22group_id%5C%22%3A%5C%226900356917323959567%5C%22%2C%5C%22live_id%5C%22%3A1%2C%5C%22product_activity_type%5C%22%3A%5C%22nonactivity%5C%22%2C%5C%22request_id%5C%22%3A%5C%22202011301345510101980821034009F2B6%5C%22%2C%5C%22room_id%5C%22%3A%5C%226900732511879039758%5C%22%2C%5C%22sdk_version%5C%22%3A%5C%221600%5C%22%2C%5C%22source_method%5C%22%3A%5C%22video_head%5C%22%7D%22%7D&enter_from=live'
- cookie = ''
- res = X_Gorgon(url, data, cookie)
- print(res)
|