Advertisement
caffeinatedmike

Russian Nesting Doll

Apr 23rd, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1.     def decode(self, resp):
  2.         listRe = re.compile('var\s+\w{3}\s+=\s+(\[.+?\]);',re.DOTALL)
  3.         minusRe = re.compile('\s+\-\s+(\d{,10})\);')
  4.         iframeRe = re.compile('<iframe.+?src=["\'](\S{10,})["\']')
  5.         packerRe = re.compile('(eval\(function\(p,a,c,k,e,(?:r|d).*)')
  6.         clapprRe = re.compile('new\s+Clappr\.Player\(\{\s*?source:\s*?["\'](.+?)["\']')
  7.        
  8.         hParse = HTMLParser()
  9.         jsList = listRe.findall(resp)[0]
  10.         minusValue = int(minusRe.findall(resp)[0])
  11.         valuesList = eval(jsList)
  12.  
  13.         iframePage = hParse.unescape(unquote(''.join(map(chr,
  14.                                      [int(''.join([x for x in
  15.                                      base64.b64decode(valueInList)
  16.                                      if x.isdigit()])) - minusValue
  17.                                      for valueInList in valuesList]))))
  18.         iframe_url = iframeRe.findall(iframePage)[0]
  19.         packerPage = requests.get(iframe_url).text
  20.         packed = packerRe.findall(packerPage)[0]
  21.         unpacked = jsunpack.unpack(packed)
  22.         clapprStream = clapprRe.findall(unpacked)[0]
  23.        
  24.         headers = '|Referer=%s&User-Agent=%s' % (iframe_url, ua_string)
  25.         return clapprStream + headers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement