Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
chrome-debugging-client
Advanced tools
An async/await friendly Chrome debugging client with TypeScript support
An async/await friendly Chrome debugging client with TypeScript support, designed with automation in mind.
DEBUG=chrome-debugging-client
const { spawnChrome } = require("chrome-debugging-client");
const { writeFileSync } = require("fs");
main();
async function main() {
const chrome = spawnChrome();
try {
const browser = chrome.connection;
browser.on("error", err => {
// underlying connection error or error dispatching events.
console.error(`connection error ${err.stack}`);
});
const { targetId } = await browser.send("Target.createTarget", {
url: "about:blank",
});
await browser.send("Target.activateTarget", { targetId });
const page = await browser.attachToTarget(targetId);
let buffer = "";
await page.send("HeapProfiler.enable");
page.on("HeapProfiler.addHeapSnapshotChunk", params => {
buffer += params.chunk;
});
await page.send("HeapProfiler.takeHeapSnapshot", {
reportProgress: false,
});
writeFileSync("heapsnapshot.json", buffer);
await browser.send("Target.closeTarget", { targetId });
// graceful browser shutdown
await chrome.close();
} finally {
await chrome.dispose();
}
}
const { spawnWithWebSocket } = require("chrome-debugging-client");
main();
async function main() {
// start node requesting it break on start at debug port that
// is available
const node = await spawnWithWebSocket(process.execPath, [
"--inspect-brk=0",
"-e",
`const obj = {
hello: "world",
};
debugger;
console.log("end");`,
]);
const { connection } = node;
try {
// we requested Node to break on start, so we runIfWaitingForDebugger
// and wait for it to break at the start of our script
await Promise.all([
connection.until("Debugger.paused"),
connection.send("Debugger.enable"),
connection.send("Runtime.enable"),
connection.send("Runtime.runIfWaitingForDebugger"),
]);
// right now we are paused at the start of the script
// resume until debugger statement hit
const [debuggerStatement] = await Promise.all([
connection.until("Debugger.paused"),
connection.send("Debugger.resume"),
]);
// get the call frame of the debugger statement
const [callFrame] = debuggerStatement.callFrames;
const { callFrameId } = callFrame;
// eval obj at the debugger call frame
const { result } = await connection.send(
"Debugger.evaluateOnCallFrame",
{
callFrameId,
expression: "obj",
returnByValue: true,
},
);
console.log(result.value); //= { hello: "world" }
// resume and wait for execution to be done
await Promise.all([
connection.until("Runtime.executionContextDestroyed"),
connection.send("Debugger.resume"),
]);
// Node is still alive here and waiting for the debugger to disconnect
// when we close the websocket after resuming
// Node should exit on its own
node.close();
await node.waitForExit();
} finally {
await node.dispose();
}
}
FAQs
An async/await friendly Chrome debugging client with TypeScript support
The npm package chrome-debugging-client receives a total of 1,669 weekly downloads. As such, chrome-debugging-client popularity was classified as popular.
We found that chrome-debugging-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.