@zorilla/puppeteer-extra-plugin-stealth 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/evasions/_template/index.d.ts +6 -4
- package/dist/evasions/_template/index.d.ts.map +1 -1
- package/dist/evasions/_template/index.js +13 -16
- package/dist/evasions/_template/index.js.map +1 -1
- package/{src/evasions/_template/index.js → dist/evasions/_template/index.ts} +5 -4
- package/dist/evasions/_utils/index.d.ts +48 -232
- package/dist/evasions/_utils/index.d.ts.map +1 -1
- package/dist/evasions/_utils/index.js +288 -328
- package/dist/evasions/_utils/index.js.map +1 -1
- package/{src/evasions/_utils/index.js → dist/evasions/_utils/index.ts} +240 -83
- package/dist/evasions/_utils/withUtils.d.ts +12 -4
- package/dist/evasions/_utils/withUtils.d.ts.map +1 -1
- package/dist/evasions/_utils/withUtils.js +29 -31
- package/dist/evasions/_utils/withUtils.js.map +1 -1
- package/dist/evasions/_utils/withUtils.ts +83 -0
- package/dist/evasions/chrome.app/README.md +225 -6
- package/dist/evasions/chrome.app/index.d.ts +6 -4
- package/dist/evasions/chrome.app/index.d.ts.map +1 -1
- package/dist/evasions/chrome.app/index.js +64 -75
- package/dist/evasions/chrome.app/index.js.map +1 -1
- package/{src/evasions/chrome.app/index.js → dist/evasions/chrome.app/index.ts} +12 -8
- package/dist/evasions/chrome.csi/README.md +229 -15
- package/dist/evasions/chrome.csi/index.d.ts +6 -4
- package/dist/evasions/chrome.csi/index.d.ts.map +1 -1
- package/dist/evasions/chrome.csi/index.js +37 -45
- package/dist/evasions/chrome.csi/index.js.map +1 -1
- package/{src/evasions/chrome.csi/index.js → dist/evasions/chrome.csi/index.ts} +8 -8
- package/dist/evasions/chrome.loadTimes/README.md +327 -13
- package/dist/evasions/chrome.loadTimes/index.d.ts +6 -4
- package/dist/evasions/chrome.loadTimes/index.d.ts.map +1 -1
- package/dist/evasions/chrome.loadTimes/index.js +114 -140
- package/dist/evasions/chrome.loadTimes/index.js.map +1 -1
- package/{src/evasions/chrome.loadTimes/index.js → dist/evasions/chrome.loadTimes/index.ts} +37 -22
- package/dist/evasions/chrome.runtime/README.md +346 -17
- package/dist/evasions/chrome.runtime/index.d.ts +7 -7
- package/dist/evasions/chrome.runtime/index.d.ts.map +1 -1
- package/dist/evasions/chrome.runtime/index.js +176 -240
- package/dist/evasions/chrome.runtime/index.js.map +1 -1
- package/{src/evasions/chrome.runtime/index.js → dist/evasions/chrome.runtime/index.ts} +27 -17
- package/dist/evasions/defaultArgs/README.md +230 -6
- package/dist/evasions/defaultArgs/index.d.ts +9 -7
- package/dist/evasions/defaultArgs/index.d.ts.map +1 -1
- package/dist/evasions/defaultArgs/index.js +32 -32
- package/dist/evasions/defaultArgs/index.js.map +1 -1
- package/{src/evasions/defaultArgs/index.js → dist/evasions/defaultArgs/index.ts} +18 -9
- package/dist/evasions/iframe.contentWindow/README.md +293 -8
- package/dist/evasions/iframe.contentWindow/index.d.ts +7 -5
- package/dist/evasions/iframe.contentWindow/index.d.ts.map +1 -1
- package/dist/evasions/iframe.contentWindow/index.js +106 -120
- package/dist/evasions/iframe.contentWindow/index.js.map +1 -1
- package/{src/evasions/iframe.contentWindow/index.js → dist/evasions/iframe.contentWindow/index.ts} +20 -14
- package/dist/evasions/media.codecs/README.md +282 -19
- package/dist/evasions/media.codecs/index.d.ts +6 -4
- package/dist/evasions/media.codecs/index.d.ts.map +1 -1
- package/dist/evasions/media.codecs/index.js +68 -79
- package/dist/evasions/media.codecs/index.js.map +1 -1
- package/{src/evasions/media.codecs/index.js → dist/evasions/media.codecs/index.ts} +12 -10
- package/dist/evasions/navigator.hardwareConcurrency/README.md +150 -9
- package/dist/evasions/navigator.hardwareConcurrency/index.d.ts +7 -7
- package/dist/evasions/navigator.hardwareConcurrency/index.d.ts.map +1 -1
- package/dist/evasions/navigator.hardwareConcurrency/index.js +20 -33
- package/dist/evasions/navigator.hardwareConcurrency/index.js.map +1 -1
- package/{src/evasions/navigator.hardwareConcurrency/index.js → dist/evasions/navigator.hardwareConcurrency/index.ts} +6 -6
- package/dist/evasions/navigator.languages/README.md +189 -7
- package/dist/evasions/navigator.languages/index.d.ts +7 -7
- package/dist/evasions/navigator.languages/index.d.ts.map +1 -1
- package/dist/evasions/navigator.languages/index.js +25 -34
- package/dist/evasions/navigator.languages/index.js.map +1 -1
- package/{src/evasions/navigator.languages/index.js → dist/evasions/navigator.languages/index.ts} +11 -8
- package/dist/evasions/navigator.permissions/README.md +225 -7
- package/dist/evasions/navigator.permissions/index.d.ts +6 -4
- package/dist/evasions/navigator.permissions/index.d.ts.map +1 -1
- package/dist/evasions/navigator.permissions/index.js +43 -56
- package/dist/evasions/navigator.permissions/index.js.map +1 -1
- package/{src/evasions/navigator.permissions/index.js → dist/evasions/navigator.permissions/index.ts} +11 -8
- package/dist/evasions/navigator.plugins/README.md +193 -11
- package/dist/evasions/navigator.plugins/functionMocks.d.ts +11 -4
- package/dist/evasions/navigator.plugins/functionMocks.d.ts.map +1 -1
- package/dist/evasions/navigator.plugins/functionMocks.js +25 -33
- package/dist/evasions/navigator.plugins/functionMocks.js.map +1 -1
- package/{src/evasions/navigator.plugins/functionMocks.js → dist/evasions/navigator.plugins/functionMocks.ts} +24 -16
- package/dist/evasions/navigator.plugins/index.d.ts +6 -4
- package/dist/evasions/navigator.plugins/index.d.ts.map +1 -1
- package/dist/evasions/navigator.plugins/index.js +64 -75
- package/dist/evasions/navigator.plugins/index.js.map +1 -1
- package/{src/evasions/navigator.plugins/index.js → dist/evasions/navigator.plugins/index.ts} +47 -17
- package/dist/evasions/navigator.plugins/magicArray.d.ts +15 -1
- package/dist/evasions/navigator.plugins/magicArray.d.ts.map +1 -1
- package/dist/evasions/navigator.plugins/magicArray.js +94 -113
- package/dist/evasions/navigator.plugins/magicArray.js.map +1 -1
- package/{src/evasions/navigator.plugins/magicArray.js → dist/evasions/navigator.plugins/magicArray.ts} +56 -24
- package/dist/evasions/navigator.plugins/mimeTypes.d.ts +18 -1
- package/dist/evasions/navigator.plugins/mimeTypes.d.ts.map +1 -1
- package/dist/evasions/navigator.plugins/mimeTypes.js +3 -8
- package/dist/evasions/navigator.plugins/mimeTypes.js.map +1 -1
- package/dist/evasions/navigator.plugins/mimeTypes.ts +32 -0
- package/dist/evasions/navigator.plugins/plugins.d.ts +18 -1
- package/dist/evasions/navigator.plugins/plugins.d.ts.map +1 -1
- package/dist/evasions/navigator.plugins/plugins.js +3 -8
- package/dist/evasions/navigator.plugins/plugins.js.map +1 -1
- package/dist/evasions/navigator.plugins/plugins.ts +32 -0
- package/dist/evasions/navigator.vendor/README.md +173 -10
- package/dist/evasions/navigator.vendor/index.d.ts +7 -7
- package/dist/evasions/navigator.vendor/index.d.ts.map +1 -1
- package/dist/evasions/navigator.vendor/index.js +23 -36
- package/dist/evasions/navigator.vendor/index.js.map +1 -1
- package/{src/evasions/navigator.vendor/index.js → dist/evasions/navigator.vendor/index.ts} +6 -6
- package/dist/evasions/navigator.webdriver/README.md +128 -8
- package/dist/evasions/navigator.webdriver/index.d.ts +7 -5
- package/dist/evasions/navigator.webdriver/index.d.ts.map +1 -1
- package/dist/evasions/navigator.webdriver/index.js +40 -38
- package/dist/evasions/navigator.webdriver/index.js.map +1 -1
- package/{src/evasions/navigator.webdriver/index.js → dist/evasions/navigator.webdriver/index.ts} +18 -10
- package/dist/evasions/sourceurl/README.md +222 -7
- package/dist/evasions/sourceurl/index.d.ts +6 -4
- package/dist/evasions/sourceurl/index.d.ts.map +1 -1
- package/dist/evasions/sourceurl/index.js +57 -70
- package/dist/evasions/sourceurl/index.js.map +1 -1
- package/dist/evasions/sourceurl/index.ts +104 -0
- package/dist/evasions/types.d.ts +20 -0
- package/dist/evasions/user-agent-override/README.md +283 -33
- package/dist/evasions/user-agent-override/index.d.ts +20 -18
- package/dist/evasions/user-agent-override/index.d.ts.map +1 -1
- package/dist/evasions/user-agent-override/index.js +162 -168
- package/dist/evasions/user-agent-override/index.js.map +1 -1
- package/{src/evasions/user-agent-override/index.js → dist/evasions/user-agent-override/index.ts} +94 -39
- package/dist/evasions/webgl.vendor/README.md +237 -10
- package/dist/evasions/webgl.vendor/index.d.ts +6 -4
- package/dist/evasions/webgl.vendor/index.d.ts.map +1 -1
- package/dist/evasions/webgl.vendor/index.js +37 -42
- package/dist/evasions/webgl.vendor/index.js.map +1 -1
- package/{src/evasions/webgl.vendor/index.js → dist/evasions/webgl.vendor/index.ts} +10 -8
- package/dist/evasions/window.outerdimensions/README.md +257 -8
- package/dist/evasions/window.outerdimensions/index.d.ts +7 -5
- package/dist/evasions/window.outerdimensions/index.d.ts.map +1 -1
- package/dist/evasions/window.outerdimensions/index.js +27 -31
- package/dist/evasions/window.outerdimensions/index.js.map +1 -1
- package/{src/evasions/window.outerdimensions/index.js → dist/evasions/window.outerdimensions/index.ts} +6 -6
- package/dist/index.d.ts +22 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/evasions/_template/index.ts +27 -0
- package/src/evasions/_utils/index.ts +745 -0
- package/src/evasions/_utils/withUtils.ts +83 -0
- package/src/evasions/chrome.app/README.md +225 -6
- package/src/evasions/chrome.app/index.ts +101 -0
- package/src/evasions/chrome.csi/README.md +229 -15
- package/src/evasions/chrome.csi/index.ts +69 -0
- package/src/evasions/chrome.loadTimes/README.md +327 -13
- package/src/evasions/chrome.loadTimes/index.ts +178 -0
- package/src/evasions/chrome.runtime/README.md +346 -17
- package/src/evasions/chrome.runtime/index.ts +268 -0
- package/src/evasions/defaultArgs/README.md +230 -6
- package/src/evasions/defaultArgs/index.ts +54 -0
- package/src/evasions/iframe.contentWindow/README.md +293 -8
- package/src/evasions/iframe.contentWindow/index.ts +138 -0
- package/src/evasions/media.codecs/README.md +282 -19
- package/src/evasions/media.codecs/index.ts +91 -0
- package/src/evasions/navigator.hardwareConcurrency/README.md +150 -9
- package/src/evasions/navigator.hardwareConcurrency/index.ts +47 -0
- package/src/evasions/navigator.languages/README.md +189 -7
- package/src/evasions/navigator.languages/index.ts +49 -0
- package/src/evasions/navigator.permissions/README.md +225 -7
- package/src/evasions/navigator.permissions/index.ts +71 -0
- package/src/evasions/navigator.plugins/README.md +193 -11
- package/src/evasions/navigator.plugins/functionMocks.ts +55 -0
- package/src/evasions/navigator.plugins/index.ts +128 -0
- package/src/evasions/navigator.plugins/magicArray.ts +177 -0
- package/src/evasions/navigator.plugins/mimeTypes.ts +32 -0
- package/src/evasions/navigator.plugins/plugins.ts +32 -0
- package/src/evasions/navigator.vendor/README.md +173 -10
- package/src/evasions/navigator.vendor/index.ts +65 -0
- package/src/evasions/navigator.webdriver/README.md +128 -8
- package/src/evasions/navigator.webdriver/index.ts +56 -0
- package/src/evasions/sourceurl/README.md +222 -7
- package/src/evasions/sourceurl/index.ts +104 -0
- package/src/evasions/types.d.ts +20 -0
- package/src/evasions/user-agent-override/README.md +283 -33
- package/src/evasions/user-agent-override/index.ts +262 -0
- package/src/evasions/webgl.vendor/README.md +237 -10
- package/src/evasions/webgl.vendor/index.ts +59 -0
- package/src/evasions/window.outerdimensions/README.md +257 -8
- package/src/evasions/window.outerdimensions/index.ts +42 -0
- package/src/index.ts +28 -23
- package/tsconfig.json +3 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/evasions/_utils/withUtils.js +0 -47
- package/src/evasions/navigator.plugins/mimeTypes.js +0 -18
- package/src/evasions/navigator.plugins/plugins.js +0 -18
- package/src/evasions/sourceurl/index.js +0 -82
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @zorilla/puppeteer-extra-plugin-stealth
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#16](https://github.com/zorillajs/zorilla/pull/16) [`03c5dee`](https://github.com/zorillajs/zorilla/commit/03c5deedc81be8914b0e193e3d16731f89cbca15) Thanks [@JustinBeckwith](https://github.com/JustinBeckwith)! - Add demo site and comprehensive evasion documentation
|
|
8
|
+
|
|
9
|
+
- Created Cloudflare Worker demo site with 15 bot detection tests
|
|
10
|
+
- Wrote comprehensive documentation for all 17 stealth evasions
|
|
11
|
+
- Added code samples, demo scripts, and testing instructions
|
|
12
|
+
|
|
13
|
+
- [#22](https://github.com/zorillajs/zorilla/pull/22) [`4967570`](https://github.com/zorillajs/zorilla/commit/4967570ed5073b5fa068583b2f599d71c829c80a) Thanks [@JustinBeckwith](https://github.com/JustinBeckwith)! - Convert stealth plugin evasions to TypeScript
|
|
14
|
+
|
|
15
|
+
- Converted all 24 JavaScript files in evasions directory to TypeScript
|
|
16
|
+
- Added comprehensive type annotations throughout
|
|
17
|
+
- Created browser API type augmentations
|
|
18
|
+
- Improved type safety for proxy handlers and browser API mocking
|
|
19
|
+
- No breaking changes or API modifications
|
|
20
|
+
|
|
3
21
|
## 1.0.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { PuppeteerExtraPlugin } from '@zorilla/puppeteer-extra-plugin';
|
|
2
|
+
import type { Page } from 'puppeteer';
|
|
2
3
|
/**
|
|
3
4
|
* Minimal stealth plugin template, not being used. :-)
|
|
4
5
|
*
|
|
5
6
|
* Feel free to copy this folder as the basis for additional detection evasion plugins.
|
|
6
7
|
*/
|
|
7
8
|
declare class Plugin extends PuppeteerExtraPlugin {
|
|
8
|
-
constructor(opts?:
|
|
9
|
-
|
|
9
|
+
constructor(opts?: Record<string, unknown>);
|
|
10
|
+
get name(): string;
|
|
11
|
+
onPageCreated(page: Page): Promise<void>;
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
export default function (pluginConfig?: Record<string, unknown>): Plugin;
|
|
12
14
|
export {};
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evasions/_template/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evasions/_template/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;GAIG;AACH,cAAM,MAAO,SAAQ,oBAAoB;gBAC3B,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAI9C,IAAa,IAAI,IAAI,MAAM,CAE1B;IAEc,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAKxD;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAEvE"}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { PuppeteerExtraPlugin } from '@zorilla/puppeteer-extra-plugin';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Minimal stealth plugin template, not being used. :-)
|
|
5
4
|
*
|
|
6
5
|
* Feel free to copy this folder as the basis for additional detection evasion plugins.
|
|
7
6
|
*/
|
|
8
7
|
class Plugin extends PuppeteerExtraPlugin {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
}
|
|
8
|
+
constructor(opts = {}) {
|
|
9
|
+
super(opts);
|
|
10
|
+
}
|
|
11
|
+
get name() {
|
|
12
|
+
return 'stealth/evasions/_template';
|
|
13
|
+
}
|
|
14
|
+
async onPageCreated(page) {
|
|
15
|
+
await page.evaluateOnNewDocument(() => {
|
|
16
|
+
console.debug('hello world');
|
|
17
|
+
});
|
|
18
|
+
}
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
export default function (pluginConfig) {
|
|
25
|
-
|
|
21
|
+
return new Plugin(pluginConfig);
|
|
26
22
|
}
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/evasions/_template/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/evasions/_template/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE;;;;GAIG;AACH,MAAM,MAAO,SAAQ,oBAAoB;IACvC,YAAY,OAAgC,EAAE;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAED,IAAa,IAAI;QACf,OAAO,4BAA4B,CAAC;IACtC,CAAC;IAEQ,KAAK,CAAC,aAAa,CAAC,IAAU;QACrC,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE;YACpC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,OAAO,WAAW,YAAsC;IAC7D,OAAO,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PuppeteerExtraPlugin } from '@zorilla/puppeteer-extra-plugin';
|
|
2
|
+
import type { Page } from 'puppeteer';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Minimal stealth plugin template, not being used. :-)
|
|
@@ -6,21 +7,21 @@ import { PuppeteerExtraPlugin } from '@zorilla/puppeteer-extra-plugin';
|
|
|
6
7
|
* Feel free to copy this folder as the basis for additional detection evasion plugins.
|
|
7
8
|
*/
|
|
8
9
|
class Plugin extends PuppeteerExtraPlugin {
|
|
9
|
-
constructor(opts = {}) {
|
|
10
|
+
constructor(opts: Record<string, unknown> = {}) {
|
|
10
11
|
super(opts);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
get name() {
|
|
14
|
+
override get name(): string {
|
|
14
15
|
return 'stealth/evasions/_template';
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
async onPageCreated(page) {
|
|
18
|
+
override async onPageCreated(page: Page): Promise<void> {
|
|
18
19
|
await page.evaluateOnNewDocument(() => {
|
|
19
20
|
console.debug('hello world');
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export default function (pluginConfig) {
|
|
25
|
+
export default function (pluginConfig?: Record<string, unknown>): Plugin {
|
|
25
26
|
return new Plugin(pluginConfig);
|
|
26
27
|
}
|
|
@@ -1,238 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A set of shared utility functions specifically for modifying native browser APIs without leaving traces.
|
|
3
|
+
*
|
|
4
|
+
* Meant to be passed down in puppeteer and used in the context of the page (everything in here runs in NodeJS as well as a browser).
|
|
5
|
+
*
|
|
6
|
+
* Note: If for whatever reason you need to use this outside of `puppeteer-extra`:
|
|
7
|
+
* Just remove the `export default` statement at the very bottom, the rest can be copy pasted into any browser context.
|
|
8
|
+
*
|
|
9
|
+
* Alternatively take a look at the `extract-stealth-evasions` package to create a finished bundle which includes these utilities.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
interface UtilsCache {
|
|
13
|
+
Reflect: {
|
|
14
|
+
get: typeof Reflect.get;
|
|
15
|
+
apply: typeof Reflect.apply;
|
|
13
16
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @param {object} descriptorOverrides - e.g. { value: "alice" }
|
|
37
|
-
*/
|
|
38
|
-
function replaceProperty(obj: object, propName: string, descriptorOverrides?: object): object;
|
|
39
|
-
/**
|
|
40
|
-
* Preload a cache of function copies and data.
|
|
41
|
-
*
|
|
42
|
-
* For a determined enough observer it would be possible to overwrite and sniff usage of functions
|
|
43
|
-
* we use in our internal Proxies, to combat that we use a cached copy of those functions.
|
|
44
|
-
*
|
|
45
|
-
* Note: Whenever we add a `Function.prototype.toString` proxy we should preload the cache before,
|
|
46
|
-
* by executing `utils.preloadCache()` before the proxy is applied (so we don't cause recursive lookups).
|
|
47
|
-
*
|
|
48
|
-
* This is evaluated once per execution context (e.g. window)
|
|
49
|
-
*/
|
|
50
|
-
function preloadCache(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Utility function to generate a cross-browser `toString` result representing native code.
|
|
53
|
-
*
|
|
54
|
-
* There's small differences: Chromium uses a single line, whereas FF & Webkit uses multiline strings.
|
|
55
|
-
* To future-proof this we use an existing native toString result as the basis.
|
|
56
|
-
*
|
|
57
|
-
* The only advantage we have over the other team is that our JS runs first, hence we cache the result
|
|
58
|
-
* of the native toString result once, so they cannot spoof it afterwards and reveal that we're using it.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* makeNativeString('foobar') // => `function foobar() { [native code] }`
|
|
62
|
-
*
|
|
63
|
-
* @param {string} [name] - Optional function name
|
|
64
|
-
*/
|
|
65
|
-
function makeNativeString(name?: string): any;
|
|
66
|
-
/**
|
|
67
|
-
* Helper function to modify the `toString()` result of the provided object.
|
|
68
|
-
*
|
|
69
|
-
* Note: Use `utils.redirectToString` instead when possible.
|
|
70
|
-
*
|
|
71
|
-
* There's a quirk in JS Proxies that will cause the `toString()` result to differ from the vanilla Object.
|
|
72
|
-
* If no string is provided we will generate a `[native code]` thing based on the name of the property object.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* patchToString(WebGLRenderingContext.prototype.getParameter, 'function getParameter() { [native code] }')
|
|
76
|
-
*
|
|
77
|
-
* @param {object} obj - The object for which to modify the `toString()` representation
|
|
78
|
-
* @param {string} str - Optional string used as a return value
|
|
79
|
-
*/
|
|
80
|
-
function patchToString(obj: object, str?: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* Make all nested functions of an object native.
|
|
83
|
-
*
|
|
84
|
-
* @param {object} obj
|
|
85
|
-
*/
|
|
86
|
-
function patchToStringNested(obj?: object): object;
|
|
87
|
-
/**
|
|
88
|
-
* Redirect toString requests from one object to another.
|
|
89
|
-
*
|
|
90
|
-
* @param {object} proxyObj - The object that toString will be called on
|
|
91
|
-
* @param {object} originalObj - The object which toString result we wan to return
|
|
92
|
-
*/
|
|
93
|
-
function redirectToString(proxyObj: object, originalObj: object): void;
|
|
94
|
-
/**
|
|
95
|
-
* All-in-one method to replace a property with a JS Proxy using the provided Proxy handler with traps.
|
|
96
|
-
*
|
|
97
|
-
* Will stealthify these aspects (strip error stack traces, redirect toString, etc).
|
|
98
|
-
* Note: This is meant to modify native Browser APIs and works best with prototype objects.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* replaceWithProxy(WebGLRenderingContext.prototype, 'getParameter', proxyHandler)
|
|
102
|
-
*
|
|
103
|
-
* @param {object} obj - The object which has the property to replace
|
|
104
|
-
* @param {string} propName - The name of the property to replace
|
|
105
|
-
* @param {object} handler - The JS Proxy handler to use
|
|
106
|
-
*/
|
|
107
|
-
function replaceWithProxy(obj: object, propName: string, handler: object): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* All-in-one method to replace a getter with a JS Proxy using the provided Proxy handler with traps.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* replaceGetterWithProxy(Object.getPrototypeOf(navigator), 'vendor', proxyHandler)
|
|
113
|
-
*
|
|
114
|
-
* @param {object} obj - The object which has the property to replace
|
|
115
|
-
* @param {string} propName - The name of the property to replace
|
|
116
|
-
* @param {object} handler - The JS Proxy handler to use
|
|
117
|
-
*/
|
|
118
|
-
function replaceGetterWithProxy(obj: object, propName: string, handler: object): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* All-in-one method to replace a getter and/or setter. Functions get and set
|
|
121
|
-
* of handler have one more argument that contains the native function.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* replaceGetterSetter(HTMLIFrameElement.prototype, 'contentWindow', handler)
|
|
125
|
-
*
|
|
126
|
-
* @param {object} obj - The object which has the property to replace
|
|
127
|
-
* @param {string} propName - The name of the property to replace
|
|
128
|
-
* @param {object} handlerGetterSetter - The handler with get and/or set
|
|
129
|
-
* functions
|
|
130
|
-
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description
|
|
131
|
-
*/
|
|
132
|
-
function replaceGetterSetter(obj: object, propName: string, handlerGetterSetter: object): void;
|
|
133
|
-
/**
|
|
134
|
-
* All-in-one method to mock a non-existing property with a JS Proxy using the provided Proxy handler with traps.
|
|
135
|
-
*
|
|
136
|
-
* Will stealthify these aspects (strip error stack traces, redirect toString, etc).
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* mockWithProxy(chrome.runtime, 'sendMessage', function sendMessage() {}, proxyHandler)
|
|
140
|
-
*
|
|
141
|
-
* @param {object} obj - The object which has the property to replace
|
|
142
|
-
* @param {string} propName - The name of the property to replace or create
|
|
143
|
-
* @param {object} pseudoTarget - The JS Proxy target to use as a basis
|
|
144
|
-
* @param {object} handler - The JS Proxy handler to use
|
|
145
|
-
*/
|
|
146
|
-
function mockWithProxy(obj: object, propName: string, pseudoTarget: object, handler: object): boolean;
|
|
147
|
-
/**
|
|
148
|
-
* All-in-one method to create a new JS Proxy with stealth tweaks.
|
|
149
|
-
*
|
|
150
|
-
* This is meant to be used whenever we need a JS Proxy but don't want to replace or mock an existing known property.
|
|
151
|
-
*
|
|
152
|
-
* Will stealthify certain aspects of the Proxy (strip error stack traces, redirect toString, etc).
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* createProxy(navigator.mimeTypes.__proto__.namedItem, proxyHandler) // => Proxy
|
|
156
|
-
*
|
|
157
|
-
* @param {object} pseudoTarget - The JS Proxy target to use as a basis
|
|
158
|
-
* @param {object} handler - The JS Proxy handler to use
|
|
159
|
-
*/
|
|
160
|
-
function createProxy(pseudoTarget: object, handler: object): any;
|
|
161
|
-
/**
|
|
162
|
-
* Helper function to split a full path to an Object into the first part and property.
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* splitObjPath(`HTMLMediaElement.prototype.canPlayType`)
|
|
166
|
-
* // => {objName: "HTMLMediaElement.prototype", propName: "canPlayType"}
|
|
167
|
-
*
|
|
168
|
-
* @param {string} objPath - The full path to an object as dot notation string
|
|
169
|
-
*/
|
|
170
|
-
function splitObjPath(objPath: string): {
|
|
17
|
+
nativeToStringStr: string;
|
|
18
|
+
}
|
|
19
|
+
interface Utils {
|
|
20
|
+
cache?: UtilsCache;
|
|
21
|
+
init: () => void;
|
|
22
|
+
preloadCache: () => void;
|
|
23
|
+
stripProxyFromErrors: <T extends object>(handler?: ProxyHandler<T>) => ProxyHandler<T>;
|
|
24
|
+
stripErrorWithAnchor: (err: Error, anchor: string) => Error;
|
|
25
|
+
replaceProperty: <T extends object>(obj: T, propName: string | symbol, descriptorOverrides: PropertyDescriptor) => T;
|
|
26
|
+
makeNativeString: (name?: string) => string;
|
|
27
|
+
patchToString: (obj: Function, str?: string) => void;
|
|
28
|
+
patchToStringNested: (obj: object) => object;
|
|
29
|
+
redirectToString: (proxyObj: Function, originalObj: Function) => void;
|
|
30
|
+
replaceWithProxy: <T extends object>(obj: T, propName: string | symbol, handler: ProxyHandler<object>) => boolean;
|
|
31
|
+
replaceGetterWithProxy: <T extends object>(obj: T, propName: string | symbol, handler: ProxyHandler<Function>) => boolean;
|
|
32
|
+
replaceGetterSetter: <T extends object>(obj: T, propName: string | symbol, handlerGetterSetter: {
|
|
33
|
+
get?: (nativeFn: Function) => unknown;
|
|
34
|
+
set?: (newValue: unknown, nativeFn: Function) => void;
|
|
35
|
+
}) => void;
|
|
36
|
+
mockWithProxy: <T extends object>(obj: T, propName: string | symbol, pseudoTarget: object, handler: ProxyHandler<object>) => boolean;
|
|
37
|
+
createProxy: <T extends object>(pseudoTarget: T, handler: ProxyHandler<T>) => T;
|
|
38
|
+
splitObjPath: (objPath: string) => {
|
|
171
39
|
objName: string;
|
|
172
|
-
propName: string
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Convenience method to replace a property with a JS Proxy using the provided objPath.
|
|
176
|
-
*
|
|
177
|
-
* Supports a full path (dot notation) to the object as string here, in case that makes it easier.
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* replaceObjPathWithProxy('WebGLRenderingContext.prototype.getParameter', proxyHandler)
|
|
181
|
-
*
|
|
182
|
-
* @param {string} objPath - The full path to an object (dot notation string) to replace
|
|
183
|
-
* @param {object} handler - The JS Proxy handler to use
|
|
184
|
-
*/
|
|
185
|
-
function replaceObjPathWithProxy(objPath: string, handler: object): boolean;
|
|
186
|
-
/**
|
|
187
|
-
* Traverse nested properties of an object recursively and apply the given function on a whitelist of value types.
|
|
188
|
-
*
|
|
189
|
-
* @param {object} obj
|
|
190
|
-
* @param {array} typeFilter - e.g. `['function']`
|
|
191
|
-
* @param {Function} fn - e.g. `utils.patchToString`
|
|
192
|
-
*/
|
|
193
|
-
function execRecursively(obj: object | undefined, typeFilter: array, fn: Function): object;
|
|
194
|
-
/**
|
|
195
|
-
* Everything we run through e.g. `page.evaluate` runs in the browser context, not the NodeJS one.
|
|
196
|
-
* That means we cannot just use reference variables and functions from outside code, we need to pass everything as a parameter.
|
|
197
|
-
*
|
|
198
|
-
* Unfortunately the data we can pass is only allowed to be of primitive types, regular functions don't survive the built-in serialization process.
|
|
199
|
-
* This utility function will take an object with functions and stringify them, so we can pass them down unharmed as strings.
|
|
200
|
-
*
|
|
201
|
-
* We use this to pass down our utility functions as well as any other functions (to be able to split up code better).
|
|
202
|
-
*
|
|
203
|
-
* @see utils.materializeFns
|
|
204
|
-
*
|
|
205
|
-
* @param {object} fnObj - An object containing functions as properties
|
|
206
|
-
*/
|
|
207
|
-
function stringifyFns(fnObj?: object): {
|
|
208
|
-
[k: string]: any;
|
|
40
|
+
propName: string;
|
|
209
41
|
};
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
function materializeFns(fnStrObj?: object): {
|
|
217
|
-
[k: string]: any;
|
|
42
|
+
replaceObjPathWithProxy: (objPath: string, handler: ProxyHandler<object>) => boolean;
|
|
43
|
+
execRecursively: (obj: object, typeFilter: string[], fn: Function) => object;
|
|
44
|
+
stringifyFns: (fnObj: Record<string, Function>) => Record<string, string>;
|
|
45
|
+
materializeFns: (fnStrObj: Record<string, string>) => Record<string, Function>;
|
|
46
|
+
makeHandler: () => {
|
|
47
|
+
getterValue: (value: unknown) => ProxyHandler<Function>;
|
|
218
48
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
apply(_target: any, _ctx: any, _args: any, ...args: any[]): any;
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Compare two arrays.
|
|
226
|
-
*
|
|
227
|
-
* @param {array} array1 - First array
|
|
228
|
-
* @param {array} array2 - Second array
|
|
229
|
-
*/
|
|
230
|
-
function arrayEquals(array1: array, array2: array): boolean;
|
|
231
|
-
/**
|
|
232
|
-
* Cache the method return according to its arguments.
|
|
233
|
-
*
|
|
234
|
-
* @param {Function} fn - A function that will be cached
|
|
235
|
-
*/
|
|
236
|
-
function memoize(fn: Function): (...args: any[]) => any;
|
|
49
|
+
arrayEquals: <T>(array1: T[], array2: T[]) => boolean;
|
|
50
|
+
memoize: <T extends Function>(fn: T) => T;
|
|
237
51
|
}
|
|
52
|
+
declare const utils: Utils;
|
|
53
|
+
export default utils;
|
|
238
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evasions/_utils/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evasions/_utils/index.ts"],"names":[],"mappings":"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"}
|