mic~ proxy for JA4-TLS fingerprinting evasion |
| git clone https://github.com/djnnvx/mic.git |
| log | files | refs | archive | README | LICENSE |
client.go (2117B)
1 package cmd 2 3 import ( 4 "fmt" 5 "log" 6 "strings" 7 8 "github.com/djnnvx/mic/fingerprint" 9 "github.com/djnnvx/mic/proxy" 10 "github.com/spf13/cobra" 11 ) 12 13 func proxyURL(listen string) string { 14 if strings.HasPrefix(listen, ":") { 15 return "localhost" + listen 16 } 17 return listen 18 } 19 20 func newClientCmd() *cobra.Command { 21 var ( 22 listen string 23 fpName string 24 caPath string 25 interceptCert string 26 interceptKey string 27 ) 28 29 cmd := &cobra.Command{ 30 Use: "client", 31 Short: "HTTP CONNECT proxy with optional MitM interception", 32 RunE: func(cmd *cobra.Command, args []string) error { 33 p := &proxy.Proxy{ListenAddr: listen} 34 35 if caPath != "" { 36 pool, err := loadCAPool(caPath) 37 if err != nil { 38 return err 39 } 40 p.CAPool = pool 41 } 42 43 if fpName != "" { 44 fp, err := fingerprint.ByName(fpName) 45 if err != nil { 46 return fmt.Errorf("loading fingerprint: %w", err) 47 } 48 p.Fingerprint = fp 49 log.Printf("[+] Using TLS fingerprint: %s", fp.Name()) 50 } 51 52 if (interceptCert == "") != (interceptKey == "") { 53 return fmt.Errorf("--intercept-cert and --intercept-key must be given together") 54 } 55 if interceptCert != "" { 56 ca, err := proxy.LoadOrGenerateCA(interceptCert, interceptKey) 57 if err != nil { 58 return fmt.Errorf("loading/generating intercept CA: %w", err) 59 } 60 p.LocalCA = ca 61 log.Printf("[+] MitM CA ready. Import %s, then: curl --cacert %s -x http://%s https://<target>", 62 interceptCert, interceptCert, proxyURL(listen)) 63 } 64 65 log.Printf("[+] Mode: client (HTTP CONNECT proxy on %s)", listen) 66 p.Handler = proxy.HttpsHandler 67 return p.Run() 68 }, 69 } 70 71 cmd.Flags().StringVarP(&listen, "listen", "l", ":8080", "listen address") 72 cmd.Flags().StringVarP(&fpName, "fingerprint", "f", "", "TLS fingerprint profile name (e.g. chrome-120)") 73 cmd.Flags().StringVar(&caPath, "ca", "", "path to upstream CA certificate") 74 cmd.Flags().StringVar(&interceptCert, "intercept-cert", "", "MitM CA cert path (enables interception)") 75 cmd.Flags().StringVar(&interceptKey, "intercept-key", "", "MitM CA key path (enables interception)") 76 77 return cmd 78 }