Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 427

Metamask Ethereum Address Extractor From Logs - Python

by nakedpoet - 02 March, 2024 - 12:38 PM
This post is by a banned member (nakedpoet) - Unhide
nakedpoet  
Registered
23
Posts
7
Threads
2 Years of service
#1
Metamask Ethereum Address Extractor From Logs - Python
 
Code:
 
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')
This post is by a banned member (jijevo3002) - Unhide
18
Posts
0
Threads
#2
Ts

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)