From 6541a21d06cd3e674acd35ec61263d2c680fbfc7 Mon Sep 17 00:00:00 2001 From: Eric Pelland Date: Fri, 21 Oct 2022 19:35:25 -0400 Subject: [PATCH] small refactor + display info on port 8000 --- docker-compose.sample.yml | 2 ++ index.js | 51 ++++++++++++++++++++++++--------------- package-lock.json | 1 + package.json | 1 + 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/docker-compose.sample.yml b/docker-compose.sample.yml index d538997..21ed48c 100644 --- a/docker-compose.sample.yml +++ b/docker-compose.sample.yml @@ -7,5 +7,7 @@ services: - EMAIL_USER=email@website.com - EMAIL_PASS=GOOGLE-APP-PASSWORD # See https://stackoverflow.com/questions/71477637/nodemailer-and-gmail-after-may-30-2022 - EMAIL_TO=email@website.com + ports: + - 8000:8000 volumes: - ./output:/output \ No newline at end of file diff --git a/index.js b/index.js index 0c3f887..893963b 100644 --- a/index.js +++ b/index.js @@ -1,24 +1,26 @@ -let Web3 = require("web3"); -let ethNetwork = 'https://cloudflare-eth.com'; -let ethscan = require('@mycrypto/eth-scan'); -let web3 = new Web3(new Web3.providers.HttpProvider(ethNetwork)); -let fs = require('fs'); -let nodemailer = require("nodemailer"); +const Web3 = require("web3") +const ethNetwork = 'https://cloudflare-eth.com' +const ethscan = require('@mycrypto/eth-scan') +const web3 = new Web3(new Web3.providers.HttpProvider(ethNetwork)) +const fs = require('fs') +const nodemailer = require("nodemailer") +const express = require("express") +const app = express(); +const port = process.env.PORT || "8000"; +let count = 0 +let found_count = 0 -let transporter = nodemailer.createTransport({ +const transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: process.env.EMAIL_USER, pass: process.env.EMAIL_PASS } -}); - -function makeMoney(count = 0){ - console.log('\033[2J'); - console.log("Addresses checked: " + count) - - // let accounts = [{address: '0x8735015837bD10e05d9cf5EA43A2486Bf4Be156F', privateKey: 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364150'}] +}) +function main(_count, _found_count){ + found_count = _found_count + count = _count let accounts = [] let x = 0 while(x < 100) { @@ -27,25 +29,26 @@ function makeMoney(count = 0){ x++ } - search(accounts, count) + search(accounts) } -function search(accounts, count) { +function search(accounts) { let addresses = accounts.map((account) => { return account.address }) ethscan.getEtherBalances(web3, addresses).then(balanceMap => { for (const [key, value] of Object.entries(balanceMap)) { if(BigInt(value) > 0) { + found_count++ message = key + ": " + accounts[addresses.indexOf(key)].privateKey + "\n" writeToFile('/output/output.txt', message) transporter.sendMail({ from: '"Random Ethereum Scanner" ', - to: process.env.EMAIL_TO, // Test email address + to: process.env.EMAIL_TO, subject: "$$$ We Found Ethereum!", text: message, }).catch(emailError) } } - makeMoney(count) + main(count, found_count) }).catch(emailError) } @@ -63,9 +66,17 @@ function writeToFile(filename, message) { if (err) { console.log(err) } - }); + }) } +app.get("/", (req, res) => { + res.status(200).send("Addresses tested: " + count + "
" + "Balances Found: " + found_count); +}); + +app.listen(port, () => { + console.log(`Listening to requests on http://localhost:${port}`) +}); + transporter.sendMail({ from: '"Random Ethereum Scanner" ', to: process.env.EMAIL_TO, // Test email address @@ -73,4 +84,4 @@ transporter.sendMail({ text: "Random Ethereum Scanner Started Successfully", }).catch((err)=>{writeToFile('/output/err.txt', err.toString())}) -makeMoney() \ No newline at end of file +main(count, found_count) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 561d1e6..aa84f0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@mycrypto/eth-scan": "^3.5.3", + "express": "^4.18.2", "fs": "^0.0.1-security", "nodemailer": "^6.8.0", "web3": "^1.8.0" diff --git a/package.json b/package.json index a2915e5..0557a97 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@mycrypto/eth-scan": "^3.5.3", + "express": "^4.18.2", "fs": "^0.0.1-security", "nodemailer": "^6.8.0", "web3": "^1.8.0"