This is an example of a sweeper bot commonly used to drain wallets which private keys have been exposed to internet.
The purpose of this bot is to show how it works and for local testing when trying to recover remaining assets from a compromised wallet.
The original repo belongs to zeroXBrock member of Flashbots. This is a modified version of the original repo, with the following changes:
- The bot doesn't burn ETH.
- It sends all ETH to a specified address (attacker, in this case my testing wallet).
- The bot doesn't sweep other assets, only gas token.
- It hasn't been tested on mainnet or other networks.
Caution
git clone https://github.com/Ariiellus/sweeper-bot.git
cd sweeper-bot
yarn install
To initialize the bot run:
yarn start
-p <privatekey> \ # private key from compromised wallet
-r \ https://eth-mainnet.alchemyapi.io/v2/<key>
-s <pubkey> # OPTIONAL address to receive eth, defaults to my testing wallet 0x1F3bfa0620f95fda15E67F3e8FA459A258559E94