Advertisement
xtekky_

Untitled

Aug 3rd, 2022
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1.  
  2. import time, json, hashlib
  3.  
  4. class Xgorgon:
  5. def __init__(self, params: str, data: str, cookies: str) -> None:
  6.  
  7. self.params = params
  8. self.data = data
  9. self.cookies = cookies
  10.  
  11. def hash(self, data: str) -> str:
  12. _hash = str(
  13. hashlib.md5(
  14. data.encode()
  15. ).hexdigest()
  16. )
  17.  
  18. return _hash
  19.  
  20. def get_base_string(self) -> str:
  21. base_str = self.hash(self.params)
  22. base_str = (
  23. base_str + self.hash(self.data)
  24. if self.data
  25. else base_str + str(
  26. "0"
  27. *
  28. 32
  29. )
  30. )
  31. base_str = (
  32. base_str + self.hash(self.cookies)
  33. if self.cookies
  34. else base_str + str(
  35. "0"
  36. *
  37. 32
  38. )
  39. )
  40.  
  41. return base_str
  42.  
  43. def get_value(self) -> json:
  44. base_str = self.get_base_string()
  45.  
  46. return self.encrypt(base_str)
  47.  
  48. def encrypt(self, data: str) -> json:
  49. unix = int(time.time())
  50. len = 0x14
  51. key =[0xDF ,0x77 ,0xB9 ,0x40 ,0xB9 ,0x9B ,0x84 ,0x83 ,0xD1 ,0xB9 ,0xCB ,0xD1 ,0xF7 ,0xC2 ,0xB9 ,0x85 ,0xC3 ,0xD0 ,0xFB ,0xC3 ,]
  52.  
  53. param_list = []
  54.  
  55. for i in range(0, 12, 4):
  56. temp = data[8 * i : 8 * (i + 1)]
  57. for j in range(4):
  58. H = int(temp[j * 2 : (j + 1) * 2], 16)
  59. param_list.append(H)
  60.  
  61. param_list.extend(
  62. [
  63. 0x0, 0x6, 0xB, 0x1C
  64. ]
  65. )
  66.  
  67. H = int(
  68. hex(
  69. unix
  70. )
  71. , 16
  72. )
  73.  
  74. param_list.append(
  75. (
  76. H & 0xFF000000
  77. )
  78. >> 24
  79. )
  80. param_list.append(
  81. (
  82. H & 0x00FF0000
  83. )
  84. >> 16
  85. )
  86. param_list.append(
  87. (
  88. H & 0x0000FF00
  89. )
  90. >> 8
  91. )
  92. param_list.append(
  93. (
  94. H & 0x000000FF
  95. )
  96. >> 0
  97. )
  98.  
  99. eor_result_list = []
  100.  
  101. for A, B in zip(param_list, key):
  102. eor_result_list.append(A ^ B)
  103.  
  104. for i in range(len):
  105.  
  106. C = self.reverse(eor_result_list[i])
  107. D = eor_result_list[
  108. (
  109. i + 1
  110. )
  111. % len
  112. ]
  113. E = C ^ D
  114.  
  115. F = self.rbit_algorithm(E)
  116. H = (
  117. (
  118. F ^ 0xFFFFFFFF
  119. )
  120. ^ len
  121. ) & 0xFF
  122. eor_result_list[i] = H
  123.  
  124. result = ""
  125. for param in eor_result_list:
  126. result += self.hex_string(param)
  127.  
  128. return {
  129. "X-Gorgon": (
  130. "0404b0d30000"
  131. + result
  132. ),
  133. "X-Khronos": str(unix)
  134. }
  135.  
  136. def rbit_algorithm(self, num):
  137. result = ""
  138. tmp_string = bin(num)[2:]
  139.  
  140. while len(tmp_string) < 8:
  141. tmp_string = (
  142. "0"
  143. + tmp_string
  144. )
  145.  
  146. for i in range(0, 8):
  147. result = (
  148. result
  149. + tmp_string[
  150. 7 - i
  151. ]
  152. )
  153.  
  154. return int(result, 2)
  155.  
  156. def hex_string(self, num):
  157. tmp_string = hex(num)[2:]
  158.  
  159. if len(tmp_string) < 2:
  160. tmp_string = "0" + tmp_string
  161.  
  162. return tmp_string
  163.  
  164. def reverse(self, num):
  165. tmp_string = self.hex_string(num)
  166.  
  167. return int(tmp_string[1:] + tmp_string[:1], 16)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement