如何捕获远程网站上使用的 cookie、像素等跟踪器?
How to capture trackers like cookies, pixels, etc., used on a remote website?
我们正在开展一个类似于 CookieBot 的项目,作为保护网络用户的个人数据和信息的更大项目的一部分。目的是获得有关跟踪和分析技术的全面信息,以便用户可以自行决定是否允许使用它们。但网站的前所有者必须知道它。
我们如何以拦截请求和 cookie 的方式访问网站?
您可以尝试使用 puppeteer,它允许您通过 JavaScript.
编写脚本 Chrome(或 Chromium)
在这个例子中:
- 我去这个页面
- 我打印所有从此页面发出的请求
- 我打印本页设置的所有cookies
// pptr.js
const puppeteer = require('puppeteer-core');
module.exports = async () => {
const browser = await puppeteer.connect({ browserWSEndpoint: 'ws://localhost:3001' });
const page = await browser.newPage();
page.on('request', req => {
console.log(`request: ${req.url()}`);
});
await page.goto('
const cookies = await page.cookies();
console.log('Cookies:');
cookies.forEach(cookie => {
console.log(`${cookie.name}\t${cookie.value}`);
});
await browser.close();
};
您可以运行如下:
node -p -e 'require("./pptr.js")()'
输出:
request:
request:
request: https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
request: https://cdn.sstatic.net/Js/stub.en.js?v=e10313546043
request: https://cdn.sstatic.net/Shared/stacks.css?v=3b16a418cc4c
request: https://cdn.sstatic.net/Sites/Whosebug/primary.css?v=8cf2d7217e38
request: https://www.gravatar.com/avatar/79435cc2571ffa23dfcef703f8d762e0?s=32&d=identicon&r=PG
request: https://www.gravatar.com/avatar/f7c922ac3a9edef38d31baf959088f77?s=32&d=identicon&r=PG&f=1
request: https://cdn.sstatic.net/Img/unified/sprites.svg?v=fcc0ea44ba27
request: https://cdn.sstatic.net/Img/favicons-sprite16.png?v=f4676f10d215
request: https://cdn.sstatic.net/clc/clc.min.js?v=d7c7e62bd2f5
request: https://www.googletagservices.com/tag/js/gpt.js
request: https://www.google-analytics.com/analytics.js
request: https://secure.quantserve.com/quant.js
request: https://sb.scorecardresearch.com/beacon.js
request: https://cdn.sstatic.net/Js/full-anon.en.js?v=2d9c6897045f
request: https://cdn.sstatic.net/clc/styles/clc.min.css?v=83419f27e8fa
request: https://cdn.sstatic.net/Js/post-validation.en.js?v=2589ce0a8248
request: https://whosebug.com/posts/64901406/ivc/6697?_=1605741791032
request: https://cdn.sstatic.net/Img/unified/wmd-buttons.svg?v=c26278fc22d9
request: https://rules.quantcount.com/rules-p-c1rF4kxgLUzNc.js
request: https://pixel.quantserve.com/pixel;r=1818481277;rf=0;uht=2;a=p-c1rF4kxgLUzNc;url=https%3A%2F%2Fwhosebug.com%2Fquestions%2F64901406%2Fhow-to-capture-trackers-like-cookies-pixels-etc-used-on-a-remote-website;fpan=1;fpa=P0-221458664-1605741791402;ns=0;ce=1;qjs=1;qv=3364aec3-20201006003021;cm=;gdpr=0;ref=;d=whosebug.com;je=0;sr=800x600x24;dst=0;et=1605741791401;tzo=0;ogl=type.website%2Curl.https%3A%2F%2FWhosebug%252Ecom%2Fquestions%2F64901406%2Fhow-to-capture-trackers-like-cookie%2Csite_name.Stack%20Overflow%2Cimage.https%3A%2F%2Fcdn%252Esstatic%252Enet%2FSites%2FWhosebug%2FImg%2Fapple-touch-icon%402%252Epng%3Fv%3D73d79a8%2Ctitle.How%20to%20capture%20trackers%20like%20cookies%252C%20pixels%252C%20etc%252E%252C%20used%20on%20a%20remote%20website%3F%2Cdescription.We%20are%20working%20on%20a%20project%20similar%20to%20CookieBot%20as%20part%20of%20a%20larger%20project%20to%20
Cookies:
__qca P0-221458664-1605741791402
prov d91ccb9e-35d8-78ff-61b2-2c157d6d65c7
我们正在开展一个类似于 CookieBot 的项目,作为保护网络用户的个人数据和信息的更大项目的一部分。目的是获得有关跟踪和分析技术的全面信息,以便用户可以自行决定是否允许使用它们。但网站的前所有者必须知道它。
我们如何以拦截请求和 cookie 的方式访问网站?
您可以尝试使用 puppeteer,它允许您通过 JavaScript.
编写脚本 Chrome(或 Chromium)在这个例子中:
- 我去这个页面
- 我打印所有从此页面发出的请求
- 我打印本页设置的所有cookies
// pptr.js
const puppeteer = require('puppeteer-core');
module.exports = async () => {
const browser = await puppeteer.connect({ browserWSEndpoint: 'ws://localhost:3001' });
const page = await browser.newPage();
page.on('request', req => {
console.log(`request: ${req.url()}`);
});
await page.goto('
const cookies = await page.cookies();
console.log('Cookies:');
cookies.forEach(cookie => {
console.log(`${cookie.name}\t${cookie.value}`);
});
await browser.close();
};
您可以运行如下:
node -p -e 'require("./pptr.js")()'
输出:
request:
request:
request: https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
request: https://cdn.sstatic.net/Js/stub.en.js?v=e10313546043
request: https://cdn.sstatic.net/Shared/stacks.css?v=3b16a418cc4c
request: https://cdn.sstatic.net/Sites/Whosebug/primary.css?v=8cf2d7217e38
request: https://www.gravatar.com/avatar/79435cc2571ffa23dfcef703f8d762e0?s=32&d=identicon&r=PG
request: https://www.gravatar.com/avatar/f7c922ac3a9edef38d31baf959088f77?s=32&d=identicon&r=PG&f=1
request: https://cdn.sstatic.net/Img/unified/sprites.svg?v=fcc0ea44ba27
request: https://cdn.sstatic.net/Img/favicons-sprite16.png?v=f4676f10d215
request: https://cdn.sstatic.net/clc/clc.min.js?v=d7c7e62bd2f5
request: https://www.googletagservices.com/tag/js/gpt.js
request: https://www.google-analytics.com/analytics.js
request: https://secure.quantserve.com/quant.js
request: https://sb.scorecardresearch.com/beacon.js
request: https://cdn.sstatic.net/Js/full-anon.en.js?v=2d9c6897045f
request: https://cdn.sstatic.net/clc/styles/clc.min.css?v=83419f27e8fa
request: https://cdn.sstatic.net/Js/post-validation.en.js?v=2589ce0a8248
request: https://whosebug.com/posts/64901406/ivc/6697?_=1605741791032
request: https://cdn.sstatic.net/Img/unified/wmd-buttons.svg?v=c26278fc22d9
request: https://rules.quantcount.com/rules-p-c1rF4kxgLUzNc.js
request: https://pixel.quantserve.com/pixel;r=1818481277;rf=0;uht=2;a=p-c1rF4kxgLUzNc;url=https%3A%2F%2Fwhosebug.com%2Fquestions%2F64901406%2Fhow-to-capture-trackers-like-cookies-pixels-etc-used-on-a-remote-website;fpan=1;fpa=P0-221458664-1605741791402;ns=0;ce=1;qjs=1;qv=3364aec3-20201006003021;cm=;gdpr=0;ref=;d=whosebug.com;je=0;sr=800x600x24;dst=0;et=1605741791401;tzo=0;ogl=type.website%2Curl.https%3A%2F%2FWhosebug%252Ecom%2Fquestions%2F64901406%2Fhow-to-capture-trackers-like-cookie%2Csite_name.Stack%20Overflow%2Cimage.https%3A%2F%2Fcdn%252Esstatic%252Enet%2FSites%2FWhosebug%2FImg%2Fapple-touch-icon%402%252Epng%3Fv%3D73d79a8%2Ctitle.How%20to%20capture%20trackers%20like%20cookies%252C%20pixels%252C%20etc%252E%252C%20used%20on%20a%20remote%20website%3F%2Cdescription.We%20are%20working%20on%20a%20project%20similar%20to%20CookieBot%20as%20part%20of%20a%20larger%20project%20to%20
Cookies:
__qca P0-221458664-1605741791402
prov d91ccb9e-35d8-78ff-61b2-2c157d6d65c7