Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib, urllib2, re, requests, cookielib, string
- """Unpacker for Dean Edward's p.a.c.k.e.r"""
- PRIORITY = 1
- def detect(source):
- """Detects whether `source` is P.A.C.K.E.R. coded."""
- return source.replace(' ', '').startswith('eval(function(p,a,c,k,e,')
- def unpack(source):
- """Unpacks P.A.C.K.E.R. packed js code."""
- payload, symtab, radix, count = _filterargs(source)
- if count != len(symtab):
- raise UnpackingError('Malformed p.a.c.k.e.r. symtab.')
- try:
- unbase = Unbaser(radix)
- except TypeError:
- raise UnpackingError('Unknown p.a.c.k.e.r. encoding.')
- def lookup(match):
- """Look up symbols in the synthetic symtab."""
- word = match.group(0)
- return symtab[unbase(word)] or word
- source = re.sub(r'\b\w+\b', lookup, payload)
- return _replacestrings(source)
- def _filterargs(source):
- """Juice from a source file the four args needed by decoder."""
- juicers = [ (r"}\('(.*)', *(\d+), *(\d+), *'(.*)'\.split\('\|'\), *(\d+), *(.*)\)\)"),
- (r"}\('(.*)', *(\d+), *(\d+), *'(.*)'\.split\('\|'\)"),
- ]
- for juicer in juicers:
- args = re.search(juicer, source, re.DOTALL)
- if args:
- a = args.groups()
- try:
- return a[0], a[3].split('|'), int(a[1]), int(a[2])
- except ValueError:
- raise UnpackingError('Corrupted p.a.c.k.e.r. data.')
- # could not find a satisfying regex
- raise UnpackingError('Could not make sense of p.a.c.k.e.r data (unexpected code structure)')
- def _replacestrings(source):
- """Strip string lookup table (list) and replace values in source."""
- match = re.search(r'var *(_\w+)\=\["(.*?)"\];', source, re.DOTALL)
- if match:
- varname, strings = match.groups()
- startpoint = len(match.group(0))
- lookup = strings.split('","')
- variable = '%s[%%d]' % varname
- for index, value in enumerate(lookup):
- source = source.replace(variable % index, '"%s"' % value)
- return source[startpoint:]
- return source
- class Unbaser(object):
- """Functor for a given base. Will efficiently convert
- strings to natural numbers."""
- ALPHABET = {
- 53 : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ',
- 59 : '0123456789abcdefghijklmnopqrstuvwABCDEFGHIJKLMNOPQRSTUVWXYZ',
- 62 : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
- 95 : (' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- '[\]^_`abcdefghijklmnopqrstuvwxyz{|}~')
- }
- def __init__(self, base):
- self.base = base
- # If base can be handled by int() builtin, let it do it for us
- if 2 <= base <= 36:
- self.unbase = lambda string: int(string, base)
- else:
- # Build conversion dictionary cache
- try:
- self.dictionary = dict((cipher, index) for
- index, cipher in enumerate(self.ALPHABET[base]))
- except KeyError:
- raise TypeError('Unsupported base encoding.')
- self.unbase = self._dictunbaser
- def __call__(self, string):
- return self.unbase(string)
- def _dictunbaser(self, string):
- """Decodes a value to an integer."""
- ret = 0
- for index, cipher in enumerate(string[::-1]):
- ret += (self.base ** index) * self.dictionary[cipher]
- return ret
- url = 'http://oklivetv.com/eurosport-france-live/'
- def oklivetv_com(url):
- agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36'
- referer = 'http://oklivetv.com/'
- headers = {'Referer': referer,'User-Agent': agent}
- if not '/xplay.php' in url:
- bron = requests.get(url, headers=headers); b = bron.text ; #print b
- url = re.findall("<iframe style=.+src='(.*?)'", b)[0]; #print url
- bron = requests.get(url, headers=headers); b = bron.text ;# print b
- eval_pck = re.findall('(?=player69|container".\s.div id=").*?(eval.*)', b)[0] ; #print eval_pck
- unpackeudtext = unpack(eval_pck);# print unpackeudtext
- url2 = re.findall('(?=streamURL|file).*?"(.*?)"', unpackeudtext)[0]; #print url2
- ref = re.findall('plugin_hls:"(.*?)"', unpackeudtext)[0]; #print ref
- #plugin_hls:"http://oklivetv.com/xplay/swf/flashlsOSMF.swf"
- media_url = url2 + '|Referer=' + ref + '&User-Agent=' + agent
- return media_url
- print oklivetv_com(url)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement