Skip to content

Commit

Permalink
Merge branch 'targetfp'
Browse files Browse the repository at this point in the history
  • Loading branch information
ccev committed Jun 16, 2024
2 parents e083895 + d2d66ef commit da84a8a
Show file tree
Hide file tree
Showing 10 changed files with 613 additions and 1 deletion.
1 change: 0 additions & 1 deletion xilriws-proxy/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const STEALTH_JS = ""
const ws = new WebSocket('ws://127.0.0.1:9091');

let currentProxyCreds = {
Expand Down
10 changes: 10 additions & 0 deletions xilriws-targetfp/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
chrome.webNavigation.onCompleted.addListener((details) => {
console.log(details.tabId)
})

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message === "getTabId") {
sendResponse(sender.tab.id)
}
return true
})
68 changes: 68 additions & 0 deletions xilriws-targetfp/canvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import * as utils from "./utils.js"

const typeValues = {
" monospace": 1, " sans-serif": 2, " serif": 3
}

const possibleFonts = ["ArialUnicodeMS", "Calibri", "Century", "Haettenschweiler", "Marlett", "Pristina", "Bauhaus93", "FuturaBkBT", "HelveticaNeue", "LucidaSans", "MYRIADPRO", "SegoeUILight"]

export function block() {
utils.overwriteProp(CanvasRenderingContext2D.prototype, "isPointInPath", () => false)
utils.overwriteProp(CanvasRenderingContext2D.prototype, "globalCompositeOperation", "screen")

function zeroOrOne() {
return utils.randomNumber(0, 2)
}

// utils.overwriteProp(CanvasRenderingContext2D.prototype, "measureText", (s) => {
// const metrics = {}
// metrics.width = zeroOrOne()
// metrics.actualBoundingBoxAscent = zeroOrOne()
// metrics.actualBoundingBoxDescent = zeroOrOne()
// metrics.actualBoundingBoxLeft = zeroOrOne()
// metrics.actualBoundingBoxRight = zeroOrOne()
// return metrics
// })

const goodFonts = utils.randomChooseMultiple(possibleFonts, utils.randomNumber(4, 7))
console.log("good fonts are " + goodFonts.join(","))

CanvasRenderingContext2D.prototype.measureText = function (text) {
let value = -10
for (const typeValue of Object.keys(typeValues)) {
if (this.font.includes(typeValue)) {
value = typeValues[typeValue]
}
}

for (const goodFont of goodFonts) {
if (this.font.includes(" " + goodFont + ",")) {
value = -10
}
}

const metrics = {}
metrics.width = value
metrics.actualBoundingBoxAscent = value
metrics.actualBoundingBoxDescent = value
metrics.actualBoundingBoxLeft = value
metrics.actualBoundingBoxRight = value
return metrics
}

const originalArc = CanvasRenderingContext2D.prototype.arc
CanvasRenderingContext2D.prototype.arc = function (n1, n2, n3, zero, pi2, bool) {
n1 += utils.randomNumber(-1, 2)
n2 += utils.randomNumber(-1, 2)
n3 += utils.randomNumber(-1, 2)
return originalArc.bind(this, n1, n2, n3, zero, pi2, bool)()
}

const originalPutImageData = CanvasRenderingContext2D.prototype.putImageData
CanvasRenderingContext2D.prototype.putImageData = function (img, x, y, ...args) {
// this doesn't actually do anything. however, it doesn't appear this canvas differs between different chromiums
x += utils.randomNumber(-1, 2)
y += utils.randomNumber(-1, 2)
return originalPutImageData.bind(this, img, x, y, ...args)()
}
}
11 changes: 11 additions & 0 deletions xilriws-targetfp/contentScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(async () => {
const tabId = await chrome.runtime.sendMessage("getTabId")
const div = document.createElement("div")
div.setAttribute("data-xil-tab-id", tabId)

while (!document.body) {
console.log("body is null, waiting 0.1s")
await new Promise(resolve => setTimeout(resolve, 100))
}
document.body.appendChild(div)
})()
87 changes: 87 additions & 0 deletions xilriws-targetfp/general.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import * as utils from "./utils.js"

const baseLanguages = [
"en-US",
"fr",
"de",
"es"
]

const extraLanguages = [
"en-GB",
"pt-BR",
"ru",
"tr",
"de",
"fr",
"es",
"hr",
"el",
"hu",
"no",
"ro",
"sr"
]

const englishes = [
"en-US",
"en-GB"
]

const timezones = [
0, 1, 2, 3, 4, 5, 6, 8, 9, -4, -5, -6, -7
]

