This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
forked from mandatoryprogrammer/xsshunter-express
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnotification.js
71 lines (59 loc) · 2.02 KB
/
notification.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const nodemailer = require('nodemailer');
const mustache = require('mustache');
const fs = require('fs');
const axios = require('axios');
const XSS_PAYLOAD_FIRE_EMAIL_TEMPLATE = fs.readFileSync(
'./templates/xss_email_template.htm',
'utf8'
);
async function send_email_notification(xss_payload_fire_data) {
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: parseInt(process.env.SMTP_PORT),
secure: (process.env.SMTP_USE_TLS === "true"),
auth: {
user: process.env.SMTP_USERNAME,
pass: process.env.SMTP_PASSWORD,
},
});
const notification_html_email_body = mustache.render(
XSS_PAYLOAD_FIRE_EMAIL_TEMPLATE,
xss_payload_fire_data
);
const info = await transporter.sendMail({
from: process.env.SMTP_FROM_EMAIL,
to: process.env.SMTP_RECEIVER_EMAIL,
subject: `[XSS Hunter Express] XSS Payload Fired On ${xss_payload_fire_data.url}`,
text: "Only HTML reports are available, please use an email client which supports this.",
html: notification_html_email_body,
});
console.log("Message sent: %s", info.messageId);
}
async function send_slack_notification(xss_payload_fire_data) {
var slack_message = {
"channel": process.env.SLACK_CHANNEL,
"username": process.env.SLACK_USERNAME,
"icon_emoji": `:${process.env.SLACK_EMOJI}:`,
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": `XSS Payload Fired On ${xss_payload_fire_data.url}`
}
},
]
};
await axios.post(process.env.SLACK_WEBHOOK, JSON.stringify(slack_message));
console.log("Message sent to slack");
}
async function send_discord_notification(xss_payload_fire_data) {
var discord_message = {
"content": `XSS Payload Fired On ${xss_payload_fire_data.url}`
};
await axios.post(process.env.DISCORD_WEBHOOK, discord_message);
console.log("Message sent to discord");
}
module.exports.send_email_notification = send_email_notification;
module.exports.send_slack_notification = send_slack_notification;
module.exports.send_discord_notification = send_discord_notification;