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

feature: add support http/socks tunnel #325

Open
PandaWorker opened this issue Feb 12, 2024 · 0 comments
Open

feature: add support http/socks tunnel #325

PandaWorker opened this issue Feb 12, 2024 · 0 comments
Assignees
Labels
triage This ticket will be looked at shortly

Comments

@PandaWorker
Copy link

PandaWorker commented Feb 12, 2024

Description

Hello, How about making a tls ja3 tunnel with proxy?

The client sends a CONNECT request, and the tunnel builds a connection using utls through a proxy to the final host and gives this socket to the client.
See how this is implemented in https://github.com/sleeyax/burp-awesome-tls/tree/main/src-go/server, https://github.com/rosahaj/tlsproxy and https://github.com/LyleMi/ja3proxy

sample usage with node js

// main.mjs
import * as undici from 'undici';

const ja3tunnel = new URL('http://localhost:8888');
const httpProxyUri = new URL('http://localhost:3000');

const dispatcher = buildProxyAgent(ja3tunnel, {
  // headers CONNECT method
  headers: {
    'x-tls-timeout': '1000', // timeout ms
    'x-tls-proxy': `${httpProxyUri}`,
    'x-tls-client': 'Chrome-120', // or x-tls-ja3
    'x-tls-ja3': '771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0', // or x-tls-client
    // ... all other tls ja3 options
  }
});

const resp = await undici.request('https://check.ja3.zone/', {
  headers: {
    'user-agent': '[email protected]'
  },
  dispatcher
});
const data = await resp.json();
console.log(data);


// proxy.mjs
import * as undici from 'undici';

/**
 *
 * @param {URL | string} uri
 * @param {undici.ProxyAgent.Options} proxyOptions
 * @returns {undici.ProxyAgent}
 */
export function buildProxyAgent(uri, proxyOptions = {}) {
    return new undici.ProxyAgent(buildProxyOptions(uri, proxyOptions));
}

/**
 *
 * @param {URL | string} uri
 * @param {undici.ProxyAgent.Options} proxyOptions
 * @returns {undici.ProxyAgent.Options}
 */
export function buildProxyOptions(uri, proxyOptions = {}) {
	const { origin, username, password } = new URL(uri);
	const token = Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString('base64');

	return {
		uri: origin,
		token: `Basic ${token}`,
		...proxyOptions,
	};
}

Issue Type

Feature Request

Operating System

No response

Node Version

None

Golang Version

None

Relevant Log Output

No response

@PandaWorker PandaWorker added the triage This ticket will be looked at shortly label Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage This ticket will be looked at shortly
Projects
None yet
Development

No branches or pull requests

2 participants