Example #1
0
def decrypt(data, password):
    try:
        decrypted_data = rncryptor.decrypt(data, password)
    except:
        print('Некорректный ввод')
        return False
    return decrypted_data
Example #2
0
 def notification_url(self):
     notification = (
         b'\x03\x01\x1f@c\xfd\xf4\xd6\xbb]\xbb\x93rY\xf1Dc\xaf\xf1\xe1\x14\xc2h'
         b'\xf1\xec$\xba\x04\xc9\x84\xc4Z\xe1\x8f\x19.,n\xc4EG.\xe1~\x93\x13\xf6h'
         b'\xbf\xb6J\xa9\xeb\xe8\x9b\xf9\xf9k\x9c\xef\xac\xf1>;\rs'
         b'\xcc\x9d\xaa\xf8\xd4\xaf\xd9\xf9P\x89\xf4\xa1\xe0[\x05I#\xe7rBb'
         b'\xcf\x0e\x13\x1e\xa7\xf8O\x92\x9b7.\x1c*\xf96`\x97\xe2B\xbd\x81\xe0\xf9\x99,'
         b'\xdc\xed\xcbJ\xbbN\x98\x87>E?n[\xde;\xef\xe7\xaf')
     return rncryptor.decrypt(notification, self._PASS)
Example #3
0
 def platform_dns(self):
     dns = (
         b'\x03\x01\xc2\x08U+\xef0z\x8f\xd3\xf6\xa2\xd4\xd5\xa5\x95\x80\xd3\xd7\xfa'
         b'\x88\xf9\xb6!\xb6\x05(\x19\x81\xb9^\xf5\xc1\x85\x10\xda\xc4>\xc5\x94\x87'
         b'\xed\xc5\xde$~*\xfa-\xe9=e\x944=\x01\x8cA\xf9is\xdf\x13d~\xadq/\xea\x1d"\xbb'
         b'\xa6\xad\xaf\xcd^H\xa8\x8eA\xde\x8d#\x11\xeeO\xf5\xbd%\xf8\x89\xdd\x966\x8a^'
         b'\x9f0Z#\x87\xdb\x15G\x1d\\\xe3\xc0\xbbO\x15_\xdc\xeb\x1b,`\rO\x83\xbb^\x1f\xbbl'
         b'\x94\r\xb4\xf7\xbf\xc0J\x88\x94\x06_p\xb5\xb7^\x88P,,`\xd2\xa2\tG'
         b'\xf4\xaa"\x9a\x7f\xbc>\xe8<\xffl')
     return rncryptor.decrypt(dns, self._PASS)
Example #4
0
def mainfunc(request):
    """ We use this function to check if show existe on db or no"""
    animes_list = []
    get_as_new_id = requests.get(f'https://arab-drama.me/api/drdash')
    as_new_id = (json.loads(get_as_new_id.content.decode()))
    for ix in as_new_id['Response']:
        anime_na = ix['drama_name']
        animes_list.append(anime_na)
    #return JsonResponse({"RES":animes_list})

    header = {
        'Client-Id': 'drama-android-app',
        'Client-Secret': '7befba6263cc14c90e2f1d6da2c5cf9b251bfbbd',
        'Accept': 'application/*+json',
        'Accept': 'application/vnd.drama-app-api.v1+json',
        'Connection': 'Keep-Alive',
        'Accept-Encoding': 'gzip',
        'User-Agent': 'okhttp/3.12.1'
    }

    req = requests.get(
        """https://drslayer.com/drama/public/drama-app-api/get-all-published-drama?json=%7B%22_offset%22%3A0%2C%22_limit%22%3A21%2C%22list_type%22%3A%22latest_updated_episode_new%22%7D&offset=0&list_type=latest_updated_episode_new&limit=40
                        """,
        headers=header)
    my_string = (json.loads(req.content.decode()))
    #return JsonResponse({"RES":str(req.text)})
    encrypted_data = my_string['result']
    #print (encrypted_data)
    password = b'9>E>VBa=X%;[5BX~=Q~K'  #b'9>E>VBa=X%;[5BX~=Q~K'
    data = base64.b64decode(encrypted_data)
    decrypted_data = rncryptor.decrypt(data, password)
    movie_info = json.loads(decrypted_data)
    #return JsonResponse({"RES":movie_info})
    anime_lastest = []

    for i in movie_info:
        anime_name = i['drama_name']
        if anime_name not in animes_list:
            i['anime_status_in_db'] = 'NOT FOUND'
            anime_lastest.append(i)
        else:
            i['anime_status_in_db'] = 'FOUND'
            anime_lastest.append(i)
    return render(request, 'main.html', {'anime_lastest': anime_lastest})
