hmgle / graftcp

A flexible tool for redirecting a given program's TCP traffic to SOCKS5 or HTTP proxy.
GNU General Public License v3.0
2.1k stars 175 forks source link

openssl error reported when connect to https #74

Open ziyouchutuwenwu opened 16 hours ago

ziyouchutuwenwu commented 16 hours ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

$ mgraftcp curl -I https://www.google.com
curl: (60) SSL: no alternative certificate subject name matches target hostname 'www.google.com'
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the webpage mentioned above.

graftcp-local.conf

## graftcp-local configuation

## Listen address (default ":2233")
listen = :2233

## Write logs to file, to stdout if empty
# logfile = graftcp-local.log

## Log level (0-6), 0: debug, 1: info, 2: notice, 3: warn, 4: error,
## 5: critical: 6: fatal
loglevel = 1

## Pipe path for graftcp to send address info (default "/tmp/graftcplocal.fifo")
# pipepath = /tmp/graftcplocal.fifo

## SOCKS5 address (default "127.0.0.1:1080")
socks5 = 127.0.0.1:1080
http_proxy = 127.0.0.1:8118

## SOCKS5 proxy username (default "")
# socks5_username = SOCKS5USERNAME

## SOCKS5 proxy password (default "")
# socks5_password = SOCKS5PASSWORD

## HTTP proxy address (default "")
# http_proxy = 127.0.0.1:8080

## Set the mode for select a proxy (default "auto")
## "auto": select socks5 if socks5 is reachable, else HTTP proxy if HTTP proxy
##  is rechable, else direct.
## "random": select the reachable proxy randomly.
## "only_http_proxy": only use http proxy.
## "only_socks5": only use socks5 proxy.
## "direct": direct connect.
# select_proxy_mode = only_socks5
select_proxy_mode = only_http_proxy

## Use the system logger (syslog on Unix, Event Log on Windows)
## use_syslog = true

http config of privoxy

$ cat /etc/privoxy/config 
listen-address 0.0.0.0:8118
forward-socks5t / 127.0.0.1:1080 .

i try mgraftcp with curl, then gets different ip

$ curl ipinfo.io/ip
218.90.xxx.xxx
$ mgraftcp curl ipinfo.io/ip
122.118.yyy.yyy

when i set HTTP_PROXY HTTPS_PROXY env

HTTP_PROXY=http://127.0.0.1:8118
HTTPS_PROXY=http://127.0.0.1:8118
ALL_PROXY=socks5://127.0.0.1:1080
$ curl -I https://www.google.com
HTTP/1.1 200 Connection established

HTTP/2 200 
content-type: text/html; charset=ISO-8859-1
content-security-policy-report-only: object-src 'none';base-uri 'self';script-src 'nonce-MnVwTkNsrFbip0Sd0nKa0w' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
accept-ch: Sec-CH-Prefers-Color-Scheme
p3p: CP="This is not a P3P policy! See g.co/p3phelp for more info."
date: Mon, 23 Sep 2024 03:07:32 GMT
server: gws
x-xss-protection: 0
x-frame-options: SAMEORIGIN
expires: Mon, 23 Sep 2024 03:07:32 GMT
cache-control: private
set-cookie: AEC=AVYB7crWZUvdIBNYQMmbkBH7hmkW4AU7-nwkGX88UgfM9cpWLSU_vhrwwg; expires=Sat, 22-Mar-2025 03:07:32 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax
set-cookie: NID=517=Auk5jifZBvxZeSmRnu8osdNFqTMD6qyW0LPpZAuvq3ytHsU4BGDXEErexgeyEARmJ8I7fLa-7Jyt8e9u9GdKUDScUjdDIELVnq1T2kPFzWnY6spTq041MEIdhk4EZvyFkalZc9eal2nl27KncQcQuvQu67ol_qwnRdd-6eAIp2UDPUA0UeEfZtAQqnk-Rsk; expires=Tue, 25-Mar-2025 03:07:32 GMT; path=/; domain=.google.com; HttpOnly
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

Expected behavior get correct html from this command

$ mgraftcp curl -I https://www.google.com

Screenshots image

Desktop (please complete the following information):

hmgle commented 7 hours ago

You can try mgraftcp --enable-debug-log --select_proxy_mode=only_http_proxy --http_proxy=127.0.0.1:8118 curl -v -I https://www.google.com and check the logs.