Skip to content

Commit 621db20

Browse files
authored
Merge pull request #215 from projectdiscovery/dev
tlsx v1.0.6
2 parents 8f9f4a3 + 9c4d6e6 commit 621db20

32 files changed

+1090
-721
lines changed

.github/workflows/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, windows-latest, macOS-12]
14-
go-version: [1.18.x, 1.19.x]
14+
go-version: [1.19.x, 1.20.x]
1515
steps:
1616
- name: Set up Go
1717
uses: actions/setup-go@v3
@@ -30,7 +30,7 @@ jobs:
3030
working-directory: .
3131

3232
- name: Race Condition Tests
33-
run: go build -race .
33+
run: go run -race . -u scanme.sh
3434
working-directory: cmd/tlsx/
3535

3636
- name: Test Example Code

.github/workflows/dockerhub-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
password: ${{ secrets.DOCKER_TOKEN }}
3333

3434
- name: Build and push
35-
uses: docker/build-push-action@v3
35+
uses: docker/build-push-action@v4
3636
with:
3737
context: .
3838
platforms: linux/amd64,linux/arm64,linux/arm

.github/workflows/lint-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
- name: "Set up Go"
1414
uses: actions/setup-go@v3
1515
with:
16-
go-version: 1.18
16+
go-version: 1.19
1717
- name: Run golangci-lint
18-
uses: golangci/golangci-lint-action@v3.3.1
18+
uses: golangci/golangci-lint-action@v3.4.0
1919
with:
2020
version: latest
2121
args: --timeout 5m

.github/workflows/release-binary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: "Set up Go"
1818
uses: actions/setup-go@v3
1919
with:
20-
go-version: 1.18
20+
go-version: 1.19
2121

2222
- name: "Create release on GitHub"
2323
uses: goreleaser/goreleaser-action@v4

.github/workflows/sonarcloud.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM golang:1.18.2-alpine3.14 AS build-env
22
RUN apk add --no-cache build-base
33
RUN go install -v github.com/projectdiscovery/tlsx/cmd/tlsx@latest
44

5-
FROM alpine:3.17.1
5+
FROM alpine:3.17.2
66
RUN apk add --no-cache bind-tools ca-certificates
77
COPY --from=build-env /go/bin/tlsx /usr/local/bin/tlsx
88
ENTRYPOINT ["tlsx"]

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ A fast and configurable TLS grabber focused on TLS based **data collection and a
4343

4444
## Installation
4545

46-
tlsx requires **Go 1.18** to install successfully. To install, just run the below command or download pre-compiled binary from [release page](https://github.com/projectdiscovery/tlsx/releases).
46+
tlsx requires **Go 1.19** to install successfully. To install, just run the below command or download pre-compiled binary from [release page](https://github.com/projectdiscovery/tlsx/releases).
4747

4848
```console
4949
go install github.com/projectdiscovery/tlsx/cmd/tlsx@latest
@@ -88,14 +88,17 @@ PROBES:
8888
-tps, -probe-status display tls probe status
8989
-ve, -version-enum enumerate and display supported tls versions
9090
-ce, -cipher-enum enumerate and display supported cipher
91+
-ct, -cipher-type ciphers types to enumerate (all/secure/insecure/weak) (default 0)
9192
-ch, -client-hello include client hello in json output (ztls mode only)
9293
-sh, -server-hello include server hello in json output (ztls mode only)
94+
-se, -serial display certificate serial number
9395

9496
MISCONFIGURATIONS:
9597
-ex, -expired display host with host expired certificate
9698
-ss, -self-signed display host with self-signed certificate
9799
-mm, -mismatched display host with mismatched certificate
98100
-re, -revoked display host with revoked certificate
101+
-un, -untrusted display host with untrusted certificate
99102

100103
CONFIGURATIONS:
101104
-config string path to the tlsx configuration file
@@ -104,23 +107,28 @@ CONFIGURATIONS:
104107
-ci, -cipher-input string[] ciphers to use with tls connection
105108
-sni string[] tls sni hostname to use
106109
-rs, -random-sni use random sni when empty
110+
-rps, -rev-ptr-sni perform reverse PTR to retrieve SNI from IP
107111
-min-version string minimum tls version to accept (ssl30,tls10,tls11,tls12,tls13)
108112
-max-version string maximum tls version to accept (ssl30,tls10,tls11,tls12,tls13)
109-
-ac, -all-ciphers send all ciphers as accepted inputs (default true)
110113
-cert, -certificate include certificates in json output (PEM format)
111114
-tc, -tls-chain include certificates chain in json output
112115
-vc, -verify-cert enable verification of server certificate
113116
-ob, -openssl-binary string OpenSSL Binary Path
117+
-hf, -hardfail strategy to use if encountered errors while checking revocation status
114118

115119
OPTIMIZATIONS:
116120
-c, -concurrency int number of concurrent threads to process (default 300)
117121
-timeout int tls connection timeout in seconds (default 5)
118122
-retry int number of retries to perform for failures (default 3)
119123
-delay string duration to wait between each connection per thread (eg: 200ms, 1s)
120124

125+
UPDATE:
126+
-up, -update update tlsx to latest version
127+
-duc, -disable-update-check disable automatic tlsx update check
128+
121129
OUTPUT:
122130
-o, -output string file to write output to
123-
-j, -json display json format output
131+
-j, -json display output in jsonline format
124132
-ro, -resp-only display tls response only
125133
-silent display silent output
126134
-nc, -no-color disable colors in cli output
@@ -320,12 +328,12 @@ support.hackerone.com:443 [TLS1.2] [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256]
320328

321329
# TLS Misconfiguration
322330

323-
### Expired / Self Signed / Mismatched / Revoked Certificate
331+
### Expired / Self Signed / Mismatched / Revoked / Untrusted Certificate
324332

325-
A list of host can be provided to tlsx to detect **expired / self-signed / mismatched / revoked** certificates.
333+
A list of host can be provided to tlsx to detect **expired / self-signed / mismatched / revoked / untrusted** certificates.
326334

327335
```console
328-
$ tlsx -l hosts.txt -expired -self-signed -mismatched -revoked
336+
$ tlsx -l hosts.txt -expired -self-signed -mismatched -revoked -untrusted
329337
330338

331339
_____ _ _____ __
@@ -342,6 +350,7 @@ wrong.host.badssl.com:443 [mismatched]
342350
self-signed.badssl.com:443 [self-signed]
343351
expired.badssl.com:443 [expired]
344352
revoked.badssl.com:443 [revoked]
353+
untrusted-root.badssl.com:443 [untrusted]
345354
```
346355

347356
### [JARM](https://engineering.salesforce.com/easily-identify-malicious-servers-on-the-internet-with-jarm-e095edac525a/) TLS Fingerprint
@@ -530,6 +539,7 @@ This program optionally uses:
530539

531540
- [zcrypto](https://github.com/zmap/zcrypto) library from the zmap team.
532541
- [cfssl](https://github.com/cloudflare/cfssl) library from the cloudflare team
542+
- cipher data from [ciphersuite.info](https://ciphersuite.info) for ciphersuite classification
533543

534544
--------
535545

assets/cipherstatus_data.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package assets
2+
3+
import (
4+
_ "embed"
5+
"encoding/json"
6+
7+
"github.com/projectdiscovery/gologger"
8+
stringsutil "github.com/projectdiscovery/utils/strings"
9+
)
10+
11+
//go:embed cipherstatus_data.json
12+
var CipherDataBin string
13+
14+
// CipherSecLevel contains cipher and its security level
15+
// Source: https://ciphersuite.info/
16+
var CipherSecLevel map[string]string = map[string]string{}
17+
18+
// GetSecureCiphers returns Ciphers with status `Recommended` and `Secure`
19+
// Ex: https://ciphersuite.info/cs/TLS_AES_128_CCM_8_SHA256/
20+
func GetSecureCipherSuites() []string {
21+
return getCipherWithLevel("Recommended", "Secure")
22+
}
23+
24+
// GetInSecureCipherSuites returns Ciphers with status `Insecure`.
25+
// Insecure Ciphers either uses no authentication at all or does not provide confidentiality
26+
// Ex: https://ciphersuite.info/cs/TLS_NULL_WITH_NULL_NULL/
27+
func GetInSecureCipherSuites() []string {
28+
return getCipherWithLevel("Insecure")
29+
}
30+
31+
// GetWeakCipherSuites returns Ciphers with status `Weak`.
32+
// Weak Cipher suites use algorithms that are proven to be weak or can be broken
33+
// Ex: https://ciphersuite.info/cs/TLS_RSA_WITH_AES_256_CBC_SHA/
34+
func GetWeakCipherSuites() []string {
35+
return getCipherWithLevel("Weak")
36+
}
37+
38+
// returns cipher with level
39+
func getCipherWithLevel(level ...string) []string {
40+
arr := []string{}
41+
for k, v := range CipherSecLevel {
42+
if stringsutil.EqualFoldAny(v, level...) {
43+
arr = append(arr, k)
44+
}
45+
}
46+
return arr
47+
}
48+
49+
func init() {
50+
err := json.Unmarshal([]byte(CipherDataBin), &CipherSecLevel)
51+
if err != nil {
52+
gologger.Error().Label("cipher").Msgf("failed to load cipherstatus_data.json, cipher-enum might return unexpected results: %v", err)
53+
}
54+
}

assets/cipherstatus_data.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

cmd/tlsx/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,23 @@ func readFlags() error {
8080
flagSet.BoolVarP(&options.ProbeStatus, "probe-status", "tps", false, "display tls probe status"),
8181
flagSet.BoolVarP(&options.TlsVersionsEnum, "version-enum", "ve", false, "enumerate and display supported tls versions"),
8282
flagSet.BoolVarP(&options.TlsCiphersEnum, "cipher-enum", "ce", false, "enumerate and display supported cipher"),
83+
flagSet.EnumVarP(&options.TLsCipherLevel, "cipher-type", "ct", goflags.EnumVariable(0), "ciphers types to enumerate (all/secure/insecure/weak)", goflags.AllowdTypes{
84+
"all": goflags.EnumVariable(clients.All),
85+
"weak": goflags.EnumVariable(clients.Weak),
86+
"insecure": goflags.EnumVariable(clients.Insecure),
87+
"secure": goflags.EnumVariable(clients.Secure),
88+
}),
8389
flagSet.BoolVarP(&options.ClientHello, "client-hello", "ch", false, "include client hello in json output (ztls mode only)"),
8490
flagSet.BoolVarP(&options.ServerHello, "server-hello", "sh", false, "include server hello in json output (ztls mode only)"),
91+
flagSet.BoolVarP(&options.Serial, "serial", "se", false, "display certificate serial number"),
8592
)
8693

8794
flagSet.CreateGroup("misconfigurations", "Misconfigurations",
8895
flagSet.BoolVarP(&options.Expired, "expired", "ex", false, "display host with host expired certificate"),
8996
flagSet.BoolVarP(&options.SelfSigned, "self-signed", "ss", false, "display host with self-signed certificate"),
9097
flagSet.BoolVarP(&options.MisMatched, "mismatched", "mm", false, "display host with mismatched certificate"),
9198
flagSet.BoolVarP(&options.Revoked, "revoked", "re", false, "display host with revoked certificate"),
99+
flagSet.BoolVarP(&options.Untrusted, "untrusted", "un", false, "display host with untrusted certificate"),
92100
)
93101

94102
flagSet.CreateGroup("configs", "Configurations",
@@ -98,9 +106,9 @@ func readFlags() error {
98106
flagSet.StringSliceVarP(&options.Ciphers, "cipher-input", "ci", nil, "ciphers to use with tls connection", goflags.FileCommaSeparatedStringSliceOptions),
99107
flagSet.StringSliceVar(&options.ServerName, "sni", nil, "tls sni hostname to use", goflags.FileCommaSeparatedStringSliceOptions),
100108
flagSet.BoolVarP(&options.RandomForEmptyServerName, "random-sni", "rs", false, "use random sni when empty"),
109+
flagSet.BoolVarP(&options.ReversePtrSNI, "rev-ptr-sni", "rps", false, "perform reverse PTR to retrieve SNI from IP"),
101110
flagSet.StringVar(&options.MinVersion, "min-version", "", "minimum tls version to accept (ssl30,tls10,tls11,tls12,tls13)"),
102111
flagSet.StringVar(&options.MaxVersion, "max-version", "", "maximum tls version to accept (ssl30,tls10,tls11,tls12,tls13)"),
103-
flagSet.BoolVarP(&options.AllCiphers, "all-ciphers", "ac", true, "send all ciphers as accepted inputs"),
104112
flagSet.BoolVarP(&options.Cert, "certificate", "cert", false, "include certificates in json output (PEM format)"),
105113
flagSet.BoolVarP(&options.TLSChain, "tls-chain", "tc", false, "include certificates chain in json output"),
106114
flagSet.BoolVarP(&options.VerifyServerCertificate, "verify-cert", "vc", false, "enable verification of server certificate"),
@@ -115,6 +123,11 @@ func readFlags() error {
115123
flagSet.StringVar(&options.Delay, "delay", "", "duration to wait between each connection per thread (eg: 200ms, 1s)"),
116124
)
117125

126+
flagSet.CreateGroup("update", "Update",
127+
flagSet.CallbackVarP(runner.GetUpdateCallback(), "update", "up", "update tlsx to latest version"),
128+
flagSet.BoolVarP(&options.DisableUpdateCheck, "disable-update-check", "duc", false, "disable automatic tlsx update check"),
129+
)
130+
118131
flagSet.CreateGroup("output", "Output",
119132
flagSet.StringVarP(&options.OutputFile, "output", "o", "", "file to write output to"),
120133
flagSet.BoolVarP(&options.JSON, "json", "j", false, "display json format output"),

0 commit comments

Comments
 (0)