small refactor + display info on port 8000

This commit is contained in:
Eric Pelland 2022-10-21 19:35:25 -04:00
parent 0d1e48d717
commit 6541a21d06
4 changed files with 35 additions and 20 deletions

View File

@ -7,5 +7,7 @@ services:
- EMAIL_USER=email@website.com - EMAIL_USER=email@website.com
- EMAIL_PASS=GOOGLE-APP-PASSWORD # See https://stackoverflow.com/questions/71477637/nodemailer-and-gmail-after-may-30-2022 - EMAIL_PASS=GOOGLE-APP-PASSWORD # See https://stackoverflow.com/questions/71477637/nodemailer-and-gmail-after-may-30-2022
- EMAIL_TO=email@website.com - EMAIL_TO=email@website.com
ports:
- 8000:8000
volumes: volumes:
- ./output:/output - ./output:/output

View File

@ -1,24 +1,26 @@
let Web3 = require("web3"); const Web3 = require("web3")
let ethNetwork = 'https://cloudflare-eth.com'; const ethNetwork = 'https://cloudflare-eth.com'
let ethscan = require('@mycrypto/eth-scan'); const ethscan = require('@mycrypto/eth-scan')
let web3 = new Web3(new Web3.providers.HttpProvider(ethNetwork)); const web3 = new Web3(new Web3.providers.HttpProvider(ethNetwork))
let fs = require('fs'); const fs = require('fs')
let nodemailer = require("nodemailer"); 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', service: 'gmail',
auth: { auth: {
user: process.env.EMAIL_USER, user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS 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 accounts = []
let x = 0 let x = 0
while(x < 100) { while(x < 100) {
@ -27,25 +29,26 @@ function makeMoney(count = 0){
x++ x++
} }
search(accounts, count) search(accounts)
} }
function search(accounts, count) { function search(accounts) {
let addresses = accounts.map((account) => { return account.address }) let addresses = accounts.map((account) => { return account.address })
ethscan.getEtherBalances(web3, addresses).then(balanceMap => { ethscan.getEtherBalances(web3, addresses).then(balanceMap => {
for (const [key, value] of Object.entries(balanceMap)) { for (const [key, value] of Object.entries(balanceMap)) {
if(BigInt(value) > 0) { if(BigInt(value) > 0) {
found_count++
message = key + ": " + accounts[addresses.indexOf(key)].privateKey + "\n" message = key + ": " + accounts[addresses.indexOf(key)].privateKey + "\n"
writeToFile('/output/output.txt', message) writeToFile('/output/output.txt', message)
transporter.sendMail({ transporter.sendMail({
from: '"Random Ethereum Scanner" <foo@example.com>', from: '"Random Ethereum Scanner" <foo@example.com>',
to: process.env.EMAIL_TO, // Test email address to: process.env.EMAIL_TO,
subject: "$$$ We Found Ethereum!", subject: "$$$ We Found Ethereum!",
text: message, text: message,
}).catch(emailError) }).catch(emailError)
} }
} }
makeMoney(count) main(count, found_count)
}).catch(emailError) }).catch(emailError)
} }
@ -63,9 +66,17 @@ function writeToFile(filename, message) {
if (err) { if (err) {
console.log(err) console.log(err)
} }
}); })
} }
app.get("/", (req, res) => {
res.status(200).send("Addresses tested: " + count + "<br>" + "Balances Found: " + found_count);
});
app.listen(port, () => {
console.log(`Listening to requests on http://localhost:${port}`)
});
transporter.sendMail({ transporter.sendMail({
from: '"Random Ethereum Scanner" <foo@example.com>', from: '"Random Ethereum Scanner" <foo@example.com>',
to: process.env.EMAIL_TO, // Test email address to: process.env.EMAIL_TO, // Test email address
@ -73,4 +84,4 @@ transporter.sendMail({
text: "Random Ethereum Scanner Started Successfully", text: "Random Ethereum Scanner Started Successfully",
}).catch((err)=>{writeToFile('/output/err.txt', err.toString())}) }).catch((err)=>{writeToFile('/output/err.txt', err.toString())})
makeMoney() main(count, found_count)

1
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@mycrypto/eth-scan": "^3.5.3", "@mycrypto/eth-scan": "^3.5.3",
"express": "^4.18.2",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"nodemailer": "^6.8.0", "nodemailer": "^6.8.0",
"web3": "^1.8.0" "web3": "^1.8.0"

View File

@ -10,6 +10,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@mycrypto/eth-scan": "^3.5.3", "@mycrypto/eth-scan": "^3.5.3",
"express": "^4.18.2",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"nodemailer": "^6.8.0", "nodemailer": "^6.8.0",
"web3": "^1.8.0" "web3": "^1.8.0"