Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65fab67ec4 | ||
|
|
0d34e6cc99 |
No files matched your search
@@ -0,0 +1,97 @@
|
||||
name: text bytes host hunt (idwr candidate)
|
||||
on:
|
||||
push:
|
||||
branches: [hunt/text-bytes-host]
|
||||
paths: [scripts/hunt_text_bytes.py, .github/workflows/text-bytes-host-hunt.yml]
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
concurrency:
|
||||
group: text-bytes-host-hunt
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
hunt:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 3
|
||||
matrix:
|
||||
include:
|
||||
- {leg: w2022, runner: windows-2022, extra: none, asset: asset-win-x86_64}
|
||||
- {leg: w2025, runner: windows-2025, extra: none, asset: asset-win-x86_64}
|
||||
- {leg: ubuntu, runner: ubuntu-24.04, extra: none, asset: asset-linux-x86_64}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 40
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.12' }
|
||||
- name: Install
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ".[dev]"
|
||||
- name: Linux display and runtime libraries
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)"
|
||||
sudo apt-get update -q && sudo apt-get install -y -q xvfb
|
||||
sudo "$(which python)" -m playwright install-deps firefox
|
||||
- name: The engine of the idwr candidate (artifact of feder-cr/firefox_antidetect_patch run 43728338511), sealed
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/eng" && cd "$RUNNER_TEMP/eng"
|
||||
gh run download 43728338511 -R feder-cr/firefox_antidetect_patch -n ${{ matrix.asset }} -D .
|
||||
ls -la
|
||||
if [ "$RUNNER_OS" = "Windows" ]; then unzip -q ./*.zip -d ff && FF="$(cd ff && pwd -W)/firefox.exe"; else mkdir ff && tar -xzf ./*.tar.gz -C ff && FF="$(find "$PWD/ff" -maxdepth 2 -name firefox -type f | head -1)"; fi
|
||||
echo "FF=$FF" >> "$GITHUB_ENV"
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
python -m invisible_core seal --binary "$FF" --tag firefox-65-candidate -o "$RUNNER_TEMP/seal.json"
|
||||
echo "INVISIBLE_SEAL_FILE=$RUNNER_TEMP/seal.json" >> "$GITHUB_ENV"
|
||||
- name: One system font more (DejaVu Sans, installed for all users)
|
||||
if: matrix.extra == 'dejavu'
|
||||
shell: pwsh
|
||||
run: |
|
||||
python -m pip install matplotlib
|
||||
$src = python -c "import matplotlib, os; print(os.path.join(os.path.dirname(matplotlib.__file__), 'mpl-data', 'fonts', 'ttf', 'DejaVuSans.ttf'))"
|
||||
Copy-Item $src "C:\Windows\Fonts\DejaVuSans.ttf"
|
||||
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" -Name "DejaVu Sans (TrueType)" -Value "DejaVuSans.ttf" -PropertyType String -Force | Out-Null
|
||||
"installed: " + (Get-Item "C:\Windows\Fonts\DejaVuSans.ttf").Length
|
||||
- name: The host (Windows build, DirectWrite, the font files the probe names)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$cv = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
|
||||
$out = [ordered]@{ build = "$($cv.CurrentBuild).$($cv.UBR)"; product = $cv.ProductName }
|
||||
foreach ($dll in "DWrite.dll", "d2d1.dll", "gdi32full.dll", "fontsub.dll") {
|
||||
$p = "C:\Windows\System32\$dll"
|
||||
if (Test-Path $p) { $out[$dll] = "$((Get-Item $p).VersionInfo.FileVersion) $((Get-FileHash $p -Algorithm SHA256).Hash.Substring(0,16))" }
|
||||
}
|
||||
$reg = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
|
||||
$out["registry_fonts"] = @($reg.PSObject.Properties | Where-Object { $_.Name -notlike "PS*" }).Count
|
||||
$out["fonts_dir_files"] = @(Get-ChildItem C:\Windows\Fonts -File).Count
|
||||
foreach ($f in "arial.ttf","arialbd.ttf","times.ttf","segoeui.ttf","segoeuii.ttf","calibri.ttf","consola.ttf","verdana.ttf","tahoma.ttf","georgia.ttf","seguiemj.ttf","msyh.ttc","YuGothR.ttc","cour.ttf","timesi.ttf") {
|
||||
$p = "C:\Windows\Fonts\$f"
|
||||
$out["font:$f"] = if (Test-Path $p) { "$((Get-Item $p).VersionInfo.FileVersion) $((Get-FileHash $p -Algorithm SHA256).Hash.Substring(0,16))" } else { "absent" }
|
||||
}
|
||||
$out | ConvertTo-Json | Tee-Object "$env:RUNNER_TEMP\host.json"
|
||||
- name: Two runs of the probe, seed 42
|
||||
env:
|
||||
MOZ_CRASHREPORTER_DISABLE: "1"
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/out"
|
||||
if [ -f "$RUNNER_TEMP/host.json" ]; then cp "$RUNNER_TEMP/host.json" "$RUNNER_TEMP/out/host.json"; else
|
||||
python -c "import json, platform, sys; json.dump({'os': platform.platform()}, open(sys.argv[1], 'w'))" "$RUNNER_TEMP/out/host.json"; fi
|
||||
python -c "import json, sys; json.dump({'engine': 'idwr candidate, feder-cr/firefox_antidetect_patch run 43728338511', 'asset': sys.argv[1]}, open(sys.argv[2], 'w'))" "${{ matrix.asset }}" "$RUNNER_TEMP/out/engine.json"
|
||||
if [ "$RUNNER_OS" = "Linux" ]; then RUN="xvfb-run -a"; else RUN=""; fi
|
||||
for i in 1 2; do $RUN python scripts/hunt_text_bytes.py "$FF" "$RUNNER_TEMP/out/probe-$i.json"; done
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with: { name: "text-bytes-${{ matrix.leg }}", path: "${{ runner.temp }}/out" }
|
||||
- name: Close every Firefox left
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
@@ -0,0 +1,75 @@
|
||||
"""Hunt only: the bytes a page reads, one seed, on this machine; and each probe font drawn alone, to tell which one differs.
|
||||
|
||||
python scripts/hunt_text_bytes.py <binary> <out.json>
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "tests"))
|
||||
import _page_bytes # noqa: E402
|
||||
|
||||
from invisible_playwright import InvisiblePlaywright # noqa: E402
|
||||
|
||||
LAUNCH = dict(seed=42, headless=True, locale="en-US", timezone="Europe/Rome")
|
||||
PROBE = (Path(__file__).resolve().parent.parent / "tests" / "page_bytes_probe.js").read_text(encoding="utf-8")
|
||||
EACH_FONT = r"""async () => {
|
||||
const FONTS = ["16px sans-serif", "20px serif", "18px monospace", "bold 16px Arial", "italic 15px 'Segoe UI'", "16px 'Times New Roman'",
|
||||
"16px Calibri", "14px Consolas", "16px Verdana", "16px Tahoma", "17px Georgia", "16px 'Segoe UI Emoji'", "16px 'Microsoft YaHei'",
|
||||
"16px 'Yu Gothic'", "bold 40px sans-serif", "italic 34px serif", "28px monospace", "bold 44px Arial", "36px 'Times New Roman'", "30px 'Segoe UI'"];
|
||||
const TEXTS = {latin: "Hamburgefonstiv 0123456789 Ag", cjk: "日本語のテキスト 漢字", emoji: "😀🚀👍🏽", arabic: "مرحبا بالعالم"};
|
||||
async function digest(data) {
|
||||
const h = await crypto.subtle.digest("SHA-256", data);
|
||||
return Array.from(new Uint8Array(h)).slice(0, 8).map((b) => b.toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
const out = [];
|
||||
for (const f of FONTS) {
|
||||
for (const [name, t] of Object.entries(TEXTS)) {
|
||||
const c = document.createElement("canvas"); c.width = 640; c.height = 64;
|
||||
const g = c.getContext("2d"); g.fillStyle = "#fff"; g.fillRect(0, 0, 640, 64);
|
||||
g.font = f; g.fillStyle = "#101820"; g.textBaseline = "alphabetic"; g.fillText(t, 4, 44);
|
||||
const m = g.measureText(t);
|
||||
const px = g.getImageData(0, 0, 640, 64).data;
|
||||
let ink = 0; for (let i = 0; i < px.length; i += 4) if (px[i] < 250) ink++;
|
||||
out.push({font: f, text: name, raster: await digest(px), ink, width: m.width, asc: m.actualBoundingBoxAscent,
|
||||
desc: m.actualBoundingBoxDescent, fasc: m.fontBoundingBoxAscent, fdesc: m.fontBoundingBoxDescent,
|
||||
check: document.fonts.check(f)});
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}"""
|
||||
|
||||
|
||||
class Page(BaseHTTPRequestHandler):
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
def do_GET(self):
|
||||
body = b"<!doctype html><meta charset=utf-8><title>probe</title><body></body>"
|
||||
self.send_response(200); self.send_header("Content-Type", "text/html"); self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers(); self.wfile.write(body)
|
||||
|
||||
|
||||
def main(binary, out):
|
||||
server = ThreadingHTTPServer(("127.0.0.1", 0), Page)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
url = "http://127.0.0.1:%d/" % server.server_address[1]
|
||||
try:
|
||||
with InvisiblePlaywright(binary_path=binary, **LAUNCH) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(url, wait_until="load", timeout=60000)
|
||||
measured = page.evaluate(PROBE)
|
||||
page.goto(url, wait_until="load", timeout=60000)
|
||||
each = page.evaluate(EACH_FONT)
|
||||
finally:
|
||||
server.shutdown()
|
||||
entries = {k: _page_bytes.entry_of(k, v) for k, v in measured.items()}
|
||||
raw_strings = {k: v["s"] for k, v in measured.items() if "s" in v}
|
||||
Path(out).write_text(json.dumps({"entries": entries, "strings": raw_strings, "each_font": each}, indent=1), encoding="utf-8")
|
||||
print("HUNT wrote %d keys and %d single-font draws" % (len(entries), len(each)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1], sys.argv[2])
|
||||
Reference in new issue
Block a user