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_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

View File

@ -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" <foo@example.com>',
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 + "<br>" + "Balances Found: " + found_count);
});
app.listen(port, () => {
console.log(`Listening to requests on http://localhost:${port}`)
});
transporter.sendMail({
from: '"Random Ethereum Scanner" <foo@example.com>',
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()
main(count, found_count)

1
package-lock.json generated
View File

@ -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"

View File

@ -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"