2023-01-29 19:46:28 +00:00
|
|
|
const sendgrid = require('@sendgrid/mail')
|
|
|
|
sendgrid.setApiKey(process.env.SENDGRID_API_KEY)
|
2021-05-31 19:06:40 +00:00
|
|
|
const mustache = require('mustache');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const XSS_PAYLOAD_FIRE_EMAIL_TEMPLATE = fs.readFileSync(
|
|
|
|
'./templates/xss_email_template.htm',
|
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
|
2023-01-17 06:25:51 +00:00
|
|
|
async function send_email_notification(xss_payload_fire_data, email) {
|
2021-05-31 19:06:40 +00:00
|
|
|
const notification_html_email_body = mustache.render(
|
|
|
|
XSS_PAYLOAD_FIRE_EMAIL_TEMPLATE,
|
|
|
|
xss_payload_fire_data
|
|
|
|
);
|
|
|
|
|
2023-02-21 20:05:01 +00:00
|
|
|
const fire_location = (!xss_payload_fire_data.encrypted ? xss_payload_fire_data.url : 'With An Encryption Key');
|
|
|
|
|
2023-01-29 19:46:28 +00:00
|
|
|
const msg = {
|
|
|
|
from: process.env.EMAIL_FROM,
|
2023-01-17 06:25:51 +00:00
|
|
|
to: email,
|
2023-02-21 20:05:01 +00:00
|
|
|
subject: `[XSS Hunter Express] XSS Payload Fired On ${fire_location}`,
|
2021-05-31 19:06:40 +00:00
|
|
|
text: "Only HTML reports are available, please use an email client which supports this.",
|
|
|
|
html: notification_html_email_body,
|
2023-01-29 19:46:28 +00:00
|
|
|
asm: {
|
|
|
|
groupId: parseInt(process.env.SENDGRID_UNSUBSRIBE_GROUP_ID),
|
|
|
|
groupsToDisplay: [
|
|
|
|
parseInt(process.env.SENDGRID_UNSUBSRIBE_GROUP_ID)
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
response = await sendgrid
|
|
|
|
.send(msg)
|
|
|
|
.catch((error) => {
|
|
|
|
console.error(error);
|
|
|
|
})
|
2021-05-31 19:06:40 +00:00
|
|
|
|
2023-02-06 17:36:46 +00:00
|
|
|
console.debug("Message emailed with status %d", response[0].statusCode);
|
2023-01-29 19:46:28 +00:00
|
|
|
return true;
|
2021-05-31 19:06:40 +00:00
|
|
|
}
|
|
|
|
|
2023-01-17 06:25:51 +00:00
|
|
|
module.exports.send_email_notification = send_email_notification;
|