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

bugfix: Error unknown flag gobin (fixes #354 ) #355

Merged
merged 2 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cli/cmd/gotls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 0 additions & 7 deletions cli/cmd/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"ecapture/pkg/util/kernel"
"ecapture/user/config"
"ecapture/user/module"
"errors"
"log"
"os"
"os/signal"
Expand Down Expand Up @@ -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
}
Expand Down
40 changes: 40 additions & 0 deletions tests/golang_https.go
Original file line number Diff line number Diff line change
@@ -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},

Check failure

Code scanning / CodeQL

Disabled TLS certificate check

InsecureSkipVerify should not be used in production code.
}}
resp, e := c.Get(url)
if e != nil {
return nil, e
}

defer resp.Body.Close()
body, err = io.ReadAll(resp.Body)
return body, err
}
4 changes: 2 additions & 2 deletions user/config/config_gotls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down