diff --git a/cli/cmd/gotls.go b/cli/cmd/gotls.go index 9055f8f84..d722b219e 100644 --- a/cli/cmd/gotls.go +++ b/cli/cmd/gotls.go @@ -34,12 +34,12 @@ var goc = config.NewGoTLSConfig() var gotlsCmd = &cobra.Command{ Use: "gotls", Aliases: []string{"tlsgo"}, - Short: "capturing plaintext communication of TLS/HTTPS encrypted programs written in Golang.", - Long: `use eBPF uprobe/TC to capture process event data and network data. also support pcap-NG format. + Short: "Capturing plaintext communication from Golang programs encrypted with TLS/HTTPS.", + Long: `Utilize eBPF uprobe/TC to capture both process event and network data, with added support for pcap-NG format. ecapture gotls ecapture gotls --elfpath=/home/cfc4n/go_https_client --hex --pid=3423 ecapture gotls --elfpath=/home/cfc4n/go_https_client -l save.log --pid=3423 -ecapture gotls -w save_android.pcapng -i wlan0 --port 443 --gobin=/home/cfc4n/go_https_client +ecapture gotls -w save_android.pcapng -i wlan0 --port 443 --elfpath=/home/cfc4n/go_https_client `, Run: goTLSCommandFunc, } @@ -100,8 +100,8 @@ func goTLSCommandFunc(command *cobra.Command, args []string) { err = conf.Check() if err != nil { - // ErrorGoBINNotSET is a special error, we should not print it. - if errors.Is(err, config.ErrorGoBINNotSET) { + // ErrorGoBINNotFound is a special error, we should not print it. + if errors.Is(err, config.ErrorGoBINNotFound) { logger.Printf("%s\tmodule [disabled].", mod.Name()) return } diff --git a/cli/cmd/tls.go b/cli/cmd/tls.go index 92e343f03..91f4b45ea 100644 --- a/cli/cmd/tls.go +++ b/cli/cmd/tls.go @@ -19,7 +19,6 @@ import ( "ecapture/pkg/util/kernel" "ecapture/user/config" "ecapture/user/module" - "errors" "log" "os" "os/signal" @@ -136,12 +135,6 @@ func openSSLCommandFunc(command *cobra.Command, args []string) { err = conf.Check() if err != nil { - // ErrorGoBINNotSET is a special error, we should not print it. - if errors.Is(err, config.ErrorGoBINNotSET) { - logger.Printf("%s\tmodule [disabled].", mod.Name()) - continue - } - logger.Printf("%s\tmodule initialization failed. [skip it]. error:%+v", mod.Name(), err) continue } diff --git a/tests/golang_https.go b/tests/golang_https.go new file mode 100644 index 000000000..53383286d --- /dev/null +++ b/tests/golang_https.go @@ -0,0 +1,40 @@ +package main + +import ( + "crypto/tls" + "fmt" + "io" + "net/http" + "os" + "path/filepath" +) + +func main() { + + b, e := GetHttp("https://github.com") + if e == nil { + fmt.Printf("response body: %s\n\n", b) + } else { + fmt.Printf("error :%v", e) + } +} + +func GetHttp(url string) (body []byte, err error) { + f, err := os.OpenFile(filepath.Join(os.TempDir(), "ecapture_go_master_secret.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) + if err != nil { + panic(err) + } + defer f.Close() + c := &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true, KeyLogWriter: f}, + }} + resp, e := c.Get(url) + if e != nil { + return nil, e + } + + defer resp.Body.Close() + body, err = io.ReadAll(resp.Body) + return body, err +} diff --git a/user/config/config_gotls.go b/user/config/config_gotls.go index 99501f22b..b248ebee8 100644 --- a/user/config/config_gotls.go +++ b/user/config/config_gotls.go @@ -20,7 +20,7 @@ import ( ) var ( - ErrorGoBINNotSET = errors.New("GO binary not set") + ErrorGoBINNotFound = errors.New("GO binary not found") ) // GoTLSConfig represents configuration for Go SSL probe @@ -39,7 +39,7 @@ func NewGoTLSConfig() *GoTLSConfig { func (c *GoTLSConfig) Check() error { if c.Path == "" { - return ErrorGoBINNotSET + return ErrorGoBINNotFound } if c.Ifname == "" || len(c.Ifname) == 0 {