Danny-Dasilva/CycleTLS

feature: add support http/socks tunnel

PandaWorker opened this issue · 0 comments

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': 'my-user-agent@4.1.0'
  },
  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