
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
A bridge between Python's mitmproxy
and Node.JS programs. Rewrite network requests using Node.JS!
It is far easier to rewrite JavaScript/HTML/etc using JavaScript than Python, but mitmproxy only accepts Python plugins. There are no decent alternatives to mitmproxy, so this package lets me use mitmproxy with Node.js-based rewriting code.
For transparently rewriting HTTP/HTTPS responses. The mitmproxy plugin lets every HTTP request go through to the server uninhibited, and then passes it to Node.js via a WebSocket for rewriting. You can optionally specify a list of paths that should be directly intercepted without being passed to the server.
If you want to add additional functionality, such as filtering or whatnot, I'll accept pull requests so long as they do not noticeably hinder performance.
A Python plugin for mitmproxy
starts a WebSocket server, and mitmproxy-node
talks with it over WebSocket messages. The two communicate via binary messages to reduce marshaling-related overhead.
I have no idea what I am doing. PRs to improve my Python code are appreciated!
mitmproxy
V4 must be installed and runnable from the terminal. The install method cannot be a prebuilt binary or homebrew, since those packages are missing the Python websockets module. Install via pip
or from source.npm install
to pull in Node and PIP dependencies.You can either start mitmproxy
manually with mitmdump --anticache -s scripts/proxy.py
, or mitmproxy-node
will do so automatically for you.
mitmproxy-node
auto-detects if mitmproxy
is already running.
If you frequently start/stop the proxy, it may be best to start it manually.
import MITMProxy from 'mitmproxy-node';
// Returns Promise<MITMProxy>
async function makeProxy() {
// Note: Your interceptor can also be asynchronous and return a Promise!
return MITMProxy.Create(function(interceptedMsg) {
const req = interceptedMsg.request;
const res = interceptedMsg.response;
if (req.rawUrl.contains("target.js") && res.getHeader('content-type').indexOf("javascript") !== -1) {
interceptedMsg.setResponseBody(Buffer.from(`Hacked!`, 'utf8'));
}
}, ['/eval'] /* list of paths to directly intercept -- don't send to server */,
true /* Be quiet; turn off for debug messages */,
true /* Only intercept text or potentially-text requests (all mime types with *application* and *text* in them, plus responses with no mime type) */
);
}
async function main() {
const proxy = await makeProxy();
// when done:
await proxy.shutdown();
}
Without fancy async/await:
import MITMProxy from 'mitmproxy-node';
// Returns Promise<MITMProxy>
function makeProxy() {
return MITMProxy.Create(function(interceptedMsg) {
const req = interceptedMsg.request;
const res = interceptedMsg.response;
if (req.rawUrl.contains("target.js") && res.getHeader('content-type').indexOf("javascript") !== -1) {
interceptedMsg.setResponseBody(Buffer.from(`Hacked!`, 'utf8'));
}
}, ['/eval'], true, true);
}
function main() {
makeProxy().then((proxy) => {
// when done
proxy.shutdown.then(() => {
// Proxy is closed!
});
});
}
npm run build
FAQs
NodeJS mitmproxy adapter.
The npm package mitmproxy receives a total of 785 weekly downloads. As such, mitmproxy popularity was classified as not popular.
We found that mitmproxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.