Print all the full hosts so they are easier to visit and get tainted

with cookies
This commit is contained in:
Kuba Orlik 2021-11-07 17:18:17 +01:00
parent 86bd7f72b6
commit 7fdc2a3660
4 changed files with 43 additions and 8 deletions

View File

@ -164,4 +164,8 @@ export default class ExtendedRequest {
getMarkedEntries() {
return this.stolenData.filter((data) => data.hasMark());
}
getHost() {
return new URL(this.url).host;
}
}

View File

@ -4,7 +4,14 @@ import ExtendedRequest from "./extended-request";
export type Sources = "cookie" | "pathname" | "queryparams" | "header";
import { TCString, TCModel } from "@iabtcf/core";
import { getMemory, isJSONObject, isURL, parseToObject } from "./util";
import {
allSubhosts,
getMemory,
isJSONObject,
isURL,
parseToObject,
unique,
} from "./util";
const id = (function* id() {
let i = 0;
@ -45,7 +52,7 @@ export class StolenDataEntry {
priority += 100;
}
if (this.source === "cookie") {
priority += 100;
priority += 200;
}
return priority;
}
@ -68,11 +75,9 @@ export class StolenDataEntry {
host: url.host,
path: url.pathname,
...Object.fromEntries(
(
url.searchParams as unknown as {
((url.searchParams as unknown) as {
entries: () => Iterable<[string, string]>;
}
).entries()
}).entries()
),
};
return object;
@ -257,4 +262,12 @@ export class RequestCluster extends EventEmitter {
getMarkedRequests() {
return this.requests.filter((request) => request.hasMark());
}
getFullHosts() {
return unique(
this.requests
.map((request) => allSubhosts(request.getHost()))
.reduce((a, b) => a.concat(b), [])
);
}
}

View File

@ -1,5 +1,5 @@
import React from "react";
import memory from "../memory";
import { MergedStolenDataEntry, Sources } from "../request-cluster";
import { getMemory, hyphenate } from "../util";
@ -101,6 +101,11 @@ export default function StolenDataCluster({
Wyczyść cookiesy
</a>
</h2>
<div>
{cluster.getFullHosts().map((host) => (
<a href={`https://${host}`}>{host}, </a>
))}
</div>
<table>
<tbody>
{cluster

13
util.ts
View File

@ -86,3 +86,16 @@ export function hyphenate(str: string): string {
export function getMemory(): Memory {
return (browser.extension.getBackgroundPage().window as any).memory as Memory;
}
export function unique(array: string[]) {
return Array.from(new Set(array));
}
export function allSubhosts(host: string) {
const parts = host.split(".");
const result = [];
for (let i = 0; i < parts.length - 2; i++) {
result.push(parts.slice(i).join("."));
}
return result;
}