2022-10-21 23:35:25 +00:00
|
|
|
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")
|
2022-10-22 00:14:54 +00:00
|
|
|
const path = require('path');
|
|
|
|
|
2022-10-21 23:35:25 +00:00
|
|
|
const app = express();
|
|
|
|
const port = process.env.PORT || "8000";
|
|
|
|
let count = 0
|
2022-10-22 00:14:54 +00:00
|
|
|
let balancesFound = 0
|
2022-10-21 22:43:56 +00:00
|
|
|
|
2022-10-21 23:35:25 +00:00
|
|
|
const transporter = nodemailer.createTransport({
|
2022-10-21 22:43:56 +00:00
|
|
|
service: 'gmail',
|
|
|
|
auth: {
|
|
|
|
user: process.env.EMAIL_USER,
|
|
|
|
pass: process.env.EMAIL_PASS
|
|
|
|
}
|
2022-10-21 23:35:25 +00:00
|
|
|
})
|
2022-10-21 22:43:56 +00:00
|
|
|
|
2022-10-22 00:14:54 +00:00
|
|
|
function main(_count, _balancesFound){
|
|
|
|
balancesFound = _balancesFound
|
2022-10-21 23:35:25 +00:00
|
|
|
count = _count
|
2022-10-21 22:43:56 +00:00
|
|
|
let accounts = []
|
|
|
|
let x = 0
|
|
|
|
while(x < 100) {
|
|
|
|
accounts.push(web3.eth.accounts.create())
|
|
|
|
count++
|
|
|
|
x++
|
|
|
|
}
|
|
|
|
|
2022-10-21 23:35:25 +00:00
|
|
|
search(accounts)
|
2022-10-21 22:43:56 +00:00
|
|
|
}
|
|
|
|
|
2022-10-21 23:35:25 +00:00
|
|
|
function search(accounts) {
|
2022-10-21 22:43:56 +00:00
|
|
|
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) {
|
2022-10-22 00:14:54 +00:00
|
|
|
balancesFound++
|
2022-10-21 22:43:56 +00:00
|
|
|
message = key + ": " + accounts[addresses.indexOf(key)].privateKey + "\n"
|
|
|
|
writeToFile('/output/output.txt', message)
|
|
|
|
transporter.sendMail({
|
|
|
|
from: '"Random Ethereum Scanner" <foo@example.com>',
|
2022-10-21 23:35:25 +00:00
|
|
|
to: process.env.EMAIL_TO,
|
2022-10-21 22:43:56 +00:00
|
|
|
subject: "$$$ We Found Ethereum!",
|
|
|
|
text: message,
|
|
|
|
}).catch(emailError)
|
|
|
|
}
|
|
|
|
}
|
2022-10-22 00:14:54 +00:00
|
|
|
main(count, balancesFound)
|
2022-10-22 12:06:54 +00:00
|
|
|
}).catch((err)=> { emailError(err, true) })
|
2022-10-21 22:43:56 +00:00
|
|
|
}
|
|
|
|
|
2022-10-22 11:56:19 +00:00
|
|
|
function emailError(err, restart = false){
|
2022-10-22 12:06:54 +00:00
|
|
|
console.log(err)
|
2022-10-24 15:12:38 +00:00
|
|
|
// transporter.sendMail({
|
|
|
|
// from: '"Random Ethereum Scanner" <foo@example.com>',
|
|
|
|
// to: process.env.EMAIL_TO, // Test email address
|
|
|
|
// subject: "Error detected",
|
|
|
|
// text: err.toString(),
|
|
|
|
// }).catch((err)=>{writeToFile('/output/err.txt', err.toString())})
|
2022-10-22 11:56:19 +00:00
|
|
|
if (restart) {
|
|
|
|
main(count, balancesFound)
|
|
|
|
}
|
2022-10-21 22:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function writeToFile(filename, message) {
|
|
|
|
fs.appendFile(filename, message, err => {
|
|
|
|
if (err) {
|
|
|
|
console.log(err)
|
|
|
|
}
|
2022-10-21 23:35:25 +00:00
|
|
|
})
|
2022-10-21 22:43:56 +00:00
|
|
|
}
|
|
|
|
|
2022-10-21 23:35:25 +00:00
|
|
|
app.get("/", (req, res) => {
|
2022-10-22 00:14:54 +00:00
|
|
|
res.sendFile(path.join(__dirname, '/index.html'))
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get("/stats", (req, res) => {
|
|
|
|
res.status(200).send({ "count": count,"balancesFound": balancesFound });
|
2022-10-21 23:35:25 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Listening to requests on http://localhost:${port}`)
|
|
|
|
});
|
|
|
|
|
2022-10-21 22:43:56 +00:00
|
|
|
transporter.sendMail({
|
|
|
|
from: '"Random Ethereum Scanner" <foo@example.com>',
|
|
|
|
to: process.env.EMAIL_TO, // Test email address
|
|
|
|
subject: "Scanner Started",
|
|
|
|
text: "Random Ethereum Scanner Started Successfully",
|
|
|
|
}).catch((err)=>{writeToFile('/output/err.txt', err.toString())})
|
|
|
|
|
2022-10-22 00:14:54 +00:00
|
|
|
main(count, balancesFound)
|