-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush.js
More file actions
57 lines (47 loc) · 1.85 KB
/
push.js
File metadata and controls
57 lines (47 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(async()=>{
"use strict";
// Dependencies
const client = await require("./modules/mongodb.js")
const shortener = require("./shortener.js")
const sAES256 = require("simple-aes-256")
const { parse } = require("smol-toml")
const hashJS = require("hash.js")
const ky = require("ky").default
const crypto = require("crypto")
const fs = require("fs")
// Variables
const config = parse(fs.readFileSync("./config.toml", "utf8"))
const fakeAds = fs.readdirSync("./fake-ads").map((d)=>`./fake-ads/${d}`)
const agents = require("./agents.json")
const args = process.argv.slice(2)
const database = client.db(config.database.database)
const messages = database.collection(config.database.messagesCollection)
// Functions
const generateCode = ()=>{
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
const bytes = crypto.randomBytes(8)
var result = ""
for ( let i = 0; i < 8; i++ ) result += chars[bytes[i] % chars.length]
return result
}
// Main
if(!args.length || !agents[args.slice(0).join(" ")]){
console.log("usage: node push.js <agentCode>")
process.exit()
}
//* Variables
const code = generateCode()
//* Core
var message = fs.readFileSync(fakeAds[Math.floor(Math.random() * fakeAds.length)], "utf8")
message = message.replace("{url}", await shortener(`${config.web.url}/promo?code=${code}`))
await messages.insertOne({
x: hashJS.sha512().update(code).digest("hex"),
m: sAES256.encrypt(code, fs.readFileSync("./message.txt", "utf8")).toString("hex")
})
await ky.post(`https://ntfy.sh/${agents[args.slice(0).join(" ")]}`, {
body: message
})
console.log(`The agent has been notified and the data has been pushed!
Code: ${code}`)
process.exit()
})()