Example #5
0
def verify_request_encryption(request, redis_pool):
    """
    校验写接口,防止重复提交. True 为通过验证, False 为没有通过.
    :type request: django.http.HttpRequest
    :type redis_pool: redis.ConnectionPool
    :rtype: bool
    """
    encrypted_data = request.META.get(ENCRYPTION_KEY, '')
    # 如果加密数据为空, 则返回无效
    if is_blank(encrypted_data):
        return False, 'Empty data'

    # 解出加密数据,如果解数据出错,则返回无效
    try:
        data = base64.b64decode(encrypted_data)
        data = rncryptor.decrypt(data, ENCRYPTION_PKEY)
        timestamp, udid = data.split()
        timestamp = int(timestamp)
    except Exception as e:
        return False, 'Error data, {}'.format(e)

    # 验证时间, 如果当前时间比
    now_ts = int(time.time() * 1000)
    if now_ts > timestamp + ENCRYPTION_TIMEDELTA or now_ts < timestamp - ENCRYPTION_TIMEDELTA:
        return False, 'Invalid time, now={}, args={}, {}, date={}'.format(
            now_ts, timestamp, udid, encrypted_data)

    try:
        redis_db = redis.StrictRedis(connection_pool=redis_pool)
        key = '{}_{}'.format(udid, timestamp)
        if redis_db.exists(key):
            return False, 'Repeat request, now={}, args={}, {}, date={}'.format(
                now_ts, timestamp, udid, encrypted_data)

        redis_db.set(key, '1', px=ENCRYPTION_TIMEDELTA)
        return True, 'Success'
    except Exception as e:
        # 降级逻辑, REDIS 挂掉, 默认不进行校验.
        return True, 'Redis error, {}'.format(e)
def test_decryption_bad_data_should_raise_exception(data, password):
    with pytest.raises(rncryptor.DecryptionError):
        rncryptor.decrypt(data, password)
def test_encrypt_decrypt_functions_should_be_correct(data, password):
    encrypted_data = rncryptor.encrypt(data, password)
    decrypted_data = rncryptor.decrypt(encrypted_data, password)
    assert data == decrypted_data
Example #8
0
def test_encrypt_decrypt_functions_should_be_correct(data, password):
    encrypted_data = rncryptor.encrypt(data, password)
    decrypted_data = rncryptor.decrypt(encrypted_data, password)
    assert data == decrypted_data
def test_decryption_bad_data_should_raise_exception(data, password):
    with pytest.raises(rncryptor.DecryptionError):
        rncryptor.decrypt(data, password)
Example #10
0
def decrypt_decompress(settingsFile,passwd):
  hex_text = zlib.decompress(seb_open(settingsFile), zlib.MAX_WBITS | 16)
  decryptedCompXML = rncryptor.decrypt(hex_text[4:],passwd) 
  decompressedXML = zlib.decompress(decryptedCompXML, zlib.MAX_WBITS | 16)

  return decompressedXML
