7 Commits
Author SHA1 Message Date
xenos bbc7918678 Update package.json 2026-03-17 01:05:17 +01:00
xenos 68f7e1c1c0 update for 1.24.4 2026-03-17 00:29:26 +01:00
xenosandGitHub 0685a1e727 Merge pull request #10 from xenos1337/dependabot/npm_and_yarn/minimatch-10.2.4 2026-03-03 00:29:10 +01:00
dependabot[bot]andGitHub fa9dcf5361 chore(deps): bump minimatch from 10.2.2 to 10.2.4
Bumps [minimatch](https://github.com/isaacs/minimatch) from 10.2.2 to 10.2.4.
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v10.2.2...v10.2.4)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 10.2.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-28 13:26:35 +00:00
xenosandGitHub efcc89bab4 Merge pull request #9 from xenos1337/dependabot/npm_and_yarn/multi-4348f2d014 2026-02-24 16:49:12 +01:00
dependabot[bot]andGitHub 8215f4348b chore(deps): bump minimatch and @electron/asar
Bumps [minimatch](https://github.com/isaacs/minimatch) to 10.2.2 and updates ancestor dependency [@electron/asar](https://github.com/electron/asar). These dependencies need to be updated together.


Updates `minimatch` from 3.1.2 to 10.2.2
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v10.2.2)

