Hirdetés

Új hozzászólás Aktív témák

  • Hege1234

    addikt

    Sziasztok!

    hogyan tudnék kilépni ebből a loopból?

    a firefox log fájljában kerestetek 10 token-t

    a fájlok nem egyből kerülnek bele a mappába, hanem folyamatosan
    és minden 100MB adat után csinál egy új fájlt
    log.txt.moz_log.0
    log.txt.moz_log.1
    log.txt.moz_log.2

    így elképzelhető, hogy valamelyik token majd csak a 2. vagy 3. fájlban lesz megtalálható..

    script:

    import re
    import time
    import glob

    log_file_pattern = ".\\firefox-log\\log.txt.moz_log.*"

    tokens_to_find = 10
    tokens_found = 0
    processed_files = set()

    while tokens_found < tokens_to_find:
    log_files = glob.glob(log_file_pattern)

    for file_path in log_files:
    cutted_file_path = re.findall(r'\\([^\\]+)$', file_path)[0].strip()
    if file_path not in processed_files:
    try:
    with open(file_path, 'r') as file:
    tdata = file.read()

    app_key = re.findall(r"header=.app_key..value=.(.*)..merge=0]", tdata)[0].strip()
    azukiapp = re.findall(r"E/nsHttp...AzukiApp:.(.*)", tdata)[0].strip()
    azukiststoken = re.findall(r"E/nsHttp...AzukiSTSToken:.(.*)", tdata)[0].strip()
    natcho = re.findall(r"E/nsHttp.uri=.*natco_key=(.*)&device_type=WEB&channel_number=", tdata)[0].strip()
    Device_Id = re.findall(r"header=.Device-Id..value=.(.*)..merge=0]", tdata)[0].strip()
    bff_token = re.findall(r"header=.bff_token..value=.(.*)..merge=0]", tdata)[0].strip()
    sess_id = re.findall(r"https://.*wv_getlicense.*session_uid=(.*?)&", tdata)[0].strip()
    acc_ount = re.findall(r"E/nsHttp.uri=.*user_token=(.*)&session", tdata)[0].strip()

    try:
    azudrm = re.findall(r'D/n.*?AzukiApp.*?[^.].*?[^.]\"AzukiDRM\" value=\"(.*?)\"', tdata)[0].strip()
    except:
    azudrm = re.findall(r"E/nsHttp...AzukiApp:..*.*[^?].*[^?.].*[^?.]E/nsHttp...AzukiDRM:.(.*)", tdata)[0].strip()

    get_lic = re.findall(r"E/nsHttp uri=(.*wv_getlicense.*token.*)", tdata)[0].strip()

    print(f"Token found in {cutted_file_path}: app_key: {app_key}\n")
    print(f"Token found in {cutted_file_path}: azukiapp: {azukiapp}\n")
    print(f"Token found in {cutted_file_path}: azukiststoken: {azukiststoken}\n")
    print(f"Token found in {cutted_file_path}: natcho: {natcho}\n")
    print(f"Token found in {cutted_file_path}: Device_Id: {Device_Id}\n")
    print(f"Token found in {cutted_file_path}: bff_token: {bff_token}\n")
    print(f"Token found in {cutted_file_path}: sess_id: {sess_id}\n")
    print(f"Token found in {cutted_file_path}: acc_ount: {acc_ount}\n")
    print(f"Token found in {cutted_file_path}: azudrm: {azudrm}\n")
    print(f"Token found in {cutted_file_path}: get_lic: {get_lic}\n")

    tokens_found += 1

    processed_files.add(file_path)

    except (IndexError, FileNotFoundError):
    print(f"Token not found in {cutted_file_path}. Waiting for the next attempt.")
    except Exception as e:
    print(f"Error processing {cutted_file_path}: {e}")

    time.sleep(2)

    print(f"All tokens found! Press Enter to exit.")
    stopsdf = input('\stop now!')

    még a loopban lévő print:

    Token not found in log.txt.moz_log.0. Waiting for the next attempt.
    Token not found in log.txt.moz_log.0. Waiting for the next attempt.
    Token not found in log.txt.moz_log.0. Waiting for the next attempt.
    Token found in log.txt.moz_log.0: app_key: ex****k

    Token found in log.txt.moz_log.0: azukiapp: 3**

    Token found in log.txt.moz_log.0: azukiststoken: AuthTok****

    Token found in log.txt.moz_log.0: natcho: T****0P

    Token found in log.txt.moz_log.0: Device_Id: 95d6****a4

    Token found in log.txt.moz_log.0: bff_token: AuthTok****

    Token found in log.txt.moz_log.0: sess_id: e4ab****f91

    Token found in log.txt.moz_log.0: acc_ount: 100****001

    Token found in log.txt.moz_log.0: azudrm: bd****C0=

    Token found in log.txt.moz_log.0: get_lic: htt****lse

    majd miután a log.txt.moz_log.0 betelt és létrejön a log.txt.moz_log.1 a mappában
    elkezdi azt is csekkolni több száz sort nem teszek be róla, de az így néz ki:

    Token not found in log.txt.moz_log.1. Waiting for the next attempt.
    .
    .
    Token not found in log.txt.moz_log.1. Waiting for the next attempt.
    Token not found in log.txt.moz_log.1. Waiting for the next attempt.
    .
    .
    Token not found in log.txt.moz_log.1. Waiting for the next attempt.
    Token not found in log.txt.moz_log.2. Waiting for the next attempt.
    Token not found in log.txt.moz_log.3. Waiting for the next attempt.
    Token not found in log.txt.moz_log.1. Waiting for the next attempt.

    azt nem értem, hogy a loop-ból miért nem tud kilépni amikor a mostani helyzetben már az 1. fájlban megtalál minden token-t amit kerestetek és a print jelzi is.. :F

    lehet kellene valahova egy break és az, hogy megadom hogy 10 tokent találjon meg az nem elég a kilépéshez?
    vagy más ok miatt mehet mégis a következő fájlra?

Új hozzászólás Aktív témák