Compare commits

..

No commits in common. "1d31b79f1e0b8b058e892d2420f95f7823295648" and "02a30a483184e11a9a2e89016c0da7fea78183ad" have entirely different histories.

3 changed files with 40 additions and 75 deletions

View File

@ -21,11 +21,7 @@ export type HAREntry = {
method: string; method: string;
postData?: { postData?: {
mimeType: string; mimeType: string;
params: (NameValue & { params: NameValue[];
fileName: string;
contentType: string;
comment: "";
})[];
text: string; text: string;
}; };
queryString: NameValue[]; queryString: NameValue[];
@ -205,7 +201,8 @@ export default class ExtendedRequest {
this.requestBody.raw || {} this.requestBody.raw || {}
).map(([key, value], index) => [`${key}.${index}`, value]) ).map(([key, value], index) => [`${key}.${index}`, value])
), ),
}).map(([key, value]) => { })
.map(([key, value]) => {
// to handle how ocdn.eu encrypts POST body on https://businessinsider.com.pl/ // to handle how ocdn.eu encrypts POST body on https://businessinsider.com.pl/
if ( if (
(Array.isArray(value) && value.length === 1 && !value[0]) || (Array.isArray(value) && value.length === 1 && !value[0]) ||
@ -220,8 +217,11 @@ export default class ExtendedRequest {
} else { } else {
return [key, value || ""]; return [key, value || ""];
} }
}), })
StolenDataEntry.parseValue .map(([key, value]) => {
const parsed = StolenDataEntry.parseValue(value);
return [key, parsed];
}) as [string, unknown][]
).map( ).map(
([key, value]) => new StolenDataEntry(this, "request_body", key, value) ([key, value]) => new StolenDataEntry(this, "request_body", key, value)
); );
@ -319,14 +319,10 @@ export default class ExtendedRequest {
pageref: "page_1", pageref: "page_1",
startedDateTime: `${new Date().toJSON().replace("Z", "+01:00")}`, startedDateTime: `${new Date().toJSON().replace("Z", "+01:00")}`,
request: { request: {
bodySize: bodySize: 0,
JSON.stringify(this.requestBody.formData || {}).length +
(this.requestBody.raw || [])
.map((e) => e.bytes.byteLength)
.reduce((a, b) => a + b, 0),
method: this.data.method, method: this.data.method,
url: this.data.url, url: this.data.url,
headersSize: JSON.stringify(this.requestHeaders).length, headersSize: 100,
httpVersion: "HTTP/2", httpVersion: "HTTP/2",
headers: this.requestHeaders as NameValue[], headers: this.requestHeaders as NameValue[],
cookies: this.getCookieData().map((cookie) => ({ cookies: this.getCookieData().map((cookie) => ({
@ -337,22 +333,6 @@ export default class ExtendedRequest {
name: param.name, name: param.name,
value: param.value, value: param.value,
})), })),
postData: {
mimeType: "application/x-www-form-urlencoded",
params: this.stolenData
.filter((e) => e.source == "request_body")
.map((e) => ({
name: e.name,
value: e.value,
fileName: "--" + Math.ceil(Math.random() * 1000000000),
contentType: "text/plain",
comment: "",
})),
text: this.stolenData
.filter((e) => e.source == "request_body")
.map((e) => `${e.name}:\t${StolenDataEntry.parseValue(e.value)}`)
.join("\n\n"),
},
}, },
response: { response: {
status: 200, status: 200,

View File

@ -1,5 +1,3 @@
import ExtendedRequest from "./extended-request";
import { StolenDataEntry } from "./stolen-data-entry";
import { flattenObject, maskString } from "./util"; import { flattenObject, maskString } from "./util";
console.log(flattenObject({ a: { b: { c: [1, 2, 3] } } })); console.log(flattenObject({ a: { b: { c: [1, 2, 3] } } }));
@ -7,9 +5,3 @@ console.log(flattenObject({ a: { b: { c: [1, 2, 3] } } }));
console.log(maskString("abcdefghijklmnopqrstuvwxyz", 1 / 3, 5)); console.log(maskString("abcdefghijklmnopqrstuvwxyz", 1 / 3, 5));
console.log(maskString("abcdefghijklmnopqrstuvwxyz", 1, 30)); console.log(maskString("abcdefghijklmnopqrstuvwxyz", 1, 30));
console.log(
StolenDataEntry.parseValue(
`[{"@context":"https://schema.org/","@type":"Product","image":["/medias/sys_master/root/images/h95/h8b/10873724928030/oppo-reno6-black-front.png","/medias/sys_master/root/images/h15/hb9/10873725681694/oppo-reno6-black-side.png","/medias/sys_master/root/images/hf8/h81/10873728729118/oppo-reno6-black-back.png"],"description":"OPPO Reno6 5G bez umowy lub w abonamencie w sklepie Orange. Zamów do domu lub odbierz w salonie w 24h. Transport gratis!","sku":"1100027218","brand":{"@type":"Thing","name":"OPPO"},"offers":{"@type":"Offer","priceCurrency":"PLN","priceValidUntil":"2099-12-31T00:00:00","itemCondition":"https://schema.org/UsedCondition","availability":"https://schema.org/InStock","url":"/esklep/smartfony/oppo/oppo-reno6-5g","seller":{"@type":"Organization","name":"Orange Polska S.A"},"price":"2199"},"name":"OPPO Reno6 5G"},{"@context":"http://schema.org/","@type":"Product","name":"OPPO Reno6 5G","description":"null","offers":{"@type":"Offer","priceCurrency":"PLN","price":"1248.00"}}]`
)
);

35
util.ts
View File

@ -197,38 +197,31 @@ export function isBase64JSON(s: unknown): s is string {
} }
export function flattenObject( export function flattenObject(
obj: unknown, obj: Record<string, unknown>
parser: (to_parse: unknown) => string | Record<string, unknown> = (id) =>
id.toString(),
key = "",
ret = [],
parsed = false
): [string, string][] { ): [string, string][] {
if (Array.isArray(obj)) { const ret: [string, string][] = [];
for (let i in obj) { for (const [key, value] of Object.entries(obj)) {
flattenObject(obj[i], parser, key + "." + i, ret); const value = obj[key];
if (value === null) {
ret.push([key, "null"]);
continue;
} }
} else if (typeof obj === "object") { if (typeof value === "object") {
for (const [subkey, value] of Object.entries(obj)) { const flattened = flattenObject(value as Record<string, unknown>);
flattenObject(value, parser, key + "." + subkey, ret); for (const [subkey, subvalue] of flattened) {
ret.push([`${key}.${subkey}`, subvalue]);
} }
} else if (!parsed) {
flattenObject(parser(obj), parser, key, ret, true);
} else { } else {
ret.push([key, obj]); ret.push([key, value ? value.toString() : "<empty>"]);
} }
if (key == "") {
console.log("FLATTENING!", obj, ret);
} }
return ret; return ret;
} }
export function flattenObjectEntries( export function flattenObjectEntries(
entries: [string, unknown][], entries: [string, unknown][]
parser: (to_parse: unknown) => string | Record<string, unknown> = (id) =>
id.toString()
): [string, string][] { ): [string, string][] {
return flattenObject(Object.fromEntries(entries), parser); return flattenObject(Object.fromEntries(entries));
} }
export function maskString( export function maskString(