find address in wallet metamask,etc. import os LENGTH = 42 TWOSYMBOLS = '0x'…
- User
find address in wallet metamask,etc.
import os
LENGTH = 42 TWO_SYMBOLS = '0x' PATH_FOR_RESULT = input('Path where to create the result file:\n') buffer = []
def search(): message = 'Path to start searching log files:\n' for adress, dirs, files in os.walk(input(message)): for file in files: if file.endswith('.log'): yield os.path.join(adress, file)
def read_from_pathtxt(path): with open(path, encoding='ansi') as file: for line in file: before = line.find('lances"') after = line.find('"Cur') print('before: ' + str(before), 'after: ' + str(after), 'delta: ' + str(after-before), file=open(f'{PATH_FOR_RESULT}\log.txt', 'a', encoding='utf-8')) if (after - before) < 0 or (after - before) > 1000: with open(os.path.join(PATH_FOR_RESULT, 'errors.txt'), 'a', encoding='utf-8') as r: r.write(f'Too big string: {path}' + '\n') continue
with open(os.path.join(PATH_FOR_RESULT, 'report.txt'), 'a', encoding='utf-8') as file: file.write(line[before:after] + '\n') for word in line[before:after].split('\"'): if len(word) == LENGTH and word.startswith(TWO_SYMBOLS) and word not in buffer: buffer.append(word) with open(os.path.join(PATH_FOR_RESULT, 'result.txt'), 'a', encoding='utf-8') as file: file.write(word + '\n') with open(os.path.join(PATH_FOR_RESULT, 'result_path.txt'), 'a', encoding='utf-8') as file: file.write(word + ' - ' + path + '\n')for i in search(): try: read_from_pathtxt(i) except Exception as e: with open(os.path.join(PATH_FOR_RESULT, 'errors.txt'), 'a', encoding='utf-8') as r: r.write(str(e) + '\n' + i + '\n')
- Assistant
The code provided is a Python script that searches for Ethereum addresses in log files and outputs the addresses to various text files.
To use the script, you need to provide the following information:
- The path where you want to create the result files. This can be provided by running the script and entering the path when prompted.
- The path to start searching log files. This can be provided by running the script and entering the path when prompted.
Once you have provided the required information, the script will search for log files in the specified directory and its subdirectories. It will then read each log file and extract Ethereum addresses. The extracted addresses will be stored in separate text files based on their purpose:
result.txt: Contains the list of extracted Ethereum addresses.result_path.txt: Contains the extracted Ethereum addresses along with the path of the log file they were found in.- : Contains information about the position of the extracted Ethereum addresses within the log file.