From 8cf9ce6d71478479f50c95c324cba5e6ea3d6cba Mon Sep 17 00:00:00 2001 From: coomdev Date: Sun, 17 Jul 2022 23:45:10 +0200 Subject: [PATCH] Remove some false positives --- chrome/dist/main.js | 24 +++++++++++++++++------- chrome/manifest.json | 2 +- dist/main.js | 24 +++++++++++++++++------- main.meta.js | 2 +- main.user.js | 26 ++++++++++++++++++-------- src/pngv3.ts | 27 +++++++++++++++++++++------ 6 files changed, 75 insertions(+), 30 deletions(-) diff --git a/chrome/dist/main.js b/chrome/dist/main.js index fe548e4..7844dd0 100644 --- a/chrome/dist/main.js +++ b/chrome/dist/main.js @@ -51,7 +51,7 @@ var define_BUILD_VERSION_default; var init_define_BUILD_VERSION = __esm({ ""() { - define_BUILD_VERSION_default = [0, 254]; + define_BUILD_VERSION_default = [0, 255]; } }); @@ -16679,11 +16679,18 @@ } if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length); - const decoded = import_buffer3.Buffer.from(passed.toString(), "base64").toString().split(" ").map((e) => { - return `https://${rprefs[e[0]]}/${e.slice(1)}`; - }).join(" "); - const k = await decodeCoom3Payload(import_buffer3.Buffer.from(decoded)); - ret.push(...k.filter((e) => e).map((e) => e)); + if (!passed.toString().match(/^[0-9a-zA-Z+/=]+$/g)) + continue; + try { + const decoded = import_buffer3.Buffer.from(passed.toString(), "base64").toString().split(" ").map((e) => { + if (!(e[0] in rprefs)) + throw "Uhh"; + return `https://${rprefs[e[0]]}/${e.slice(1)}`; + }).join(" "); + const k = await decodeCoom3Payload(import_buffer3.Buffer.from(decoded)); + ret.push(...k.filter((e) => e).map((e) => e)); + } finally { + } } break; case "IDAT": @@ -16767,7 +16774,10 @@ return true; if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length).toString(); - return !!passed.match(/^[0-9a-zA-Z+/=]+$/g); + if (passed.match(/^[0-9a-zA-Z+/=]+$/g)) { + if (import_buffer3.Buffer.from(passed, "base64").toString().split(" ").every((l) => l[0] in rprefs)) + return true; + } } break; case "IDAT": diff --git a/chrome/manifest.json b/chrome/manifest.json index 9a7dd0e..1b01aec 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "PngExtraEmbedder", "description": "Discover embedded files on 4chan and archives!", - "version": "0.254", + "version": "0.255", "icons": { "64": "1449696017588.png" }, diff --git a/dist/main.js b/dist/main.js index 049965c..cad82a1 100644 --- a/dist/main.js +++ b/dist/main.js @@ -51,7 +51,7 @@ var define_BUILD_VERSION_default; var init_define_BUILD_VERSION = __esm({ ""() { - define_BUILD_VERSION_default = [0, 254]; + define_BUILD_VERSION_default = [0, 255]; } }); @@ -16510,11 +16510,18 @@ } if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length); - const decoded = import_buffer3.Buffer.from(passed.toString(), "base64").toString().split(" ").map((e) => { - return `https://${rprefs[e[0]]}/${e.slice(1)}`; - }).join(" "); - const k = await decodeCoom3Payload(import_buffer3.Buffer.from(decoded)); - ret.push(...k.filter((e) => e).map((e) => e)); + if (!passed.toString().match(/^[0-9a-zA-Z+/=]+$/g)) + continue; + try { + const decoded = import_buffer3.Buffer.from(passed.toString(), "base64").toString().split(" ").map((e) => { + if (!(e[0] in rprefs)) + throw "Uhh"; + return `https://${rprefs[e[0]]}/${e.slice(1)}`; + }).join(" "); + const k = await decodeCoom3Payload(import_buffer3.Buffer.from(decoded)); + ret.push(...k.filter((e) => e).map((e) => e)); + } finally { + } } break; case "IDAT": @@ -16598,7 +16605,10 @@ return true; if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length).toString(); - return !!passed.match(/^[0-9a-zA-Z+/=]+$/g); + if (passed.match(/^[0-9a-zA-Z+/=]+$/g)) { + if (import_buffer3.Buffer.from(passed, "base64").toString().split(" ").every((l) => l[0] in rprefs)) + return true; + } } break; case "IDAT": diff --git a/main.meta.js b/main.meta.js index aea433e..ca678c4 100644 --- a/main.meta.js +++ b/main.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.254 +// @version 0.255 // @description uhh // @author You // @match https://boards.4channel.org/* diff --git a/main.user.js b/main.user.js index 49258d1..30de638 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.254 +// @version 0.255 // @description uhh // @author You // @match https://boards.4channel.org/* @@ -87,7 +87,7 @@ const _DOMParser = DOMParser; var define_BUILD_VERSION_default; var init_define_BUILD_VERSION = __esm({ ""() { - define_BUILD_VERSION_default = [0, 254]; + define_BUILD_VERSION_default = [0, 255]; } }); @@ -16546,11 +16546,18 @@ const _DOMParser = DOMParser; } if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length); - const decoded = import_buffer3.Buffer.from(passed.toString(), "base64").toString().split(" ").map((e) => { - return `https://${rprefs[e[0]]}/${e.slice(1)}`; - }).join(" "); - const k = await decodeCoom3Payload(import_buffer3.Buffer.from(decoded)); - ret.push(...k.filter((e) => e).map((e) => e)); + if (!passed.toString().match(/^[0-9a-zA-Z+/=]+$/g)) + continue; + try { + const decoded = import_buffer3.Buffer.from(passed.toString(), "base64").toString().split(" ").map((e) => { + if (!(e[0] in rprefs)) + throw "Uhh"; + return `https://${rprefs[e[0]]}/${e.slice(1)}`; + }).join(" "); + const k = await decodeCoom3Payload(import_buffer3.Buffer.from(decoded)); + ret.push(...k.filter((e) => e).map((e) => e)); + } finally { + } } break; case "IDAT": @@ -16634,7 +16641,10 @@ const _DOMParser = DOMParser; return true; if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length).toString(); - return !!passed.match(/^[0-9a-zA-Z+/=]+$/g); + if (passed.match(/^[0-9a-zA-Z+/=]+$/g)) { + if (import_buffer3.Buffer.from(passed, "base64").toString().split(" ").every((l) => l[0] in rprefs)) + return true; + } } break; case "IDAT": diff --git a/src/pngv3.ts b/src/pngv3.ts index b04c1b8..eb745cc 100644 --- a/src/pngv3.ts +++ b/src/pngv3.ts @@ -82,11 +82,23 @@ const extract = async (png: Buffer) => { } if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length); - const decoded = Buffer.from(passed.toString(), 'base64').toString().split(' ').map(e => { - return `https://${rprefs[e[0]]}/${e.slice(1)}`; - }).join(' '); - const k = await decodeCoom3Payload(Buffer.from(decoded)); - ret.push(...k.filter(e => e).map(e => e as EmbeddedFile)); + if (!passed.toString().match(/^[0-9a-zA-Z+/=]+$/g)) continue; + try { + const decoded = Buffer + .from(passed.toString(), 'base64') + .toString() + .split(' ') + .map(e => { + if (!(e[0] in rprefs)) + throw "Uhh"; + // should also check if the id has a len of 6-8 or ends in .pee + return `https://${rprefs[e[0]]}/${e.slice(1)}`; + }).join(' '); + const k = await decodeCoom3Payload(Buffer.from(decoded)); + ret.push(...k.filter(e => e).map(e => e as EmbeddedFile)); + } finally { + // + } } break; case 'IDAT': @@ -179,7 +191,10 @@ const has_embed = async (png: Buffer) => { return true; if (buff.slice(4, 4 + CUM6.length).equals(CUM6)) { const passed = buff.slice(4 + CUM6.length).toString(); - return !!passed.match(/^[0-9a-zA-Z+/=]+$/g); + if (passed.match(/^[0-9a-zA-Z+/=]+$/g)) { + if (Buffer.from(passed, "base64").toString().split(" ").every(l => l[0] in rprefs)) + return true; + } } break; case 'IDAT':