troyhunt / password-purgatory

Deliberately making password creation a true hell
157 stars 14 forks source link

Purgatory workflow in Gmail #11

Closed jmfayard closed 2 years ago

jmfayard commented 2 years ago

I don't know where to post it but I've just read this and it's hilarious https://www.troyhunt.com/sending-spammers-to-password-purgatory-with-microsoft-power-automate-and-cloudflare-workers-kv/

If someone puts the work to replicate that workflow with Gmail, I would love to know about it

troyhunt commented 2 years ago

Thank you 😊

Power Automate has a Gmail connector: https://powerautomate.microsoft.com/en-US/connectors/details/shared_gmail/gmail/

jLynx commented 1 year ago

Side note, you should also be able to do this on script.google.com using Google scripts. I'm going to try and get this working in the next day or so as the Microsoft solution requires a premium account in order to do the HTTP module thing

jLynx commented 1 year ago

Here is a working snippet of code if you want to do this for free using Google Scripts

function myFunction() {

  var fromEmail = "me@myemail.com";
  var body = "<p>This is exciting and might empower a cutting-edge partnership! I'd like to invite you to <a href='https://yourdomain/partnerships?kvKey={REPLACE_KEY}'> leave your information on my special registration form</a>, it will only take a moment.</p><p>We look forward to exploiting the cross-platform mindshare together</p><p>Regards,<br>Your Name</p>";

  var options = {
     "headers" : {
       "hell-api-key" : "12312312123"
     }
  };
  var response = UrlFetchApp.fetch("https://your-logger-domain.com/create-hell", options);
  var data = JSON.parse(response.getContentText());

  var body = body.replace("{REPLACE_KEY}", data.kvKey);

  var search = "label:send-spammer-to-password-purgatory label:unread";
  var threads = GmailApp.search(search);

  for (var i = 0; i < threads.length; i++) {
    threads[i].reply(body,  {from: fromEmail, name: "Jane Doe", htmlBody: body});
    threads[i].markRead();
  }

}