Skip to content

Commit 5b964fc

Browse files
committed
Improve logging
1 parent 61cf149 commit 5b964fc

File tree

2 files changed

+8
-161
lines changed

2 files changed

+8
-161
lines changed

.gitignore

Lines changed: 0 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -152,165 +152,6 @@ dmypy.json
152152
# Cython debug symbols
153153
cython_debug/
154154

155-
# PyCharm
156-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158-
# and can be added to the global gitignore or merged into this file. For a more nuclear
159-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
#.idea/# Byte-compiled / optimized / DLL files
161-
__pycache__/
162-
*.py[cod]
163-
*$py.class
164-
165-
# C extensions
166-
*.so
167-
168-
# Distribution / packaging
169-
.Python
170-
build/
171-
develop-eggs/
172-
dist/
173-
downloads/
174-
eggs/
175-
.eggs/
176-
lib/
177-
lib64/
178-
parts/
179-
sdist/
180-
var/
181-
wheels/
182-
share/python-wheels/
183-
*.egg-info/
184-
.installed.cfg
185-
*.egg
186-
MANIFEST
187-
188-
# PyInstaller
189-
# Usually these files are written by a python script from a template
190-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
191-
*.manifest
192-
*.spec
193-
194-
# Installer logs
195-
pip-log.txt
196-
pip-delete-this-directory.txt
197-
198-
# Unit test / coverage reports
199-
htmlcov/
200-
.tox/
201-
.nox/
202-
.coverage
203-
.coverage.*
204-
.cache
205-
nosetests.xml
206-
coverage.xml
207-
*.cover
208-
*.py,cover
209-
.hypothesis/
210-
.pytest_cache/
211-
cover/
212-
213-
# Translations
214-
*.mo
215-
*.pot
216-
217-
# Django stuff:
218-
*.log
219-
local_settings.py
220-
db.sqlite3
221-
db.sqlite3-journal
222-
223-
# Flask stuff:
224-
instance/
225-
.webassets-cache
226-
227-
# Scrapy stuff:
228-
.scrapy
229-
230-
# Sphinx documentation
231-
docs/_build/
232-
233-
# PyBuilder
234-
.pybuilder/
235-
target/
236-
237-
# Jupyter Notebook
238-
.ipynb_checkpoints
239-
240-
# IPython
241-
profile_default/
242-
ipython_config.py
243-
244-
# pyenv
245-
# For a library or package, you might want to ignore these files since the code is
246-
# intended to run in multiple environments; otherwise, check them in:
247-
# .python-version
248-
249-
# pipenv
250-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
251-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
252-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
253-
# install all needed dependencies.
254-
#Pipfile.lock
255-
256-
# poetry
257-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
258-
# This is especially recommended for binary packages to ensure reproducibility, and is more
259-
# commonly ignored for libraries.
260-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
261-
#poetry.lock
262-
263-
# pdm
264-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
265-
#pdm.lock
266-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
267-
# in version control.
268-
# https://pdm.fming.dev/#use-with-ide
269-
.pdm.toml
270-
271-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
272-
__pypackages__/
273-
274-
# Celery stuff
275-
celerybeat-schedule
276-
celerybeat.pid
277-
278-
# SageMath parsed files
279-
*.sage.py
280-
281-
# Environments
282-
.env
283-
.venv
284-
env/
285-
venv/
286-
ENV/
287-
env.bak/
288-
venv.bak/
289-
290-
# Spyder project settings
291-
.spyderproject
292-
.spyproject
293-
294-
# Rope project settings
295-
.ropeproject
296-
297-
# mkdocs documentation
298-
/site
299-
300-
# mypy
301-
.mypy_cache/
302-
.dmypy.json
303-
dmypy.json
304-
305-
# Pyre type checker
306-
.pyre/
307-
308-
# pytype static type analyzer
309-
.pytype/
310-
311-
# Cython debug symbols
312-
cython_debug/
313-
314155
# PyCharm
315156
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
316157
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore

keyhunter.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def find_keys(filename: str | Path) -> set[str]:
6767
"""
6868

6969
keys = set()
70+
key_count = 0
7071
with open(filename, "rb") as f:
7172
logger.info(f"Opened file: {filename}")
7273

@@ -80,11 +81,16 @@ def find_keys(filename: str | Path) -> set[str]:
8081
key_offset = pos + MAGIC_BYTES_LEN
8182
key_data = b"\x80" + block_bytes[key_offset : key_offset + 32] # noqa: E203
8283
priv_key_wif = encode_base58_check(key_data)
84+
is_new_key = priv_key_wif not in keys
85+
key_count += 1
8386
keys.add(priv_key_wif)
8487
global_offset = f.tell() - len(block_bytes) + key_offset
88+
8589
logger.info(
86-
f"Found key at offset {global_offset:,} = 0x{global_offset:_x} "
87-
f"(using magic bytes {magic_bytes.hex()}): {priv_key_wif}"
90+
f"Found {('new key' if is_new_key else 'key again')} "
91+
f"at offset {global_offset:,} = 0x{global_offset:_x} "
92+
f"(using magic bytes {magic_bytes.hex()}): {priv_key_wif} "
93+
f"({key_count:,} keys total, {len(keys):,} unique keys"
8894
)
8995
pos += 1
9096

0 commit comments

Comments
 (0)