export function block() {
utils.overwriteProp(navigator, "platform", "Win32")
utils.overwriteProp(navigator, "doNotTrack", utils.randomChoose(["unknown", "unknown", "1"]))
utils.overwriteProp(navigator, "maxTouchPoints", utils.randomChoose([0, 5, 10, 20]))
utils.overwriteProp(navigator, "productSub", "20030107")
utils.overwriteProp(navigator.connection, "rtt", utils.randomChoose([undefined, 0, 50, 100]))
utils.overwriteProp(navigator, "hardwareConcurrency", utils.randomChoose([4, 8, 12, 16, 24, 32]))

utils.overwriteProp(window.history, "length", utils.randomNumber(1, 5))

const timezone = utils.randomChoose(timezones) * -60
utils.overwriteProp(Date.prototype, "getTimezoneOffset", () => timezone)
utils.overwriteProp(Navigator.prototype, "mimeTypes", {
0: {
suffixes: "pdf",
type: "application/pdf",
enabledPlugin: { filename: "internal-pdf-viewer" },
},
1: {
suffixes: "pdf",
type: "text/pdf",
enabledPlugin: { filename: "internal-pdf-viewer" },
},
"application/pdf": {
suffixes: "pdf",
type: "application/pdf",
enabledPlugin: { filename: "internal-pdf-viewer" },
},
"text/pdf": {
suffixes: "pdf",
type: "text/pdf",
enabledPlugin: { filename: "internal-pdf-viewer" },
},

})

// language
const baseLanguage = utils.randomChoose(baseLanguages)
const languages = [baseLanguage]

const randomExtraLangs = utils.randomNumber(0, 10)
if (randomExtraLangs > 3) {
if (englishes.includes(baseLanguage)) {
languages.push(utils.randomChoose(extraLanguages))
} else {
languages.push(utils.randomChoose(englishes))
}
}
console.log("languages are " + languages.join(","))

utils.overwriteProp(navigator, "language", baseLanguage)
utils.overwriteProp(navigator, "languages", languages)
}
49 changes: 49 additions & 0 deletions xilriws-targetfp/inject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
(async () => {
"use strict"

HTMLIFrameElement.prototype.addEventListener = async function (eventType, callback) {
if (eventType !== "load") {
return
}

let fpLoaded = false
while (!fpLoaded) {
console.log("waiting for plugin load")
await new Promise(resolve => setTimeout(resolve, 200))
if (this.contentDocument) {
fpLoaded = this.contentDocument.fpLoaded
}
}
callback()
}

const utils = await import("./utils.js")
const screen = await import("./screen.js")
const general = await import("./general.js")
const canvas = await import("./canvas.js")
const webgl = await import("./webgl.js")

let div = null
while (!div) {
div = document.querySelector("[data-xil-tab-id]")
if (!div) {
console.log("didn't find seed element, waiting 0.1s")
await new Promise(resolve => setTimeout(resolve, 100))
}
}
const seed = div.getAttribute("data-xil-tab-id")
document.body.removeChild(div)
utils.setSeed(seed)

utils.sendWs("debug:seed", seed)

// screen.block()
// general.block()
// canvas.block()
// webgl.block()

document.fpLoaded = true
})()



105 changes: 105 additions & 0 deletions xilriws-targetfp/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"manifest_version": 3,
"name": "xilriws-targetfp",
"version": "1.0",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking",
"devtools",
"cookies",
"storage",
"scripting",
"tabs",
"activeTab",
"webNavigation",
"runtime"
],
"host_permissions": [
"<all_urls>"
],
"background": {
"service_worker": "background.js",
"type": "module"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"contentScript.js"
],
"run_at": "document_start",
"all_frames": true,
"match_origin_as_fallback": true
},
{
"matches": [
"<all_urls>"
],
"js": [
"inject.js"
],
"run_at": "document_start",
"all_frames": true,
"match_origin_as_fallback": true,
"world": "MAIN",
"type": "module"
}
],
"web_accessible_resources": [
{
"resources": [
"inject.js"
],
"matches": [
"<all_urls>"
]
},
{
"resources": [
"utils.js"
],
"matches": [
"<all_urls>"
]
},
{
"resources": [
"screen.js"
],
"matches": [
"<all_urls>"
]
},
{
"resources": [
"general.js"
],
"matches": [
"<all_urls>"
]
},
{
"resources": [
"canvas.js"
],
"matches": [
"<all_urls>"
]
},
{
"resources": [
"webgl.js"
],
"matches": [
"<all_urls>"
]
}
]
}
Loading

0 comments on commit da84a8a

Please sign in to comment.