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

Add -certificate-check and -certificate-verify flags #620

Merged
merged 8 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions cmd/interactsh-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func main() {
flagSet.IntVarP(&cliOptions.CorrelationIdNonceLength, "correlation-id-nonce-length", "cidn", settings.CorrelationIdNonceLengthDefault, "length of the correlation id nonce"),
flagSet.StringVarP(&cliOptions.SessionFile, "session-file", "sf", "", "store/read from session file"),
flagSet.DurationVarP(&cliOptions.KeepAliveInterval, "keep-alive-interval", "kai", time.Minute, "keep alive interval"),
flagSet.BoolVarP(&cliOptions.CheckCert, "certificate-check", "cc", false, "check the certificate of the interactsh server"),
flagSet.BoolVarP(&cliOptions.VerifyCert, "certificate-verify", "cv", false, "verify the certificate of the interactsh server"),
)

flagSet.CreateGroup("filter", "Filter",
Expand Down Expand Up @@ -136,6 +138,8 @@ func main() {
DisableHTTPFallback: cliOptions.DisableHTTPFallback,
CorrelationIdLength: cliOptions.CorrelationIdLength,
CorrelationIdNonceLength: cliOptions.CorrelationIdNonceLength,
VerifyCert: cliOptions.VerifyCert,
CheckCert: cliOptions.CheckCert,
SessionInfo: sessionInfo,
})
if err != nil {
Expand Down
20 changes: 20 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ type Options struct {
SessionInfo *options.SessionInfo
// keepAliveInterval to renew the session
KeepAliveInterval time.Duration
// VerifyCert to skip certificate verification
VerifyCert bool
// CheckCert to check certificate
CheckCert bool
}

// DefaultOptions is the default options for the interact client
Expand Down Expand Up @@ -115,6 +119,22 @@ func New(options *Options) (*Client, error) {
opts.Timeout = 10 * time.Second
httpclient = retryablehttp.NewClient(opts)
}
if options.CheckCert {
httpclient.HTTPClient.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify = false
}
if options.VerifyCert {
httpclient.HTTPClient.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify = false
interactshServerURL := ""
if strings.Contains(options.ServerURL, "://") {
interactshServerURL = options.ServerURL
} else {
interactshServerURL = "https://" + options.ServerURL
}
_, check := httpclient.HTTPClient.Get(interactshServerURL)
if check != nil {
return nil, fmt.Errorf("certificate verification failed: %s", check)
}
}

var correlationID, secretKey, token string

Expand Down
2 changes: 2 additions & 0 deletions pkg/options/client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ type CLIClientOptions struct {
Asn bool
DisableUpdateCheck bool
KeepAliveInterval time.Duration
VerifyCert bool
CheckCert bool
}