Example #11
0
def insert_new(request):
    header = {
        'Client-Id': 'drama-android-app',
        'Client-Secret': '7befba6263cc14c90e2f1d6da2c5cf9b251bfbbd',
        'Accept': 'application/*+json',
        'Accept': 'application/vnd.drama-app-api.v1+json',
        'Connection': 'Keep-Alive',
        'Accept-Encoding': 'gzip',
        'User-Agent': 'okhttp/3.12.1'
    }
    status = request.GET.get('status')
    drama_id = request.GET.get('id')
    if status == '0':
        insert_req = requests.get(
            f'https://drslayer.com/drama/public/drama-app-api/get-published-drama-info?drama_id={drama_id}',
            headers=header)
        #return JsonResponse({'data':(insert_req.text)})
        my_string = (json.loads(insert_req.content.decode()))
        #print (my_string)
        encrypted_data = my_string['result']
        password = b'9>E>VBa=X%;[5BX~=Q~K'
        data = base64.b64decode(encrypted_data)
        decrypted_data = rncryptor.decrypt(data, password)
        drama_info = json.loads(decrypted_data)

        # Drama_Info
        drama_id = drama_info['drama_id']
        drama_name = drama_info['drama_name']
        drama_type = drama_info['drama_type']
        drama_status = drama_info['drama_status']
        drama_featured = drama_info['drama_featured']
        drama_published = drama_info['drama_published']
        drama_country = drama_info['drama_country']
        drama_release_date = drama_info['drama_release_date']
        drama_description = drama_info['drama_description']
        drama_description = drama_description.replace("'", "").replace('"', '')
        drama_cover_image = drama_info['drama_cover_image']
        drama_genres = drama_info['drama_genres']
        drama_genre_ids = drama_info['drama_genre_ids']
        drama_inserted_at = drama_info['drama_inserted_at']
        drama_updated_at = drama_info['drama_updated_at']
        drama_cover_image_url = drama_info['drama_cover_image_url']
        is_ol4 = None
        ol4_str = None
        ol4_patt = None
        my_list = [
            drama_id, drama_name, drama_type, drama_status, drama_featured,
            drama_published, drama_country, drama_release_date,
            drama_description, drama_cover_image, drama_genres,
            drama_genre_ids, drama_inserted_at, drama_updated_at,
            drama_cover_image_url, is_ol4, ol4_str, ol4_patt
        ]

        drama_genres = f'{drama_country}, {drama_genres}'
        insert_query = (
            f"""INSERT INTO `a_shows`(`drama_id`, `drama_name`, `drama_score`, `drama_type`, `drama_status`, `drama_published`, `drama_featured`, `drama_country`, `drama_release_date`, `drama_description`, `drama_cover_image`, `drama_genre_ids`, `drama_genres`, `drama_updated_at`, `drama_inserted_at`, `drama_cover_image_url`, `is_ol4`, `ol4_str`, `ol4_patt`) VALUES ({drama_id},'{drama_name}',0,'{drama_type}','{drama_status}','{drama_published}','{drama_featured}','{drama_country}','{drama_release_date}','{drama_description}','{drama_cover_image}','{drama_genre_ids}','{drama_genres}','{drama_cover_image_url}','{drama_cover_image_url}','{drama_cover_image_url}', NULL, NULL, NULL);"""
        )

        insert_query = insert_query.replace("'None'", "NULL")
        drama_info['insert_q'] = insert_query

        my_info_dict = {'drama_info': drama_info}

        return render(request, 'insert.html', my_info_dict)
