Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-extra-plugin-stealth

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-extra-plugin-stealth - npm Package Compare versions

Comparing version 2.7.5 to 2.7.6

10

evasions/iframe.contentWindow/index.test.js

@@ -266,2 +266,4 @@ const test = require('ava')

page.waitForTimeout = page.waitForTimeout || page.waitFor
await page.goto('https://www.fbdemo.com/invisible-captcha/index.html')

@@ -276,4 +278,5 @@

await page.click('#tswsubmit')
await page.waitFor(1000)
await page.waitForTimeout(1000)
const { hasRecaptchaPopup } = await page.evaluate(() => {

@@ -295,2 +298,3 @@ const hasRecaptchaPopup = !!document.querySelectorAll(

page.waitForTimeout = page.waitForTimeout || page.waitFor
// Old method

@@ -300,3 +304,3 @@ await page.evaluateOnNewDocument(() => {

Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', {
get: function() {
get: function () {
return window

@@ -316,3 +320,3 @@ }

await page.click('#tswsubmit')
await page.waitFor(1000)
await page.waitForTimeout(1000)

@@ -319,0 +323,0 @@ const { hasRecaptchaPopup } = await page.evaluate(() => {

@@ -18,6 +18,12 @@ 'use strict'

// Pre Chrome 88.0.4291.0
async onPageCreated(page) {
await page.evaluateOnNewDocument(() => {
delete Object.getPrototypeOf(navigator).webdriver
if (navigator.webdriver === false) {
// Post Chrome 89.0.4339.0 and already good
} else if (navigator.webdriver === undefined) {
// Pre Chrome 89.0.4339.0 and already good
} else {
// Pre Chrome 88.0.4291.0 and needs patching
delete Object.getPrototypeOf(navigator).webdriver
}
})

@@ -24,0 +30,0 @@ }

const test = require('ava')
const { vanillaPuppeteer, addExtra } = require('../../test/util')
const { vanillaPuppeteer, addExtra, compareLooseVersionStrings } = require('../../test/util')
const Plugin = require('.')
function getExpectedValue(looseVersionString) {
if (compareLooseVersionStrings(looseVersionString, '89.0.4339.0') >= 0) {
return false
} else {
return undefined
}
}
test('vanilla: navigator.webdriver is defined', async t => {

@@ -20,3 +28,4 @@ const browser = await vanillaPuppeteer.launch({ headless: true })

const data = await page.evaluate(() => navigator.webdriver)
t.is(data, undefined)
// XXX: launch this test multiple times with browsers of different versions?
t.is(data, getExpectedValue(await browser.version()))
})

@@ -23,0 +32,0 @@

{
"name": "puppeteer-extra-plugin-stealth",
"version": "2.7.5",
"version": "2.7.6",
"description": "Stealth mode: Applies various techniques to make detection of headless puppeteer harder.",

@@ -55,6 +55,6 @@ "main": "index.js",

"debug": "^4.1.1",
"puppeteer-extra-plugin": "^3.1.8",
"puppeteer-extra-plugin-user-preferences": "^2.2.11"
"puppeteer-extra-plugin": "^3.1.9",
"puppeteer-extra-plugin-user-preferences": "^2.2.12"
},
"gitHead": "704502b1005fbe1ac1e2149ffd3715cc7629b50c"
"gitHead": "adcc26325c9a01febcd152e5fb79555b29187a5f"
}

@@ -39,3 +39,3 @@ # puppeteer-extra-plugin-stealth [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/berstend/puppeteer-extra/Test/master)](https://github.com/berstend/puppeteer-extra/actions) [![Discord](https://img.shields.io/discord/737009125862408274)](http://scraping-chat.cf) [![npm](https://img.shields.io/npm/v/puppeteer-extra-plugin-stealth.svg)](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth)

await page.goto('https://bot.sannysoft.com')
await page.waitFor(5000)
await page.waitForTimeout(5000)
await page.screenshot({ path: 'testresult.png', fullPage: true })

@@ -63,3 +63,3 @@ await browser.close()

await page.goto('https://bot.sannysoft.com')
await page.waitFor(5000)
await page.waitForTimeout(5000)
await page.screenshot({ path: 'stealth.png', fullPage: true })

@@ -66,0 +66,0 @@ await browser.close()

const test = require('ava')
const { vanillaPuppeteer, addExtra } = require('./util')
const { vanillaPuppeteer, addExtra, compareLooseVersionStrings } = require('./util')
const Plugin = require('..')

@@ -20,2 +20,3 @@

const page = await browser.newPage()
await page.exposeFunction('compareLooseVersionStrings', compareLooseVersionStrings)
const detectionResults = await page.evaluate(detectHeadless)

@@ -49,28 +50,35 @@ await browser.close()

// Detects the --enable-automation || --headless flags
// Will return true in headful if --enable-automation is provided
await test('navigator.webdriver present', _ => {
return 'webdriver' in navigator
})
// navigator.webdriver behavior change since release 89.0.4339.0. See also #448
if (await compareLooseVersionStrings(navigator.userAgent, '89.0.4339.0') >= 0) {
await test('navigator.webdriver is not false', _ => {
return navigator.webdriver !== false
})
} else {
// Detects the --enable-automation || --headless flags
// Will return true in headful if --enable-automation is provided
await test('navigator.webdriver present', _ => {
return 'webdriver' in navigator
})
await test('navigator.webdriver not undefined', _ => {
return navigator.webdriver !== undefined
})
await test('navigator.webdriver not undefined', _ => {
return navigator.webdriver !== undefined
})
/* eslint-disable no-proto */
await test('navigator.webdriver property overridden', _ => {
return (
Object.getOwnPropertyDescriptor(navigator.__proto__, 'webdriver') !==
undefined
)
})
/* eslint-disable no-proto */
await test('navigator.webdriver property overridden', _ => {
return (
Object.getOwnPropertyDescriptor(navigator.__proto__, 'webdriver') !==
undefined
)
})
await test('navigator.webdriver prop detected', _ => {
for (const prop in navigator) {
if (prop === 'webdriver') {
return true
await test('navigator.webdriver prop detected', _ => {
for (const prop in navigator) {
if (prop === 'webdriver') {
return true
}
}
}
return false
})
return false
})
}

@@ -77,0 +85,0 @@ await test('window.chrome missing', _ => {

@@ -5,3 +5,3 @@ const test = require('ava')

const { getVanillaFingerPrint, getStealthFingerPrint } = require('./util')
const { getVanillaFingerPrint, getStealthFingerPrint, compareLooseVersionStrings } = require('./util')
const Plugin = require('../.')

@@ -45,3 +45,10 @@

}
t.is(failedChecks.length, 0)
if (compareLooseVersionStrings(fingerPrint.userAgent, '89.0.4339.0') >= 0) {
// Updated navigator.webdriver behavior breaks the fpscanner tests.
t.is(failedChecks.length, 1)
t.is(failedChecks[0].name, 'WEBDRIVER')
} else {
t.is(failedChecks.length, 0)
}
})

@@ -0,1 +1,2 @@

const assert = require('assert')
const vanillaPuppeteer = require('puppeteer')

@@ -33,2 +34,26 @@ const { addExtra } = require('puppeteer-extra')

// Expecting the input string to be in one of these formats:
// - The UA string
// - The shorter version string from Puppeteers browser.version()
// - The shortest four-integer string
const parseLooseVersionString = looseVersionString => looseVersionString
.match(/(\d+\.){3}\d+/)[0]
.split('.')
.map(x => parseInt(x))
const compareLooseVersionStrings = (version0, version1) => {
const parsed0 = parseLooseVersionString(version0)
const parsed1 = parseLooseVersionString(version1)
assert(parsed0.length == 4)
assert(parsed1.length == 4)
for (let i = 0; i < parsed0.length; i++) {
if (parsed0[i] < parsed1[i]) {
return -1
} else if (parsed0[i] > parsed1[i]) {
return 1
}
}
return 0
}
module.exports = {

@@ -39,3 +64,4 @@ getVanillaFingerPrint,

vanillaPuppeteer,
addExtra
addExtra,
compareLooseVersionStrings
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc