Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monitor proxy traffic #45

Open
stefanocudini opened this issue Apr 23, 2020 · 3 comments
Open

monitor proxy traffic #45

stefanocudini opened this issue Apr 23, 2020 · 3 comments

Comments

@stefanocudini
Copy link

hi beautiful lib! congrants

I was trying to write a proxy socks that could log the http traffic and contents and show in stdout.

how can I do it? is there something like this already done?

my attempts is this:

const socks = require('socksv5');

const PORT = 9052;

//console.clear();

var srv = socks.createServer(function(info, accept, deny) {

  console.log('\n',info.cmd, info.dstAddr, info.dstPort);

  if (info.dstPort === 80) {  //NOT SSL
    var socket;
    if (socket = accept(true)) {

      	/*socket.on('data', function(data) {
			console.log('DATA:', data.toString('ascii') );
		});*/

		socket.pipe(process.stdout);
		//socket.end()
    }
  }
  else	//SSL connection
    accept();
});

srv.listen(PORT, 'localhost', function() {
  console.log('SOCKS server listening on port',PORT);
});

srv.useAuth(socks.auth.None());
@mscdex
Copy link
Owner

mscdex commented Apr 23, 2020

I'm not sure what you're asking. Do you not see the raw data printed to stdout with the code you've shown?

@stefanocudini
Copy link
Author

yes.. but only the headers, I wish I could see the body of requests and responses :-/

@mscdex
Copy link
Owner

mscdex commented Apr 24, 2020

  1. You'll only see request bodies if they're sent, which may not always be the case
  2. Responses require you to make an actual connection to the intended destination. Right now you're just connecting the incoming request socket to stdout. You have to make a separate socket connection to dstAddr:dstPort and pipe that back to socket (and optionally log that to stdout if you want).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants