Giter Club home page Giter Club logo

reverseprofanitytool's Introduction

ReverseProfanityTool

Reverse engineering tool for recovering private keys of addresses generated by https://github.com/johguse/profanity. The vulnerability is exaplained in detail in various blog [posts] (https://medium.com/amber-group/exploiting-the-profanity-flaw-e986576de7ab) (https://medium.com/@rebryk/how-to-hack-a-vanity-address-generated-with-profanity-ffad61ecacd2)

The vulnerability

The vanity tool uses 32bit random seed to generate 256bit starting private key. The seed space was found to be too small and thus vulnerable to attacks by abusing an elliptic curve property which allows to backtrack to the starting private key if the public key is available (see blog posts for detailed explanation).

Requirements

This program requires GPU with at least 4gb of memory, 150gb disk space and OpenCL installed (although it might just work with the included OpenCL.dll library).

The repo

This repository contains necessary code to recover private keys generated by Profanity. IT IS INTENDED FOR EDUCATIONAL PURPOSES ONLY AND SHOUD ONLY BE USED WITH EXPLICIT CONSENT OR ON SYSTEMS WHERE YOU HAVE BEEN AUTHORIZED TO DO SO.

The prerequisite files need to be generated first and they will take up about 150gb of disk space. The files are generated by running 2 Golang scripts and contain the necessary 4byte seed and the last 8bytes of the X coordinate of the corresponding public key. The process of generating the files can take up about a day (depending on the CPU).

Once you have the output.bin generated you can delete the other binary files.

Once the binary files are generated we can start the actually tool. First fill out the data in the config.json (etherscan and node RPC for public key recovery), if using ETH, ARB or POLYGON. Then input the target wallets or contract addresses in main.py on line 25/26 and run the code. The number of iterations on each GPU thread is set to 2000, original tool has no limitations so it can be set arbitrarily in src/tools.py on line 183.

TO RUN

Generate files: Windows: setup.bat Linux: setup.sh Run the tool: (using environment) python main.py

Disclaimer

This tool was developed after my own account was drained a few weeks ago and was only used to validate the vulnerability. The exploit was discovered in september 2022 so it is considered safe to open source since by now all vulnerable accounts have been either notified, recovered or drained.

The tool provided herein is intended for educational purposes only and should only be used with explicit consent or on systems where you have been authorized to do so. The creator of this tool does not condone illegal activities and will not be held responsible for misuse of the tool. It is the end user's responsibility to obey all applicable local, state, federal, and international laws. Any actions and/or activities related to the tool provided is solely your responsibility. Misuse of the tool can result in criminal charges brought against the persons in question.

The author of this software, its subsidiaries, and associates will not be held responsible in the event that any criminal charges be brought against any individuals misusing the tool to break the law.

THIS TOOL IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

reverseprofanitytool's People

Contributors

zigamr avatar

Stargazers

 avatar

Watchers

 avatar

reverseprofanitytool's Issues

sqlalchemy.exc.OperationalError

i've got error on this command prompt

