Skip to content

Commit

Permalink
Merge pull request #174 from projectdiscovery/dev
Browse files Browse the repository at this point in the history
tlsx v1.0.5
  • Loading branch information
ehsandeep authored Jan 28, 2023
2 parents 6a17955 + 97bfa76 commit 497719f
Show file tree
Hide file tree
Showing 25 changed files with 1,501 additions and 204 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ jobs:
- name: Race Condition Tests
run: go build -race .
working-directory: cmd/tlsx/

- name: Test Example Code
run: go run .
working-directory: examples/


2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.18.2-alpine3.14 AS build-env
RUN apk add --no-cache build-base
RUN go install -v github.com/projectdiscovery/tlsx/cmd/tlsx@latest

FROM alpine:3.17.0
FROM alpine:3.17.1
RUN apk add --no-cache bind-tools ca-certificates
COPY --from=build-env /go/bin/tlsx /usr/local/bin/tlsx
ENTRYPOINT ["tlsx"]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<p align="center">
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-_red.svg"></a>
<a href="https://goreportcard.com/badge/github.com/projectdiscovery/tlsx"><img src="https://goreportcard.com/badge/github.com/projectdiscovery/tlsx"></a>
<a href="https://pkg.go.dev/github.com/projectdiscovery/tlsx/pkg/tlsx"><img src="https://img.shields.io/badge/go-reference-blue"></a>
<a href="https://github.com/projectdiscovery/tlsx/releases"><img src="https://img.shields.io/github/release/projectdiscovery/tlsx"></a>
<a href="https://twitter.com/pdiscoveryio"><img src="https://img.shields.io/twitter/follow/pdiscoveryio.svg?logo=twitter"></a>
<a href="https://discord.gg/projectdiscovery"><img src="https://img.shields.io/discord/695645237418131507.svg?logo=discord"></a>
Expand Down Expand Up @@ -125,8 +126,15 @@ OUTPUT:
-nc, -no-color disable colors in cli output
-v, -verbose display verbose output
-version display project version