Example #12
0
def update(request):
    header = {
        'Client-Id': 'drama-android-app',
        'Client-Secret': '7befba6263cc14c90e2f1d6da2c5cf9b251bfbbd',
        'Accept': 'application/*+json',
        'Accept': 'application/vnd.drama-app-api.v1+json',
        'Connection': 'Keep-Alive',
        'Accept-Encoding': 'gzip',
        'User-Agent': 'okhttp/3.12.1'
    }

    drama_id = request.GET.get('id')
    drama_name = request.GET.get('name')

    get_as_new_id = requests.get(
        f'https://arab-drama.me/api/drdashep?sid={drama_id}')
    as_new_id = (json.loads(get_as_new_id.content.decode()))
    last_as_episode = as_new_id['Response']['episode_name']

    req_2 = requests.get(
        f'https://drslayer.com/drama/public/drama-app-api/get-published-drama-episodes?json={{"drama_id":"{drama_id}"}}'
    )
    my_string_2 = (json.loads(req_2.content.decode()))
    encrypted_data_2 = my_string_2['result']
    password = b'9>E>VBa=X%;[5BX~=Q~K'
    data_2 = base64.b64decode(encrypted_data_2)
    decrypted_data_2 = rncryptor.decrypt(data_2, password)
    drama_episodes = json.loads(decrypted_data_2)

    #return JsonResponse({"Response": len(drama_episodes['episodes'])})
    my_2 = []

    if len(drama_episodes['episodes']) > 8:
        rate_limit = len(drama_episodes['episodes']) - 2
    else:
        rate_limit = 0

    ep_list = []
    for episode in drama_episodes['episodes'][:]:
        my_dict = {}
        episode_id = episode['episode_id']
        episode_name = episode['episode_name']
        episode_number = episode['episode_number']
        episode_watched_history = episode['episode_watched_history']
        my_list_2 = [
            drama_id, drama_name, episode_id, episode_name, episode_number,
            episode_watched_history
        ]

        my_2.append(my_list_2)
        insert_query_2 = f"""INSERT INTO `b_episodes`(`drama_id`, `drama_name`, `episode_id`, `episode_name`, `episode_number`, `episode_watched_history`) VALUES ({drama_id},"{drama_name}",{episode_id},"{episode_name}",{episode_number},"{episode_watched_history}");"""

        object_json = '{' + (
            f'"drama_id":{drama_id},"episode_id":"{episode_id}"') + '}'
        # Request Episode Streaming Links
        time.sleep(0.1)
        req_3 = requests.get(
            f'https://drslayer.com/drama/public/drama-app-api/get-published-drama-episodes?json={object_json}',
            headers=header)
        my_string_3 = (json.loads(req_3.content.decode()))
        encrypted_data_3 = my_string_3['result']
        password = b'9>E>VBa=X%;[5BX~=Q~K'
        data_3 = base64.b64decode(encrypted_data_3)
        decrypted_data_3 = rncryptor.decrypt(data_3, password)
        stream_links = json.loads(decrypted_data_3)
        # Stream Links:
        stream_link = stream_links['episodes'][0]['episode_urls']
        for link in stream_link:
            if link['episode_server_name'] == 'CDN':
                mslayer = episode_id
                #print(mslayer)
            elif link['episode_server_name'] == 'multi':
                episode_url = link['episode_url']
                time.sleep(0.1)
                req_4 = requests.get(episode_url, headers=header)
                if req_4.text != 'not exist':
                    try:
                        multi_stream = (json.loads(req_4.content.decode()))
                        stream_url = "@@@".join(multi_stream)
                        episode_url = episode_url
                    except:
                        stream_url = ""
                        episode_url = ""
                else:
                    stream_url = ""
                    episode_url = ""
                #print(stream_url)
        insert_query_3 = f"""INSERT INTO `c_urls`(`G_id`, `drama_id`, `drama_name`, `episode_id`, `episode_name`, `episode_number`, `episode_url`, `stream_url`, `mslayer`, `backup`) VALUES (NULL,{drama_id},'{drama_name}',{episode_id},'{episode_name}','{episode_number}','{episode_url}','{stream_url}','{mslayer}',NULL);"""
        insert_query_2 = insert_query_2.replace('\\', '')
        insert_query_3 = insert_query_3.replace('\\', '')
        my_dict[episode_name] = f"{insert_query_2} {insert_query_3} "
        ep_list.append(my_dict)
        response_list = ep_list
    return render(request, 'update.html', {
        'response_list': ep_list,
        'last_add': last_as_episode
    })
Example #13
0
import zlib
import rncryptor

FILENAME = "SebCfgFile.seb"
PASSWORD = "******"

compressedFile = open(FILENAME, 'rb').read()
_bytes = zlib.decompress(compressedFile, zlib.MAX_WBITS | 16)

decryptedCompressedXML = rncryptor.decrypt(_bytes[4:], PASSWORD)
decompressedXML = zlib.decompress(decryptedCompressedXML, zlib.MAX_WBITS | 16)

writetoxml = open('seb-settings_enc.xml', 'wb')
writetoxml.write(bytes(decompressedXML))