Updates `@electron/asar` from 3.4.1 to 4.0.1
- [Release notes](https://github.com/electron/asar/releases)
- [Changelog](https://github.com/electron/asar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/electron/asar/compare/v3.4.1...v4.0.1)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 10.2.2
  dependency-type: indirect
- dependency-name: "@electron/asar"
  dependency-version: 4.0.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-21 10:32:42 +00:00
xenos 359b707b44 Update for 1.24.2 2025-12-18 17:38:56 +01:00
4 changed files with 448 additions and 142 deletions
+169 -46
View File
@@ -73,7 +73,7 @@ function fetchJson(url) {
const options = { const options = {
headers: { headers: {
"User-Agent": "httptoolkit-patcher", "User-Agent": "httptoolkit-patcher",
"Accept": "application/vnd.github.v3+json", Accept: "application/vnd.github.v3+json",
}, },
}; };
https https
@@ -100,7 +100,7 @@ function compareVersions(v1, v2) {
const normalize = (/** @type {string} */ v) => v.replace(/^v/, "").split(".").map(Number); const normalize = (/** @type {string} */ v) => v.replace(/^v/, "").split(".").map(Number);
const parts1 = normalize(v1); const parts1 = normalize(v1);
const parts2 = normalize(v2); const parts2 = normalize(v2);
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) { for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
const num1 = parts1[i] || 0; const num1 = parts1[i] || 0;
const num2 = parts2[i] || 0; const num2 = parts2[i] || 0;
@@ -116,18 +116,18 @@ function compareVersions(v1, v2) {
async function checkForUpdates() { async function checkForUpdates() {
try { try {
const tags = await fetchJson(`https://api.github.com/repos/${GITHUB_REPO}/tags`); const tags = await fetchJson(`https://api.github.com/repos/${GITHUB_REPO}/tags`);
if (!tags || tags.length === 0) { if (!tags || tags.length === 0) {
return; // No tags found, skip update check return; // No tags found, skip update check
} }
// Tags are returned in order, first one is the latest // Tags are returned in order, first one is the latest
const latestTag = tags[0].name; const latestTag = tags[0].name;
const latestVersion = latestTag.replace(/^v/, ""); const latestVersion = latestTag.replace(/^v/, "");
if (compareVersions(latestVersion, LOCAL_VERSION) > 0) { if (compareVersions(latestVersion, LOCAL_VERSION) > 0) {
console.log(chalk.yellowBright`\n╔════════════════════════════════════════════════════════════╗`); console.log(chalk.yellowBright`\n╔════════════════════════════════════════════════════════════╗`);
console.log(chalk.yellowBright`` + chalk.white` A new version is available: ` + chalk.greenBright`v${latestVersion}` + chalk.white` (current: ` + chalk.gray`v${LOCAL_VERSION}` + chalk.white`) ` + chalk.yellowBright` `); console.log(chalk.yellowBright`` + chalk.white` A new version is available: ` + chalk.greenBright`v${latestVersion}` + chalk.white` (current: ` + chalk.gray`v${LOCAL_VERSION}` + chalk.white`) ` + chalk.yellowBright``);
console.log(chalk.yellowBright`` + chalk.white` Update: ` + chalk.cyanBright`https://github.com/${GITHUB_REPO}` + chalk.white` ` + chalk.yellowBright``); console.log(chalk.yellowBright`` + chalk.white` Update: ` + chalk.cyanBright`https://github.com/${GITHUB_REPO}` + chalk.white` ` + chalk.yellowBright``);
console.log(chalk.yellowBright`╚════════════════════════════════════════════════════════════╝\n`); console.log(chalk.yellowBright`╚════════════════════════════════════════════════════════════╝\n`);
} }
@@ -150,7 +150,11 @@ function rm(dirPath) {
// Find HTTP Toolkit installation path // Find HTTP Toolkit installation path
async function findAppPath() { async function findAppPath() {
const possiblePaths = isWin ? [path.join("C:", "Program Files", "HTTP Toolkit", "resources"), path.join("C:", "Program Files (x86)", "HTTP Toolkit", "resources"), path.join(process.env.LOCALAPPDATA || path.join(process.env.USERPROFILE || "", "AppData", "Local"), "Programs", "HTTP Toolkit", "resources")] : isMac ? ["/Applications/HTTP Toolkit.app/Contents/Resources"] : ["/opt/HTTP Toolkit/resources", "/opt/httptoolkit/resources"]; const possiblePaths = isWin
? [path.join("C:", "Program Files", "HTTP Toolkit", "resources"), path.join("C:", "Program Files (x86)", "HTTP Toolkit", "resources"), path.join(process.env.LOCALAPPDATA || path.join(process.env.USERPROFILE || "", "AppData", "Local"), "Programs", "HTTP Toolkit", "resources")]
: isMac
? ["/Applications/HTTP Toolkit.app/Contents/Resources"]
: ["/opt/HTTP Toolkit/resources", "/opt/httptoolkit/resources"];
for (const p of possiblePaths) { for (const p of possiblePaths) {
if (fs.existsSync(path.join(p, "app.asar"))) { if (fs.existsSync(path.join(p, "app.asar"))) {
@@ -244,7 +248,7 @@ function checkPermissions(filePath) {
try { try {
// Check write access to the file/directory // Check write access to the file/directory
fs.accessSync(filePath, fs.constants.W_OK); fs.accessSync(filePath, fs.constants.W_OK);
// Check if we can create directories // Check if we can create directories
const testDirPath = path.join(path.dirname(filePath), `.test_${Date.now()}`); const testDirPath = path.join(path.dirname(filePath), `.test_${Date.now()}`);
try { try {
@@ -254,7 +258,7 @@ function checkPermissions(filePath) {
console.error(chalk.redBright`[-] Cannot create directories in ${path.dirname(filePath)}: ${dirError.message}`); console.error(chalk.redBright`[-] Cannot create directories in ${path.dirname(filePath)}: ${dirError.message}`);
return false; return false;
} }
console.log(chalk.greenBright`[+] Permissions check passed for ${filePath}`); console.log(chalk.greenBright`[+] Permissions check passed for ${filePath}`);
return true; return true;
} catch (e) { } catch (e) {
@@ -309,18 +313,130 @@ async function killHttpToolkit() {
} }
} }
// Resolve the base installation directory (without the trailing resources folder)
function getBinaryBasePath(resourcesPath) {
const normalized = resourcesPath.replace(/[\\/]+$/, "");
if (normalized.toLowerCase().endsWith("resources")) {
return path.dirname(normalized);
}
return normalized;
}
// Determine the executable path for HTTP Toolkit based on platform
function getExecutablePath(resourcesPath) {
const basePath = getBinaryBasePath(resourcesPath);
const candidates = isWin ? [path.join(basePath, "HTTP Toolkit.exe"), path.join(basePath, "httptoolkit.exe")] : isMac ? [path.join(basePath, "MacOS", "HTTP Toolkit"), path.join(basePath, "MacOS", "HTTP Toolkit Preview")] : [path.join(basePath, "httptoolkit"), path.join(basePath, "HTTP Toolkit")];
for (const candidate of candidates) {
if (fs.existsSync(candidate)) {
return candidate;
}
}
throw new Error(`Could not locate HTTP Toolkit executable near ${resourcesPath}`);
}
// Extract hashes from integrity check output
function extractIntegrityHashes(output) {
const regex = /Integrity check failed for asar archive[\s\S]*?\(\s*([0-9a-f]{64})\s*vs\s*([0-9a-f]{64})\s*\)/i;
const match = output.match(regex);
if (!match) return null;
return {
originalHash: match[1],
newHash: match[2],
};
}
// Launch the app once to grab integrity hashes from its crash output
async function captureIntegrityHashes(executablePath) {
return new Promise((resolve, reject) => {
let output = "";
let finished = false;
const child = spawn(executablePath, {
cwd: path.dirname(executablePath),
stdio: ["ignore", "pipe", "pipe"],
windowsHide: true,
});
const timeout = setTimeout(() => {
if (!finished) {
finished = true;
child.kill();
reject(new Error("Timed out waiting for integrity check output"));
}
}, 20000);
const handleData = data => {
output += data.toString();
const hashes = extractIntegrityHashes(output);
if (hashes && !finished) {
finished = true;
clearTimeout(timeout);
child.kill();
resolve(hashes);
}
};
child.stdout.on("data", handleData);
child.stderr.on("data", handleData);
child.on("error", err => {
if (!finished) {
finished = true;
clearTimeout(timeout);
reject(err);
}
});
child.on("exit", () => {
if (!finished) {
clearTimeout(timeout);
const hashes = extractIntegrityHashes(output);
if (hashes) {
resolve(hashes);
} else {
reject(new Error("Could not find integrity hashes in HTTP Toolkit output"));
}
}
});
});
}
// Replace all occurrences of the original hash with the new hash inside the binary
function patchExecutableHash(executablePath, originalHash, newHash) {
if (originalHash.length !== newHash.length) {
throw new Error("Hash lengths do not match; cannot safely patch binary");
}
const binary = fs.readFileSync(executablePath);
const originalBuf = Buffer.from(originalHash, "utf-8");
const newBuf = Buffer.from(newHash, "utf-8");
let occurrences = 0;
let idx = binary.indexOf(originalBuf);
while (idx !== -1) {
newBuf.copy(binary, idx);
occurrences += 1;
idx = binary.indexOf(originalBuf, idx + originalBuf.length);
}
if (occurrences === 0) {
throw new Error("Original hash not found in binary");
}
fs.writeFileSync(executablePath, binary);
return occurrences;
}
// Unpatch/restore function // Unpatch/restore function
async function unpatchApp() { async function unpatchApp() {
console.log(chalk.blueBright`[+] HTTP Toolkit Unpatcher Started`); console.log(chalk.blueBright`[+] HTTP Toolkit Unpatcher Started`);
// Step 1: Find app path
const appPath = await findAppPath(); const appPath = await findAppPath();
console.log(chalk.greenBright`[+] HTTP Toolkit found at ${appPath}`); console.log(chalk.greenBright`[+] HTTP Toolkit found at ${appPath}`);
// Step 2: Kill HTTP Toolkit if running
await killHttpToolkit(); await killHttpToolkit();
// Step 3: Check permissions
const asarPath = path.join(appPath, "app.asar"); const asarPath = path.join(appPath, "app.asar");
const backupPath = path.join(appPath, "app.asar.bak"); const backupPath = path.join(appPath, "app.asar.bak");
const extractPath = path.join(appPath, "app.asar_extracted"); const extractPath = path.join(appPath, "app.asar_extracted");
@@ -340,14 +456,12 @@ async function unpatchApp() {
await requestElevation(); await requestElevation();
} }
// Step 4: Check if backup exists
if (!fs.existsSync(backupPath)) { if (!fs.existsSync(backupPath)) {
console.error(chalk.redBright`[-] Backup file not found at ${backupPath}`); console.error(chalk.redBright`[-] Backup file not found at ${backupPath}`);
console.error(chalk.redBright`[-] Cannot unpatch without backup file`); console.error(chalk.redBright`[-] Cannot unpatch without backup file`);
process.exit(1); process.exit(1);
} }
// Step 5: Restore from backup
console.log(chalk.yellowBright`[+] Restoring from backup...`); console.log(chalk.yellowBright`[+] Restoring from backup...`);
try { try {
fs.copyFileSync(backupPath, asarPath); fs.copyFileSync(backupPath, asarPath);
@@ -357,14 +471,12 @@ async function unpatchApp() {
process.exit(1); process.exit(1);
} }
// Step 6: Clean up extracted files if they exist
if (fs.existsSync(extractPath)) { if (fs.existsSync(extractPath)) {
console.log(chalk.yellowBright`[+] Removing extracted files...`); console.log(chalk.yellowBright`[+] Removing extracted files...`);
rm(extractPath); rm(extractPath);
console.log(chalk.greenBright`[+] Cleaned up extracted files`); console.log(chalk.greenBright`[+] Cleaned up extracted files`);
} }
// Step 7: Optionally remove backup
const removeBackup = await prompt("Do you want to remove the backup file? (y/n): "); const removeBackup = await prompt("Do you want to remove the backup file? (y/n): ");
if (removeBackup.toLowerCase() === "y" || removeBackup.toLowerCase() === "yes") { if (removeBackup.toLowerCase() === "y" || removeBackup.toLowerCase() === "yes") {
fs.rmSync(backupPath, { force: true }); fs.rmSync(backupPath, { force: true });
@@ -378,14 +490,11 @@ async function unpatchApp() {
async function patchApp() { async function patchApp() {
console.log(chalk.blueBright`[+] HTTP Toolkit Patcher Started`); console.log(chalk.blueBright`[+] HTTP Toolkit Patcher Started`);
// Step 1: Find app path
const appPath = await findAppPath(); const appPath = await findAppPath();
console.log(chalk.greenBright`[+] HTTP Toolkit found at ${appPath}`); console.log(chalk.greenBright`[+] HTTP Toolkit found at ${appPath}`);
// Step 2: Kill HTTP Toolkit if running
await killHttpToolkit(); await killHttpToolkit();
// Step 3: Check permissions
const asarPath = path.join(appPath, "app.asar"); const asarPath = path.join(appPath, "app.asar");
// Check if we have write permissions on both the directory and the file // Check if we have write permissions on both the directory and the file
@@ -403,7 +512,6 @@ async function patchApp() {
await requestElevation(); await requestElevation();
} }
// Step 4: Backup app.asar
const backupPath = path.join(appPath, "app.asar.bak"); const backupPath = path.join(appPath, "app.asar.bak");
if (!fs.existsSync(backupPath)) { if (!fs.existsSync(backupPath)) {
console.log(chalk.yellowBright`[+] Creating backup...`); console.log(chalk.yellowBright`[+] Creating backup...`);
@@ -411,14 +519,12 @@ async function patchApp() {
console.log(chalk.greenBright`[+] Backup created at ${backupPath}`); console.log(chalk.greenBright`[+] Backup created at ${backupPath}`);
} }
// Step 5: Extract app.asar
const extractPath = path.join(appPath, "app.asar_extracted"); const extractPath = path.join(appPath, "app.asar_extracted");
console.log(chalk.yellowBright`[+] Extracting app.asar...`); console.log(chalk.yellowBright`[+] Extracting app.asar...`);
rm(extractPath); rm(extractPath);
asar.extractAll(asarPath, extractPath); asar.extractAll(asarPath, extractPath);
console.log(chalk.greenBright`[+] Extracted to ${extractPath}`); console.log(chalk.greenBright`[+] Extracted to ${extractPath}`);
// Step 6: Check if preload.cjs exists
const preloadPath = path.join(extractPath, "build", "preload.cjs"); const preloadPath = path.join(extractPath, "build", "preload.cjs");
if (!fs.existsSync(preloadPath)) { if (!fs.existsSync(preloadPath)) {
console.error(chalk.redBright`[-] preload.cjs not found in ${path.join(extractPath, "build")}`); console.error(chalk.redBright`[-] preload.cjs not found in ${path.join(extractPath, "build")}`);
@@ -428,7 +534,6 @@ async function patchApp() {
} }
console.log(chalk.greenBright`[+] Found preload.cjs`); console.log(chalk.greenBright`[+] Found preload.cjs`);
// Step 7: Read inject.js from local file (same directory as this script)
console.log(chalk.yellowBright`[+] Reading inject code from local file...`); console.log(chalk.yellowBright`[+] Reading inject code from local file...`);
const injectJsPath = path.join(path.dirname(__filename), "inject.js"); const injectJsPath = path.join(path.dirname(__filename), "inject.js");
if (!fs.existsSync(injectJsPath)) { if (!fs.existsSync(injectJsPath)) {
@@ -444,7 +549,6 @@ async function patchApp() {
} }
console.log(chalk.greenBright`[+] Inject code loaded successfully`); console.log(chalk.greenBright`[+] Inject code loaded successfully`);
// Step 8: Read files and check if already patched
let preloadContent = fs.readFileSync(preloadPath, "utf-8"); let preloadContent = fs.readFileSync(preloadPath, "utf-8");
const electronVarName = preloadContent.includes("electron_1") ? "electron_1" : "electron"; const electronVarName = preloadContent.includes("electron_1") ? "electron_1" : "electron";
@@ -496,20 +600,19 @@ async function patchApp() {
// Remove existing patches // Remove existing patches
console.log(chalk.yellowBright`[+] Replacing existing patches...`); console.log(chalk.yellowBright`[+] Replacing existing patches...`);
// Remove preload patch // Remove preload patch
const preloadPatchRegex = /\n?\(function loadInjectScript\(\) \{[\s\S]*?\}\)\(\);/; const preloadPatchRegex = /\n?\(function loadInjectScript\(\) \{[\s\S]*?\}\)\(\);/;
preloadContent = preloadContent.replace(preloadPatchRegex, ""); preloadContent = preloadContent.replace(preloadPatchRegex, "");
} }
// Step 9: Patch preload file - find line with electron import and insert patch code below it
console.log(chalk.yellowBright`[+] Applying preload patch...`); console.log(chalk.yellowBright`[+] Applying preload patch...`);
const preloadLines = preloadContent.split("\n"); const preloadLines = preloadContent.split("\n");
let preloadInsertIndex = -1; let preloadInsertIndex = -1;
for (let i = 0; i < preloadLines.length; i++) { for (let i = 0; i < preloadLines.length; i++) {
const line = preloadLines[i]; const line = preloadLines[i];
if (line.includes("require(\"electron\")") || line.includes("require('electron')") || line.includes("electron_1")) { if (line.includes('require("electron")') || line.includes("require('electron')") || line.includes("electron_1")) {
preloadInsertIndex = i + 1; preloadInsertIndex = i + 1;
break; break;
} }
@@ -528,35 +631,55 @@ async function patchApp() {
fs.writeFileSync(preloadPath, preloadContent, "utf-8"); fs.writeFileSync(preloadPath, preloadContent, "utf-8");
console.log(chalk.greenBright`[+] ${path.basename(preloadPath)} patched successfully`); console.log(chalk.greenBright`[+] ${path.basename(preloadPath)} patched successfully`);
// Step 10: Repackage app.asar
console.log(chalk.yellowBright`[+] Repackaging app.asar...`); console.log(chalk.yellowBright`[+] Repackaging app.asar...`);
await asar.createPackage(extractPath, asarPath); await asar.createPackage(extractPath, asarPath);
console.log(chalk.greenBright`[+] app.asar repackaged successfully`); console.log(chalk.greenBright`[+] app.asar repackaged successfully`);
// Step 11: Clean up let executablePath;
try {
executablePath = getExecutablePath(appPath);
} catch (e) {
rm(extractPath);
console.error(chalk.redBright`[-] ${e.message}`);
process.exit(1);
}
console.log(chalk.yellowBright`[+] Launching HTTP Toolkit to read integrity hashes...`);
let hashes;
try {
hashes = await captureIntegrityHashes(executablePath);
} catch (e) {
rm(extractPath);
console.error(chalk.redBright`[-] Failed to capture integrity hashes: ${e.message}`);
process.exit(1);
}
console.log(chalk.greenBright`[+] Integrity hashes captured`);
console.log(chalk.white` Original hash: ${hashes.originalHash}`);
console.log(chalk.white` New asar hash: ${hashes.newHash}`);
try {
const replacements = patchExecutableHash(executablePath, hashes.originalHash, hashes.newHash);
console.log(chalk.greenBright`[+] Patched binary hash (${replacements} replacement${replacements === 1 ? "" : "s"})`);
} catch (e) {
rm(extractPath);
console.error(chalk.redBright`[-] Failed to patch binary hash: ${e.message}`);
process.exit(1);
}
console.log(chalk.yellowBright`[+] Cleaning up temporary files...`); console.log(chalk.yellowBright`[+] Cleaning up temporary files...`);
rm(extractPath); rm(extractPath);
console.log(chalk.greenBright`[+] Successfully patched!`); console.log(chalk.greenBright`[+] Successfully patched!`);
// Step 12: Open HTTP Toolkit as detached process
console.log(chalk.blueBright`[+] Opening HTTP Toolkit...`); console.log(chalk.blueBright`[+] Opening HTTP Toolkit...`);
try { try {
if (isLinux) { const child = spawn(executablePath, {
// Linux: Cannot auto-launch reliably, show manual instructions stdio: "ignore",
console.log(chalk.yellowBright`[!] HTTP Toolkit has been successfully patched`); shell: false,
console.log(chalk.yellowBright`[!] Please manually launch HTTP Toolkit from your applications menu or using the command:`); detached: true,
console.log(chalk.blueBright` httptoolkit`); });
} else { child.unref();
const command = isWin ? `"${path.resolve(appPath, "..", "HTTP Toolkit.exe")}"` : isMac ? 'open -a "HTTP Toolkit"' : "httptoolkit"; console.log(chalk.greenBright`[+] HTTP Toolkit launched successfully`);
const child = spawn(command, {
stdio: "ignore",
shell: true,
detached: true,
});
child.unref();
console.log(chalk.greenBright`[+] HTTP Toolkit launched successfully`);
}
} catch (e) { } catch (e) {
console.error(chalk.yellowBright`[!] Could not auto-start HTTP Toolkit: ${e.message}`); console.error(chalk.yellowBright`[!] Could not auto-start HTTP Toolkit: ${e.message}`);
console.log(chalk.blueBright`[+] Please start HTTP Toolkit manually`); console.log(chalk.blueBright`[+] Please start HTTP Toolkit manually`);
+76 -8
View File
@@ -1,14 +1,11 @@
(function () { (function () {
console.log("[PAGE-INJECT] Installing hooks in page context"); console.log("[PAGE-INJECT] Installing hooks in page context");
// Properties to hook directly on accountStore (still exist as computed properties)
const propertyHooks = { const propertyHooks = {
isPaidUser: true,
isLoggedIn: true, isLoggedIn: true,
userHasSubscription: true,
userEmail: "hi@httptoolkit.com", userEmail: "hi@httptoolkit.com",
mightBePaidUser: true, mightBePaidUser: true,
isPastDueUser: false,
isStatusUnexpired: true,
userSubscription: { userSubscription: {
state: "fulfilled", state: "fulfilled",
status: "active", status: "active",
@@ -25,12 +22,35 @@
}, },
}; };
// Methods to hook on the user object (moved from accountStore properties to user methods in v3.1.0)
const userMethodHooks = {
isPaidUser: true,
isPastDueUser: false,
userHasSubscription: true,
};
const hookedObjects = new WeakSet(); const hookedObjects = new WeakSet();
const hookedUsers = new WeakSet();
// Patch user object methods
function patchUserObject(user) {
if (!user || typeof user !== "object" || hookedUsers.has(user)) return;
for (const methodName of Object.keys(userMethodHooks)) {
if (typeof user[methodName] === "function") {
console.log("[PAGE-INJECT] Patching user." + methodName + "()");
user[methodName] = function () {
return userMethodHooks[methodName];
};
}
}
hookedUsers.add(user);
}
// Override Object.defineProperty to intercept all property definitions // Override Object.defineProperty to intercept all property definitions
const originalDefineProperty = Object.defineProperty; const originalDefineProperty = Object.defineProperty;
Object.defineProperty = function (target, prop, descriptor) { Object.defineProperty = function (target, prop, descriptor) {
// Intercept our target properties
if (prop in propertyHooks) { if (prop in propertyHooks) {
console.log("[PAGE-INJECT] Intercepting defineProperty for: " + prop); console.log("[PAGE-INJECT] Intercepting defineProperty for: " + prop);
@@ -47,6 +67,22 @@
} }
} }
// Intercept the 'user' property to patch its methods when it's set/accessed
if (prop === "user") {
console.log("[PAGE-INJECT] Intercepting defineProperty for: user");
if (descriptor && descriptor.get) {
const originalGetter = descriptor.get;
descriptor.get = function () {
const user = originalGetter.call(this);
if (user) patchUserObject(user);
return user;
};
} else if (descriptor && descriptor.value !== undefined && descriptor.value) {
patchUserObject(descriptor.value);
}
}
return originalDefineProperty.call(this, target, prop, descriptor); return originalDefineProperty.call(this, target, prop, descriptor);
}; };
@@ -67,6 +103,20 @@
props[prop].value = propertyHooks[prop]; props[prop].value = propertyHooks[prop];
} }
} }
if (prop === "user") {
console.log("[PAGE-INJECT] Intercepting defineProperties for: user");
if (props[prop].get) {
const originalGetter = props[prop].get;
props[prop].get = function () {
const user = originalGetter.call(this);
if (user) patchUserObject(user);
return user;
};
} else if (props[prop].value !== undefined && props[prop].value) {
patchUserObject(props[prop].value);
}
}
} }
return originalDefineProperties.call(this, target, props); return originalDefineProperties.call(this, target, props);
}; };
@@ -80,6 +130,7 @@
if (!obj || hookedObjects.has(obj)) return; if (!obj || hookedObjects.has(obj)) return;
try { try {
// Patch direct property hooks
Object.keys(propertyHooks).forEach(prop => { Object.keys(propertyHooks).forEach(prop => {
try { try {
const desc = Object.getOwnPropertyDescriptor(obj, prop); const desc = Object.getOwnPropertyDescriptor(obj, prop);
@@ -88,7 +139,7 @@
if (desc.get) { if (desc.get) {
const originalGetter = desc.get; const originalGetter = desc.get;
Object.defineProperty(obj, prop, { originalDefineProperty(obj, prop, {
get: function () { get: function () {
const originalValue = originalGetter.call(this); const originalValue = originalGetter.call(this);
console.log("[PAGE-INJECT] " + prop + " getter intercepted, original=" + originalValue + ", returning=" + JSON.stringify(propertyHooks[prop])); console.log("[PAGE-INJECT] " + prop + " getter intercepted, original=" + originalValue + ", returning=" + JSON.stringify(propertyHooks[prop]));
@@ -108,6 +159,14 @@
} }
}); });
// Patch user object if present
try {
if (obj.user && typeof obj.user === "object") {
console.log("[PAGE-INJECT] Found user object on object #" + idx + ", patching methods...");
patchUserObject(obj.user);
}
} catch (e) {}
hookedObjects.add(obj); hookedObjects.add(obj);
} catch (e) { } catch (e) {
// Ignore object access errors // Ignore object access errors
@@ -128,7 +187,7 @@
const desc = Object.getOwnPropertyDescriptor(store, prop); const desc = Object.getOwnPropertyDescriptor(store, prop);
if (desc && desc.configurable && desc.get) { if (desc && desc.configurable && desc.get) {
const originalGetter = desc.get; const originalGetter = desc.get;
Object.defineProperty(store, prop, { originalDefineProperty(store, prop, {
get: function () { get: function () {
const originalValue = originalGetter.call(this); const originalValue = originalGetter.call(this);
console.log("[PAGE-INJECT] accountStore." + prop + " intercepted, original=" + originalValue + ", returning=" + JSON.stringify(propertyHooks[prop])); console.log("[PAGE-INJECT] accountStore." + prop + " intercepted, original=" + originalValue + ", returning=" + JSON.stringify(propertyHooks[prop]));
@@ -141,6 +200,15 @@
} }
} catch (e) {} } catch (e) {}
}); });
// Patch user methods on the store
try {
if (store.user && typeof store.user === "object") {
console.log("[PAGE-INJECT] Found user object in accountStore, patching methods...");
patchUserObject(store.user);
}
} catch (e) {}
hookedObjects.add(store); hookedObjects.add(store);
} }
} }
@@ -160,7 +228,7 @@
if (scanCount >= 50) { if (scanCount >= 50) {
clearInterval(scanInterval); clearInterval(scanInterval);
console.log("[PAGE-INJECT] Stopped periodic scanning after 10 attempts"); console.log("[PAGE-INJECT] Stopped periodic scanning after 50 attempts");
} }
}, 100); }, 100);
+201 -86
View File
@@ -1,15 +1,15 @@
{ {
"name": "httptoolkit-patcher", "name": "httptoolkit-patcher",
"version": "2.0.5", "version": "2.0.10",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "httptoolkit-patcher", "name": "httptoolkit-patcher",
"version": "2.0.5", "version": "2.0.10",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@electron/asar": "^3.2.9", "@electron/asar": "^4.0.1",
"chalk": "4" "chalk": "4"
}, },
"bin": { "bin": {
@@ -20,20 +20,29 @@
} }
}, },
"node_modules/@electron/asar": { "node_modules/@electron/asar": {
"version": "3.4.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.4.1.tgz", "resolved": "https://registry.npmjs.org/@electron/asar/-/asar-4.0.1.tgz",
"integrity": "sha512-i4/rNPRS84t0vSRa2HorerGRXWyF4vThfHesw0dmcWHp+cspK743UanA0suA5Q5y8kzY2y6YKrvbIUn69BCAiA==", "integrity": "sha512-F4Ykm1jiBGY1WV/o8Q8oFW8Nq0u+S2/vPujzNJtdSJ6C4LHC4CiGLn7c17s7SolZ23gcvCebMncmZtNc+MkxPQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"commander": "^5.0.0", "commander": "^13.1.0",
"glob": "^7.1.6", "glob": "^11.0.1",
"minimatch": "^3.0.4" "minimatch": "^10.0.1"
}, },
"bin": { "bin": {
"asar": "bin/asar.js" "asar": "bin/asar.mjs"
}, },
"engines": { "engines": {
"node": ">=10.12.0" "node": ">=22.12.0"
}
},
"node_modules/@isaacs/cliui": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-9.0.0.tgz",
"integrity": "sha512-AokJm4tuBHillT+FpMtxQ60n8ObyXBatq7jD2/JA9dxbDDokKQm8KMht5ibGzLVU9IJDIKK4TPKgMHEYMn3lMg==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=18"
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
@@ -62,19 +71,24 @@
} }
}, },
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "1.0.2", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.3.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "integrity": "sha512-1pHv8LX9CpKut1Zp4EXey7Z8OfH11ONNH6Dhi2WDUt31VVZFXZzKwXcysBgqSumFCmR+0dqjMK5v5JiFHzi0+g==",
"license": "MIT" "license": "MIT",
"engines": {
"node": "20 || >=22"
}
}, },
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "1.1.12", "version": "5.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.2.tgz",
"integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "integrity": "sha512-Pdk8c9poy+YhOgVWw1JNN22/HcivgKWwpxKq04M/jTmHyCZn12WPJebZxdjSa5TmBqISrUSgNYU3eRORljfCCw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"balanced-match": "^1.0.0", "balanced-match": "^4.0.2"
"concat-map": "0.0.1" },
"engines": {
"node": "20 || >=22"
} }
}, },
"node_modules/chalk": { "node_modules/chalk": {
@@ -112,42 +126,63 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/commander": { "node_modules/commander": {
"version": "5.1.0", "version": "13.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">= 6" "node": ">=18"
} }
}, },
"node_modules/concat-map": { "node_modules/cross-spawn": {
"version": "0.0.1", "version": "7.0.6",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"license": "MIT" "license": "MIT",
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"license": "ISC"
},
"node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"deprecated": "Glob versions prior to v9 are no longer supported",
"license": "ISC",
"dependencies": { "dependencies": {
"fs.realpath": "^1.0.0", "path-key": "^3.1.0",
"inflight": "^1.0.4", "shebang-command": "^2.0.0",
"inherits": "2", "which": "^2.0.1"
"minimatch": "^3.1.1",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}, },
"engines": { "engines": {
"node": "*" "node": ">= 8"
}
},
"node_modules/foreground-child": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz",
"integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==",
"license": "ISC",
"dependencies": {
"cross-spawn": "^7.0.6",
"signal-exit": "^4.0.1"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/glob": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-11.1.0.tgz",
"integrity": "sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==",
"deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
"license": "BlueOak-1.0.0",
"dependencies": {
"foreground-child": "^3.3.1",
"jackspeak": "^4.1.1",
"minimatch": "^10.1.1",
"minipass": "^7.1.2",
"package-json-from-dist": "^1.0.0",
"path-scurry": "^2.0.0"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"engines": {
"node": "20 || >=22"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
@@ -162,51 +197,122 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/inflight": { "node_modules/isexe": {
"version": "1.0.6", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
"license": "ISC",
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC" "license": "ISC"
}, },
"node_modules/minimatch": { "node_modules/jackspeak": {
"version": "3.1.2", "version": "4.2.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.2.3.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "integrity": "sha512-ykkVRwrYvFm1nb2AJfKKYPr0emF6IiXDYUaFx4Zn9ZuIH7MrzEZ3sD5RlqGXNRpHtvUHJyOnCEFxOlNDtGo7wg==",
"license": "ISC", "license": "BlueOak-1.0.0",
"dependencies": { "dependencies": {
"brace-expansion": "^1.1.7" "@isaacs/cliui": "^9.0.0"
}, },
"engines": { "engines": {
"node": "*" "node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/once": { "node_modules/lru-cache": {
"version": "1.4.0", "version": "11.2.6",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==",
"license": "ISC", "license": "BlueOak-1.0.0",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/minimatch": {
"version": "10.2.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.4.tgz",
"integrity": "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==",
"license": "BlueOak-1.0.0",
"dependencies": { "dependencies": {
"wrappy": "1" "brace-expansion": "^5.0.2"
},
"engines": {
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/path-is-absolute": { "node_modules/minipass": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=16 || 14 >=14.17"
}
},
"node_modules/package-json-from-dist": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
"license": "BlueOak-1.0.0"
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=8"
}
},
"node_modules/path-scurry": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
"integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==",
"license": "BlueOak-1.0.0",
"dependencies": {
"lru-cache": "^11.0.0",
"minipass": "^7.1.2"
},
"engines": {
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"license": "MIT",
"dependencies": {
"shebang-regex": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/signal-exit": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
"license": "ISC",
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/supports-color": { "node_modules/supports-color": {
@@ -228,11 +334,20 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/wrappy": { "node_modules/which": {
"version": "1.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"license": "ISC" "license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
} }
} }
} }
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "httptoolkit-patcher", "name": "httptoolkit-patcher",
"version": "2.0.8", "version": "2.0.11",
"description": "HTTP Toolkit Pro Patcher", "description": "HTTP Toolkit Pro Patcher",
"main": "index.js", "main": "index.js",
"type": "module", "type": "module",
@@ -14,7 +14,7 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@electron/asar": "^3.2.9", "@electron/asar": "^4.0.1",
"chalk": "4" "chalk": "4"
}, },
"devDependencies": { "devDependencies": {