DEBUG:
-health-check, -hc run diagnostic check up
```

## Using tlsx as library

Examples of using tlsx as library are provided in the [examples](examples/) folder.

## Running tlsx

### Input for tlsx
Expand Down Expand Up @@ -521,6 +529,7 @@ $ tlsx -u example.com -ci cipher_list.txt -cipher
This program optionally uses:

- [zcrypto](https://github.com/zmap/zcrypto) library from the zmap team.
- [cfssl](https://github.com/cloudflare/cfssl) library from the cloudflare team

--------

Expand Down
13 changes: 0 additions & 13 deletions assets/openssl.include

This file was deleted.

23 changes: 16 additions & 7 deletions cmd/tlsx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"os"
"strings"

"github.com/pkg/errors"
"github.com/projectdiscovery/goflags"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/tlsx/internal/runner"
Expand All @@ -27,20 +26,20 @@ func main() {

func process() error {
if err := readFlags(); err != nil {
return errors.Wrap(err, "could not read flags")
return errorutils.NewWithErr(err).Msgf("could not read flags")
}
runner, err := runner.New(options)
if err != nil {
return errors.Wrap(err, "could not create runner")
return errorutils.NewWithErr(err).Msgf("could not create runner")
}
if runner == nil {
return nil
}
if err := runner.Execute(); err != nil {
return errors.Wrap(err, "could not execute runner")
return errorutils.NewWithErr(err).Msgf("could not execute runner")
}
if err := runner.Close(); err != nil {
return errors.Wrap(err, "could not close runner")
return errorutils.NewWithErr(err).Msgf("could not close runner")
}
return nil
}
Expand Down Expand Up @@ -106,6 +105,7 @@ func readFlags() error {
flagSet.BoolVarP(&options.TLSChain, "tls-chain", "tc", false, "include certificates chain in json output"),
flagSet.BoolVarP(&options.VerifyServerCertificate, "verify-cert", "vc", false, "enable verification of server certificate"),
flagSet.StringVarP(&options.OpenSSLBinary, "openssl-binary", "ob", "", "OpenSSL Binary Path"),
flagSet.BoolVarP(&options.HardFail, "hardfail", "hf", false, "strategy to use if encountered errors while checking revocation status"),
)

flagSet.CreateGroup("optimizations", "Optimizations",
Expand All @@ -125,13 +125,22 @@ func readFlags() error {
flagSet.BoolVar(&options.Version, "version", false, "display project version"),
)

flagSet.CreateGroup("debug", "Debug",
flagSet.BoolVarP(&options.HealthCheck, "hc", "health-check", false, "run diagnostic check up"),
)

if err := flagSet.Parse(); err != nil {
return errors.Wrap(err, "could not parse flags")
return errorutils.NewWithErr(err).Msgf("could not parse flags")
}

if options.HealthCheck {
gologger.Print().Msgf("%s\n", runner.DoHealthCheck(flagSet))
os.Exit(0)
}

if cfgFile != "" {
if err := flagSet.MergeConfigFile(cfgFile); err != nil {
return errors.Wrap(err, "could not read config file")
return errorutils.NewWithErr(err).Msgf("could not read config file")
}
}
return nil
Expand Down
39 changes: 39 additions & 0 deletions examples/simple.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"

"github.com/projectdiscovery/tlsx/pkg/tlsx"
"github.com/projectdiscovery/tlsx/pkg/tlsx/clients"
)

func main() {
// setup tlsx client with options
// https://pkg.go.dev/github.com/projectdiscovery/tlsx/pkg/tlsx/clients#Options
opts := &clients.Options{
TLSVersion: true,
Retries: 3,
Expired: true,
}

// available scanmodes
allmodes := []string{"auto", "openssl", "ctls", "ztls"}

for _, scanMode := range allmodes {
opts.ScanMode = scanMode
// create tlsx service with options
service, err := tlsx.New(opts)
if err != nil {
panic(err)
}

// connect to any host either with hostname or ip
// service.Connect(hostname, ip , port string)
resp, err := service.Connect("scanme.sh", "", "443")
if err != nil {
panic(err)
}

fmt.Printf("[%v] scan-mode:%-7v tls-version:%v self-signed:%v cipher:%v\n", resp.Host, scanMode, resp.Version, resp.SelfSigned, resp.Cipher)
}
}
104 changes: 83 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,107 @@ require (
github.com/json-iterator/go v1.1.12
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/miekg/dns v1.1.50
github.com/pkg/errors v0.9.1
github.com/projectdiscovery/dnsx v1.1.1
github.com/projectdiscovery/fastdialer v0.0.20
github.com/projectdiscovery/fastdialer v0.0.22
github.com/projectdiscovery/fileutil v0.0.3
github.com/projectdiscovery/goflags v0.1.6
github.com/projectdiscovery/gologger v1.1.7
github.com/projectdiscovery/mapcidr v1.0.3
github.com/projectdiscovery/utils v0.0.4-0.20230102120019-c7a04e2045be
github.com/projectdiscovery/utils v0.0.6-0.20230123163654-ee9de8dc49ab
github.com/rs/xid v1.4.0
github.com/stretchr/testify v1.8.1
github.com/zmap/zcrypto v0.0.0-20230113044912-682e75113af0
go.uber.org/multierr v1.9.0
golang.org/x/exp v0.0.0-20221019170559-20944726eadf
)

require (
cloud.google.com/go v0.81.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/cncf/udpa/go v0.0.0-20210322005330-6414d713912e // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.1 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fullstorydev/grpcurl v1.8.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.5.0 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/certificate-transparency-go v1.1.2-0.20210511102531-373a877eec92 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jhump/protoreflect v1.8.2 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/prometheus/client_golang v1.10.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.24.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/cobra v1.1.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
github.com/urfave/cli v1.22.5 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 // indirect
go.etcd.io/etcd/client/v2 v2.305.0-alpha.0 // indirect
go.etcd.io/etcd/client/v3 v3.5.0-alpha.0 // indirect
go.etcd.io/etcd/etcdctl/v3 v3.5.0-alpha.0 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0 // indirect
go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0 // indirect
go.etcd.io/etcd/server/v3 v3.5.0-alpha.0 // indirect
go.etcd.io/etcd/tests/v3 v3.5.0-alpha.0 // indirect
go.etcd.io/etcd/v3 v3.5.0-alpha.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 // indirect
google.golang.org/grpc v1.38.0 // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

require (
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/Mzack9999/go-http-digest-auth-client v0.6.1-0.20220414142836-eb8883508809 // indirect
github.com/akrylysov/pogreb v0.10.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/cfssl v1.6.3
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/errors v1.9.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
github.com/cockroachdb/pebble v0.0.0-20210728210723-48179f1d4dae // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgraph-io/badger v1.6.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/getsentry/sentry-go v0.12.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
Expand All @@ -55,37 +118,36 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/projectdiscovery/asnmap v0.0.1 // indirect
github.com/projectdiscovery/blackrock v0.0.0-20220628111055-35616c71b2dc // indirect
github.com/projectdiscovery/cdncheck v0.0.3 // indirect
github.com/projectdiscovery/fileutil v0.0.3 // indirect
github.com/projectdiscovery/hmap v0.0.2 // indirect
github.com/projectdiscovery/iputil v0.0.2 // indirect
github.com/projectdiscovery/networkpolicy v0.0.3 // indirect
github.com/projectdiscovery/retryabledns v1.0.17 // indirect
github.com/projectdiscovery/retryablehttp-go v1.0.2 // indirect
github.com/projectdiscovery/retryabledns v1.0.20 // indirect
github.com/projectdiscovery/retryablehttp-go v1.0.10-0.20230123170312-75b58f90739a
github.com/projectdiscovery/sliceutil v0.0.1 // indirect
github.com/projectdiscovery/stringsutil v0.0.2 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 // indirect
github.com/weppos/publicsuffix-go v0.15.1-0.20220724114530-e087fba66a37 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/yl2chen/cidranger v1.0.2 // indirect
github.com/zmap/rc2 v0.0.0-20131011165748-24b9757f5521 // indirect
github.com/zmap/zcertificate v0.0.0-20180516150559-0e3d58b1bac4 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/tools v0.2.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/tools v0.5.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 497719f

Please sign in to comment.