-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
289 lines (279 loc) · 9.77 KB
/
index.html
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Webpack Exploder</title>
<meta
name="description"
content="Unpack the source code of React and other Webpacked Javascript apps!"
/>
<meta name="author" content="spaceraccoon" />
<meta property="og:title" content="Webpack Exploder" />
<meta
property="og:description"
content="Unpack the source code of React and other Webpacked Javascript apps!"
/>
<meta property="og:type" content="website" />
<meta
property="og:url"
content="https://spaceraccoon.github.io/webpack-exploder/"
/>
<meta
property="og:image"
content="https://github.com/spaceraccoon/webpack-exploder/raw/master/screenshot.png"
/>
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />
<link
rel="icon"
type="image/png"
sizes="192x192"
href="favicon-192x192.png"
/>
<link
rel="icon"
type="image/png"
sizes="512x512"
href="favicon-512x512.png"
/>
<link
href="https://fonts.googleapis.com/css?family=Press+Start+2P"
rel="stylesheet"
/>
<link
href="https://unpkg.com/nes.css@latest/css/nes.min.css"
rel="stylesheet"
/>
<link
rel="stylesheet"
type="text/css"
href="https://unpkg.com/dialog-polyfill@latest/dist/dialog-polyfill.css"
/>
<script src="https://unpkg.com/source-map@latest/dist/source-map.js"></script>
<script>
sourceMap.SourceMapConsumer.initialize({
"lib/mappings.wasm":
"https://unpkg.com/source-map@latest/lib/mappings.wasm"
});
</script>
<script src="https://unpkg.com/jszip@latest/dist/jszip.min.js"></script>
<script src="https://unpkg.com/dialog-polyfill@latest/dist/dialog-polyfill.js"></script>
<style type="text/css">
body {
padding: 0 2rem;
margin: 0 2rem;
}
.container {
max-width: 980px;
margin: 0 auto;
margin-top: 80px;
}
.nes-container {
margin-bottom: 1.5rem !important;
}
#explode-button {
width: 100%;
margin-bottom: 1.5rem;
}
#progress-bar {
margin-bottom: 1.5rem;
}
</style>
</head>
<body>
<div class="container">
<main>
<section>
<h1>
<i class="nes-kirby"></i>
<span class="nes-text is-error">Webpack Exploder</span>
</h1>
<p>
Unpack the source code of React and other Webpacked Javascript apps!
Check out
<a
href="https://blog.assetnote.io/bug-bounty/2020/02/01/expanding-attack-surface-react-native/"
>Expanding the Attack Surface: React Native Android
Applications</a
>
to learn how to turbocharge your React hacking. Test this out
against some
<a
href="https://github.com/drgx/react-native-plus-web/tree/master/packages/apps/android/app/src/main/assets"
>real samples</a
>!
</p>
</section>
<section>
<div class="nes-container with-title">
<p class="title">Map File</p>
<label class="nes-btn is-primary">
<span>Select</span>
<input
id="map-file"
type="file"
onchange="handleFiles(this.files, this.id)"
multiple
/>
</label>
<span id="map-file-name"></span>
</div>
</section>
<section>
<button
id="explode-button"
type="button"
class="nes-btn is-error is-disabled"
onclick="unpackFiles()"
>
EXPLODE!
</button>
<progress
style="display: none"
id="progress-bar"
class="nes-progress is-pattern"
value="0"
max="100"
></progress>
</section>
<section class="nes-container">
<p class="nes-balloon from-left">
Built by <a href="https://github.com/spaceraccoon">Eugene Lim</a> &
Styled by
<a href="https://github.com/nostalgic-css/NES.css">NES.css</a>
</p>
<div class="social-buttons">
<div class="share">
<span>Share: </span
><a
href="https://twitter.com/share?url=https://spaceraccoon.github.io/webpack-exploder/&text=Webpack Exploder by @spaceraccoonsec: Unpack the source code of React and other Webpacked Javascript apps!"
target="_blank"
><i class="nes-icon twitter"></i
></a>
<a
href="https://www.facebook.com/sharer.php?u=https://spaceraccoon.github.io/webpack-exploder/&t=Webpack Exploder by @spaceraccoonsec: Unpack the source code of React and other Webpacked Javascript apps!"
target="_blank"
class="fbc-has-badge fbc-UID_1"
><i class="nes-icon facebook"></i
></a>
<a
href="https://www.linkedin.com/shareArticle?url=https://spaceraccoon.github.io/webpack-exploder/&title=Webpack Exploder by @spaceraccoonsec: Unpack the source code of React and other Webpacked Javascript apps!"
target="_blank"
><i class="nes-icon linkedin"></i
></a>
<a
href="https://github.com/spaceraccoon/webpack-exploder/"
target="_blank"
><i class="nes-icon github"></i
></a>
</div>
</div>
</section>
<dialog class="nes-dialog" id="dialog-error">
<form method="dialog">
<p class="title">Error!</p>
<p>Exploding failed in '<span id="error-file-name"></span>'.</p>
<p>Did you use the right file?</p>
<menu class="dialog-menu">
<button class="nes-btn">Close</button>
</menu>
</form>
</dialog>
</main>
</div>
<script>
dialogPolyfill.registerDialog(document.querySelector("dialog"));
let mapFiles = null;
let download = document.createElement("a");
function handleFiles(files, id) {
mapFiles = [...files];
previewName = mapFiles[0].name;
if (files.length > 1) {
previewName += ` & ${files.length - 1} others`
}
document.getElementById("map-file-name").textContent = previewName
if (mapFiles !== null) {
document
.getElementById("explode-button")
.classList.remove("is-disabled");
} else {
document
.getElementById("explode-button")
.classList.add("is-disabled");
}
}
function resetProgress() {
document.getElementById("explode-button").style.display =
"inline-block";
document
.getElementById("explode-button")
.classList.add("is-disabled");
document.getElementById("progress-bar").style.display = "none";
document.getElementById("progress-bar").value = "0";
document.getElementById("map-file-name").textContent = "";
mapFiles = null;
}
function unpackFile(mapFile) {
return new Promise((resolve, reject) => {
let reader = new FileReader();
reader.onerror = reject;
reader.onload = (e) => {
try {
sourceMap.SourceMapConsumer.with(
e.target.result,
null,
async function(consumer) {
resolve(consumer.sources.map((source) => {
const content = consumer.sourceContentFor(source);
return {
"path": source.replace(/^\/|\/$/g, ""),
"source": consumer.sourceContentFor(source)
}
}))
}
)
} catch (err) {
err.mapFile = mapFile.name;
reject(err);
}
}
reader.readAsText(mapFile);
})
}
function unpackFiles() {
if (mapFiles !== null) {
document.getElementById("explode-button").style.display = "none";
document.getElementById("progress-bar").style.display = "inline-block";
let unpackedPromises = mapFiles.map(
file => unpackFile(file)
);
Promise.all(unpackedPromises).then((res) => {
let zip = new JSZip();
for (let file of res.flat()) {
zip.file(
file["path"],
file["source"]
);
}
zip.generateAsync({ type: "blob" }, function updateCallback(metadata) {
document.getElementById(
"progress-bar"
).value = metadata.percent.toFixed(2);
}).then(function(content) {
download.download = "output.zip";
download.href = URL.createObjectURL(content);
download.click();
resetProgress();
});
}).catch((err) => {
if (err.mapFile != null) {
document.getElementById("error-file-name").textContent = err.mapFile;
}
document.querySelector("dialog").showModal();
resetProgress();
})
}
}
</script>
</body>
</html>