Advertisement
havalqandiel

asaaaaw

Nov 3rd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. import urllib, urllib2, re, requests, cookielib, string
  2.  
  3.  
  4.  
  5. """Unpacker for Dean Edward's p.a.c.k.e.r"""
  6.  
  7.  
  8. PRIORITY = 1
  9.  
  10. def detect(source):
  11. """Detects whether `source` is P.A.C.K.E.R. coded."""
  12. return source.replace(' ', '').startswith('eval(function(p,a,c,k,e,')
  13.  
  14. def unpack(source):
  15. """Unpacks P.A.C.K.E.R. packed js code."""
  16. payload, symtab, radix, count = _filterargs(source)
  17.  
  18. if count != len(symtab):
  19. raise UnpackingError('Malformed p.a.c.k.e.r. symtab.')
  20.  
  21. try:
  22. unbase = Unbaser(radix)
  23. except TypeError:
  24. raise UnpackingError('Unknown p.a.c.k.e.r. encoding.')
  25.  
  26. def lookup(match):
  27. """Look up symbols in the synthetic symtab."""
  28. word = match.group(0)
  29. return symtab[unbase(word)] or word
  30.  
  31. source = re.sub(r'\b\w+\b', lookup, payload)
  32. return _replacestrings(source)
  33.  
  34. def _filterargs(source):
  35. """Juice from a source file the four args needed by decoder."""
  36. juicers = [ (r"}\('(.*)', *(\d+), *(\d+), *'(.*)'\.split\('\|'\), *(\d+), *(.*)\)\)"),
  37. (r"}\('(.*)', *(\d+), *(\d+), *'(.*)'\.split\('\|'\)"),
  38. ]
  39. for juicer in juicers:
  40. args = re.search(juicer, source, re.DOTALL)
  41. if args:
  42. a = args.groups()
  43. try:
  44. return a[0], a[3].split('|'), int(a[1]), int(a[2])
  45. except ValueError:
  46. raise UnpackingError('Corrupted p.a.c.k.e.r. data.')
  47.  
  48. # could not find a satisfying regex
  49. raise UnpackingError('Could not make sense of p.a.c.k.e.r data (unexpected code structure)')
  50.  
  51.  
  52.  
  53. def _replacestrings(source):
  54. """Strip string lookup table (list) and replace values in source."""
  55. match = re.search(r'var *(_\w+)\=\["(.*?)"\];', source, re.DOTALL)
  56.  
  57. if match:
  58. varname, strings = match.groups()
  59. startpoint = len(match.group(0))
  60. lookup = strings.split('","')
  61. variable = '%s[%%d]' % varname
  62. for index, value in enumerate(lookup):
  63. source = source.replace(variable % index, '"%s"' % value)
  64. return source[startpoint:]
  65. return source
  66.  
  67.  
  68. class Unbaser(object):
  69. """Functor for a given base. Will efficiently convert
  70. strings to natural numbers."""
  71. ALPHABET = {
  72. 53 : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ',
  73. 59 : '0123456789abcdefghijklmnopqrstuvwABCDEFGHIJKLMNOPQRSTUVWXYZ',
  74. 62 : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
  75. 95 : (' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  76. '[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
  77. }
  78.  
  79. def __init__(self, base):
  80. self.base = base
  81.  
  82. # If base can be handled by int() builtin, let it do it for us
  83. if 2 <= base <= 36:
  84. self.unbase = lambda string: int(string, base)
  85. else:
  86. # Build conversion dictionary cache
  87. try:
  88. self.dictionary = dict((cipher, index) for
  89. index, cipher in enumerate(self.ALPHABET[base]))
  90. except KeyError:
  91. raise TypeError('Unsupported base encoding.')
  92.  
  93. self.unbase = self._dictunbaser
  94.  
  95. def __call__(self, string):
  96. return self.unbase(string)
  97.  
  98. def _dictunbaser(self, string):
  99. """Decodes a value to an integer."""
  100. ret = 0
  101. for index, cipher in enumerate(string[::-1]):
  102. ret += (self.base ** index) * self.dictionary[cipher]
  103. return ret
  104.  
  105.  
  106. url = 'http://oklivetv.com/eurosport-france-live/'
  107.  
  108.  
  109. def oklivetv_com(url):
  110. agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36'
  111. referer = 'http://oklivetv.com/'
  112. headers = {'Referer': referer,'User-Agent': agent}
  113. if not '/xplay.php' in url:
  114. bron = requests.get(url, headers=headers); b = bron.text ; #print b
  115. url = re.findall("<iframe style=.+src='(.*?)'", b)[0]; #print url
  116. bron = requests.get(url, headers=headers); b = bron.text ;# print b
  117. eval_pck = re.findall('(?=player69|container".\s.div id=").*?(eval.*)', b)[0] ; #print eval_pck
  118. unpackeudtext = unpack(eval_pck);# print unpackeudtext
  119. url2 = re.findall('(?=streamURL|file).*?"(.*?)"', unpackeudtext)[0]; #print url2
  120. ref = re.findall('plugin_hls:"(.*?)"', unpackeudtext)[0]; #print ref
  121. #plugin_hls:"http://oklivetv.com/xplay/swf/flashlsOSMF.swf"
  122. media_url = url2 + '|Referer=' + ref + '&User-Agent=' + agent
  123. return media_url
  124.  
  125. print oklivetv_com(url)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement