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")
|
|
|
|
const app = express();
|
|
|
|
const port = process.env.PORT || "8000";
|
|
|
|
let count = 0
|
|
|
|
let found_count = 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-21 23:35:25 +00:00
|
|
|
function main(_count, _found_count){
|
|
|
|
found_count = _found_count
|
|
|
|
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-21 23:35:25 +00:00
|
|
|
found_count++
|
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-21 23:35:25 +00:00
|
|
|
main(count, found_count)
|
2022-10-21 22:43:56 +00:00
|
|
|
}).catch(emailError)
|
|
|
|
}
|
|
|
|
|
|
|
|
function emailError(err){
|
|
|
|
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())})
|
|
|
|
}
|
|
|
|
|
|
|
|
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) => {
|
|
|
|
res.status(200).send("Addresses tested: " + count + "<br>" + "Balances Found: " + found_count);
|
|
|
|
});
|
|
|
|
|
|
|
|
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-21 23:35:25 +00:00
|
|
|
main(count, found_count)
|