D:\ReverseProfanityTool-main>python main.py
Device name: NVIDIA GeForce GT 730
Device type: ALL | GPU
Device memory: 4096.0 MB
Traceback (most recent call last):
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 145, in init
self._dbapi_connection = engine.raw_connection()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 3288, in raw_connection
return self.pool.connect()
^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 452, in connect
return _ConnectionFairy._checkout(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 1267, in _checkout
fairy = _ConnectionRecord.checkout(pool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 716, in checkout
rec = pool._do_get()
^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\impl.py", line 169, in _do_get
with util.safe_reraise():
File "C:\Python311\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit
raise exc_value.with_traceback(exc_tb)
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\impl.py", line 167, in _do_get
return self._create_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 393, in _create_connection
return _ConnectionRecord(self)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 678, in init
self.__connect()
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 902, in __connect
with util.safe_reraise():
File "C:\Python311\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit
raise exc_value.with_traceback(exc_tb)
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 898, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\create.py", line 637, in connect
return dialect.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\default.py", line 615, in connect
return self.loaded_dbapi.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: unable to open database file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\ReverseProfanityTool-main\main.py", line 16, in
prof = RevProfanity('ethereum')
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ReverseProfanityTool-main\src\tools.py", line 177, in init
self.Base.metadata.create_all(self.engine, checkfirst=True)
File "C:\Python311\Lib\site-packages\sqlalchemy\sql\schema.py", line 5792, in create_all
bind._run_ddl_visitor(
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 3238, in _run_ddl_visitor
with self.begin() as conn:
File "C:\Python311\Lib\contextlib.py", line 137, in enter
return next(self.gen)
^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 3228, in begin
with self.connect() as conn:
^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 3264, in connect
return self._connection_cls(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 147, in init
Connection._handle_dbapi_exception_noconnection(
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 2426, in _handle_dbapi_exception_noconnection
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 145, in init
self._dbapi_connection = engine.raw_connection()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\base.py", line 3288, in raw_connection
return self.pool.connect()
^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 452, in connect
return _ConnectionFairy._checkout(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 1267, in _checkout
fairy = _ConnectionRecord.checkout(pool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 716, in checkout
rec = pool._do_get()
^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\impl.py", line 169, in _do_get
with util.safe_reraise():
File "C:\Python311\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit
raise exc_value.with_traceback(exc_tb)
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\impl.py", line 167, in _do_get
return self._create_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 393, in _create_connection
return _ConnectionRecord(self)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 678, in init
self.__connect()
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 902, in __connect
with util.safe_reraise():
File "C:\Python311\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit
raise exc_value.with_traceback(exc_tb)
File "C:\Python311\Lib\site-packages\sqlalchemy\pool\base.py", line 898, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\create.py", line 637, in connect
return dialect.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\sqlalchemy\engine\default.py", line 615, in connect
return self.loaded_dbapi.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/20/e3q8)

using more that 1 GPU

How can I run in multiGPU?
In single GPU I set the PYOPENCL_CTX=0 but with 2 GPU, it first asks [0] <pyopencl.Platform 'NVIDIA CUDA
and then lists GPUs and I chose 0,1 but i see only 1 GPU is used (in nvidia-smi)

pyopencl error

I get this error after runnning 2 minutes on a RTX 3090
Traceback (most recent call last):
File "/root/ReverseProfanityTool/main.py", line 38, in
prof.run_kernel(addresses.address.to_list(), addresses.public_key.to_list())
File "/root/ReverseProfanityTool/src/tools.py", line 32, in wrapper
result = func(*args, **kwargs)
File "/root/ReverseProfanityTool/src/tools.py", line 543, in run_kernel
cl.enqueue_copy(self.queue, result_array, array_buf)
File "/usr/local/lib/python3.9/site-packages/pyopencl/init.py", line 2013, in enqueue_copy
return _cl._enqueue_read_buffer(queue, src, dest, **kwargs)
pyopencl._cl.RuntimeError: clEnqueueReadBuffer failed: OUT_OF_RESOURCES

pywin32 issues

pywin32 does not support by Mac OS can you update for Mac OS

ReverseProfanityTool-main % pip install pywin32
ERROR: Could not find a version that satisfies the requirement pywin32 (from versions: none)
ERROR: No matching distribution found for pywin32

Very strange error

python main.py
Device name: Intel(R) UHD Graphics 630
Device type: ALL | GPU
Device memory: 6491.91015625 MB
Device name: Intel(R) UHD Graphics 630
Device type: ALL | GPU
Device memory: 8114.888671875 MB
Device name: Microsoft Basic Render Driver
Device type: ALL | GPU
Device memory: 8114.888671875 MB
Device name: NVIDIA GeForce GTX 1060
Device type: ALL | GPU
Device memory: 6052.0 MB
Device name: GeForce GTX 1060
Device type: ALL | GPU
Device memory: 6144.0 MB
Choose platform:
[0] <pyopencl.Platform 'Intel(R) OpenCL HD Graphics' at 0x262e2209bc0>
[1] <pyopencl.Platform 'OpenCLOn12' at 0x262e1c58bc0>
[2] <pyopencl.Platform 'NVIDIA CUDA' at 0x262e228a040>
Choice [0]:1
Choose device(s):
[0] <pyopencl.Device 'Intel(R) UHD Graphics 630' on 'OpenCLOn12' at 0x262e2209dd0>
[1] <pyopencl.Device 'Microsoft Basic Render Driver' on 'OpenCLOn12' at 0x262e2209220>
[2] <pyopencl.Device 'NVIDIA GeForce GTX 1060' on 'OpenCLOn12' at 0x262e2209330>
Choice, comma-separated [0]:1
Set the environment variable PYOPENCL_CTX='1:1' to avoid being asked again.
Initializing pubKeys...
read_8byte_pubkey took 0.854777 seconds
Fetching deployers, contract count: 0
Count of addresses: 1
Number of addresses: 1
Creating buffer elems
Creating buffer precomp
Copying to device elems
Copying to device precomp
Traceback (most recent call last):
File "D:\programmer\ReverseProfanityTool-main\main.py", line 41, in
prof.build_kernel()
File "D:\programmer\ReverseProfanityTool-main\src\tools.py", line 32, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\programmer\ReverseProfanityTool-main\src\tools.py", line 497, in build_kernel
self.program = cl.Program(self.ctx, kernel).build()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\martv\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyopencl_init
.py", line 534, in build
self._prg, was_cached = self.build_and_catch_errors(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\martv\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyopencl_init
.py", line 582, in _build_and_catch_errors
raise err
pyopencl._cl.RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE

Build on <pyopencl.Device 'Microsoft Basic Render Driver' on 'OpenCLOn12' at 0x262e2209220>:

source.cl:481:14: error: program scope variable must reside in constant address space
source.cl:557:33: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
Error executing LLVM compilation action.

(options: -I C:\Users\martv\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyopencl\cl)
(source saved as C:\Users\martv\AppData\Local\Temp\tmp76z98nrs.cl)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.