Skip to content

Commit

Permalink
fix: evasion - utils path
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoooqq committed Nov 7, 2021
1 parent f8535ad commit a8d080b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fakebrowser",
"version": "0.0.44",
"version": "0.0.47",
"description": "Fake fingerprints to bypass anti-bot systems. Simulate mouse and keyboard operations to make behavior like a real person.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -64,7 +64,7 @@
"cross-env": "^7.0.3",
"express": "^4.17.1",
"jest": "^27.3.1",
"puppeteer": "^10.4.0",
"puppeteer": "^11.0.0",
"rimraf": "^3.0.2",
"ts-node": "^10.4.0",
"typescript": "^4.4.4"
Expand Down
5 changes: 5 additions & 0 deletions src/core/DeviceDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ export default class DeviceDescriptorHelper {
if (!e.mimeTypes || !e.mimeTypes.length) {
throw new Error('mimeTypes cannot be empty')
}

// permissions
if (!e.permissions || Object.keys(e.permissions).length === 0) {
throw new Error('permissions cannot be empty')
}
}

/**
Expand Down
30 changes: 28 additions & 2 deletions src/core/FakeBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,35 @@ class FakeBrowserLauncher {

// Read from existing files, or generate if not available.
const fakeDDPathName = path.resolve(userDataDir, `./${kFakeDDFileName}`)
const tempFakeDD = (fs.existsSync(fakeDDPathName) ? fs.readJsonSync(fakeDDPathName) : launchParams.deviceDesc) as FakeDeviceDescriptor
let tempFakeDD: FakeDeviceDescriptor | null = null

try {
tempFakeDD = (
fs.existsSync(fakeDDPathName)
? fs.readJsonSync(fakeDDPathName)
: launchParams.deviceDesc
) as FakeDeviceDescriptor

DeviceDescriptorHelper.checkLegal(tempFakeDD)
} catch (ex: any) {
console.warn('FakeDD illegal')

// It is possible that some fields are missing due to the deviceDesc update and need to recreate fakeDD
const orgTempFakeDD = tempFakeDD

tempFakeDD = launchParams.deviceDesc as FakeDeviceDescriptor

if (orgTempFakeDD) {
tempFakeDD.fontSalt = orgTempFakeDD.fontSalt
tempFakeDD.canvasSalt = orgTempFakeDD.canvasSalt
}
}

const {
fakeDeviceDesc,
needsUpdate
} = DeviceDescriptorHelper.buildFakeDeviceDescriptor(tempFakeDD)

const {fakeDeviceDesc, needsUpdate} = DeviceDescriptorHelper.buildFakeDeviceDescriptor(tempFakeDD)
if (needsUpdate) {
fs.writeJsonSync(fakeDDPathName, fakeDeviceDesc, {spaces: 2})
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/PptrPatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export class PptrPatcher {

static async evasionsCode(pptr: PuppeteerExtra) {
let jsPatch = ''
const utils = require('.../plugins/evasions/_utils');
const utils = require('../plugins/evasions/_utils');

// utils
let utilsContent =
Expand Down

0 comments on commit a8d080b

Please sign in to comment.