Last active
December 8, 2016 01:31
-
-
Save alochym01/4c8d3e9793a8faef2fae1c7e61c36ca5 to your computer and use it in GitHub Desktop.
code for Mr Thaitnt :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import urllib | |
import re | |
import json | |
from base64 import b64decode, b64encode | |
from Crypto.Cipher import AES | |
from Crypto.Hash import MD5 | |
# We need 32 bytes for the AES key, and 16 bytes for the IV | |
def openssl_kdf(req, secret, salt): | |
prev = '' | |
while req > 0: | |
prev = MD5.new(prev+secret+salt).digest() | |
req -= 16 | |
yield prev | |
def xsearch(pattern,string,group=1,flags=0,result=''): | |
try: | |
s = re.search(pattern,string,flags).group(group) | |
except: | |
s = result | |
return s | |
def xread(url,hd={'User-Agent':'Mozilla/5.0'},data=None): | |
req = urllib2.Request(url,data,hd) | |
try: | |
res = urllib2.urlopen(req, timeout=20) | |
content = res.read() | |
res.close() | |
except: | |
content = '' | |
return content | |
def getLink(url): | |
b = xread(url) | |
# href = xsearch('src="([^<]*?episodeinfo.+?)"',b).replace('javascript','json') | |
href = xsearch('src="([^<]*?episodeinfo.+?)"', b) | |
# get the key to decode link | |
secret = 'PhimMoi.Net://%s' % xsearch('&requestid=(\d+)&', href) | |
# call api to get the hash links | |
filminfo = xread(href) | |
try: | |
links = {} | |
test = xsearch('"medias":\[(.*)\]', filminfo).replace('},{', '}alochym{') | |
# normal data into json object | |
for i in test.split('alochym'): | |
temp = json.loads(i) | |
links.update({temp.get('resolution'): temp.get('url')}) | |
# sort the json object and get highest profile | |
encoded_url = links[sorted(links)[-1]] | |
# try to decrypt url link of film - starting decode link | |
encrypted = b64decode(encoded_url) | |
salt = encrypted[8:16] | |
data = encrypted[16:] | |
math = ''.join([ x for x in openssl_kdf(32+16, secret, salt) ]) | |
key = math[0:32] | |
iv = math[32:48] | |
dec = AES.new(key, AES.MODE_CBC, iv) | |
# decrypt the link | |
clear = dec.decrypt(data) | |
# ending decode link | |
# replace an unused *ciphertext* | |
link = urllib.unquote_plus(clear).replace('\x04', '') | |
except Exception as e: | |
print str(e) | |
link = '' | |
pass | |
return link | |
print getLink('http://www.phimmoi.net/phim/hitler-ac-quy-troi-day-4628/xem-phim.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment