Skip to content

Commit 89bb6f3

Browse files
author
antelle
committedMar 6, 2021
--verbose option
1 parent b694df2 commit 89bb6f3

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
 

‎cli.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ if (!packagePath) {
1010
process.exit(1);
1111
}
1212

13-
patch({ path: packagePath });
13+
const verbose = process.argv.includes('--verbose');
14+
15+
patch({ path: packagePath, verbose });

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "electron-evil-feature-patcher",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Patches Electron to remove certain features from it, such as debugging flags, that can be used for evil",
55
"main": "patch.js",
66
"repository": {

‎patch.js

+25
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,35 @@ const replacements = [
9090
];
9191

9292
function patch(options) {
93+
const { verbose } = options;
9394
const binary = findBinary(options);
9495
if (!fs.existsSync(binary)) {
9596
throw new Error(`Binary not found: ${binary}`);
9697
}
98+
if (verbose) {
99+
console.log(`Found binary: ${binary}`);
100+
}
97101
let data = fs.readFileSync(binary, 'latin1');
102+
if (verbose) {
103+
console.log(`Read: ${data.length} bytes`);
104+
}
98105
if (data.includes(PatchedSentinel)) {
106+
if (verbose) {
107+
console.log(`Already patched`);
108+
}
99109
return;
100110
}
101111
const [, electronVersion] = data.match(/Electron\/(\d+\.\d+\.\d+)/);
112+
if (verbose) {
113+
console.log(`Found version: ${electronVersion}`);
114+
}
102115
if (electronVersion.split('.')[0] < 12) {
103116
throw new Error(`Minimal supported Electron version is 12, found ${electronVersion}`);
104117
}
105118
data = setFuseWireStatus(data, FuseConst.RunAsNode, false);
119+
if (verbose) {
120+
console.log(`Fuse wire status set`);
121+
}
106122
for (const replacement of replacements) {
107123
let replaced = false;
108124
data = data.replace(replacement.search, (match) => {
@@ -121,8 +137,17 @@ function patch(options) {
121137
if (!replaced) {
122138
throw new Error(`Not found: ${replacement.name}`);
123139
}
140+
if (verbose) {
141+
console.log(`Replaced: ${replacement.name}`);
142+
}
143+
}
144+
if (verbose) {
145+
console.log(`Writing output file...`);
124146
}
125147
fs.writeFileSync(binary, Buffer.from(data, 'latin1'));
148+
if (verbose) {
149+
console.log(`Done`);
150+
}
126151
}
127152

128153
function findBinary(options) {

0 commit comments

Comments
 (0)
Please sign in to comment.