Skip to content

Commit a462637

Browse files
support for multiple input with-cipher-type option (#318)
1 parent e3c1b80 commit a462637

File tree

10 files changed

+47
-35
lines changed

10 files changed

+47
-35
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
1616
cmd/tlsx/tlsx
17-
dist/*
17+
dist/*
18+
19+
.devcontainer

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,21 @@ SCAN-MODE:
7676
-iv, -ip-version string[] ip version to use (4, 6) (default 4)
7777

7878
PROBES:
79-
-san display subject alternative names
80-
-cn display subject common names
81-
-so display subject organization name
82-
-tv, -tls-version display used tls version
83-
-cipher display used cipher
84-
-hash string display certificate fingerprint hashes (md5,sha1,sha256)
85-
-jarm display jarm fingerprint hash
86-
-ja3 display ja3 fingerprint hash (using ztls)
87-
-wc, -wildcard-cert display host with wildcard ssl certificate
88-
-tps, -probe-status display tls probe status
89-
-ve, -version-enum enumerate and display supported tls versions
90-
-ce, -cipher-enum enumerate and display supported cipher
91-
-ct, -cipher-type ciphers types to enumerate (all/secure/insecure/weak) (default 0)
92-
-ch, -client-hello include client hello in json output (ztls mode only)
93-
-sh, -server-hello include server hello in json output (ztls mode only)
79+
-san display subject alternative names
80+
-cn display subject common names
81+
-so display subject organization name
82+
-tv, -tls-version display used tls version
83+
-cipher display used cipher
84+
-hash string display certificate fingerprint hashes (md5,sha1,sha256)
85+
-jarm display jarm fingerprint hash
86+
-ja3 display ja3 fingerprint hash (using ztls)
87+
-wc, -wildcard-cert display host with wildcard ssl certificate
88+
-tps, -probe-status display tls probe status
89+
-ve, -version-enum enumerate and display supported tls versions
90+
-ce, -cipher-enum enumerate and display supported cipher
91+
-ct, -cipher-type value ciphers types to enumerate. possible values: all/secure/insecure/weak (comma-separated) (default all)
92+
-ch, -client-hello include client hello in json output (ztls mode only)
93+
-sh, -server-hello include server hello in json output (ztls mode only)
9494
-se, -serial display certificate serial number
9595

9696
MISCONFIGURATIONS:

cmd/tlsx/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ 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{
83+
flagSet.EnumSliceVarP(&options.TLsCipherLevel, "cipher-type", "ct", []goflags.EnumVariable{goflags.EnumVariable(0)}, "ciphers types to enumerate. possible values: all/secure/insecure/weak (comma-separated)", goflags.AllowdTypes{
8484
"all": goflags.EnumVariable(clients.All),
8585
"weak": goflags.EnumVariable(clients.Weak),
8686
"insecure": goflags.EnumVariable(clients.Insecure),

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/miekg/dns v1.1.55
1111
github.com/projectdiscovery/dnsx v1.1.4
1212
github.com/projectdiscovery/fastdialer v0.0.35
13-
github.com/projectdiscovery/goflags v0.1.12
13+
github.com/projectdiscovery/goflags v0.1.13
1414
github.com/projectdiscovery/gologger v1.1.11
1515
github.com/projectdiscovery/mapcidr v1.1.2
1616
github.com/projectdiscovery/utils v0.0.47

go.sum

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdf
4949
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
5050
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
5151
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
52+
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
5253
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
5354
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
5455
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
@@ -97,6 +98,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
9798
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
9899
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
99100
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
101+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
100102
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
101103
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
102104
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
@@ -135,6 +137,7 @@ github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4AN
135137
github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc=
136138
github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
137139
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
140+
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
138141
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
139142
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
140143
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -159,8 +162,8 @@ github.com/projectdiscovery/dnsx v1.1.4 h1:hdvIPU8W1rwNAi6sjjN1rCtCVOhS1/cM3OgmO
159162
github.com/projectdiscovery/dnsx v1.1.4/go.mod h1:wYz+2E97h0j25FLiqpUJyVY6NW7cEDODyUAsIoXsDsA=
160163
github.com/projectdiscovery/fastdialer v0.0.35 h1:dCjYaZ2dOtKmIbQ7OUuf/pZiMQRHfUjjLoHrEF8CJ8g=
161164
github.com/projectdiscovery/fastdialer v0.0.35/go.mod h1:dTx0C7JRWKKO5ZxGqM0NUDzB4svmyYqGM6zcHIk2ueo=
162-
github.com/projectdiscovery/goflags v0.1.12 h1:NucjSqw7reczmon2vQq9KyOrvOmlnznECeifHI2gOW0=
163-
github.com/projectdiscovery/goflags v0.1.12/go.mod h1:wC5uJonjddDcCqDNfPq+03nRessSB/LLaaIea4w47ws=
165+
github.com/projectdiscovery/goflags v0.1.13 h1:Kcnfw++BNjSPugEscuZ0RdRd6Iwf3cWXhNY9AB0ptHI=
166+
github.com/projectdiscovery/goflags v0.1.13/go.mod h1:wC5uJonjddDcCqDNfPq+03nRessSB/LLaaIea4w47ws=
164167
github.com/projectdiscovery/gologger v1.1.11 h1:8vsz9oJlDT9euw6xlj7F7dZ6RWItVIqVwn4Mr6uzky8=
165168
github.com/projectdiscovery/gologger v1.1.11/go.mod h1:UR2bgXl7zraOxYGnUwuO917hifWrwMJ0feKnVqMQkzY=
166169
github.com/projectdiscovery/hmap v0.0.13 h1:8v5j99Pz0S7V1YrTeWp7xtr1yNOffKQ/KusHZfB+mrI=
@@ -190,6 +193,7 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
190193
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
191194
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
192195
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
196+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
193197
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
194198
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
195199
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
@@ -249,6 +253,7 @@ github.com/zmap/zcrypto v0.0.0-20230422215203-9a665e1e9968/go.mod h1:xIuOvYCZX21
249253
github.com/zmap/zlint/v3 v3.0.0/go.mod h1:paGwFySdHIBEMJ61YjoqT4h7Ge+fdYG4sUQhnTb1lJ8=
250254
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
251255
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
256+
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
252257
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
253258
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
254259
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -363,6 +368,7 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
363368
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
364369
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
365370
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
371+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
366372
gopkg.in/djherbis/times.v1 v1.3.0 h1:uxMS4iMtH6Pwsxog094W0FYldiNnfY/xba00vq6C2+o=
367373
gopkg.in/djherbis/times.v1 v1.3.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8=
368374
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
@@ -371,6 +377,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
371377
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
372378
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
373379
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
380+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
374381
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
375382
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
376383
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

pkg/tlsx/clients/clients.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type Options struct {
144144
// TlsCiphersEnum enumerates supported ciphers per TLS protocol
145145
TlsCiphersEnum bool
146146
// TLSCipherSecLevel
147-
TLsCipherLevel string
147+
TLsCipherLevel []string
148148
// ClientHello include client hello (only ztls)
149149
ClientHello bool
150150
// ServerHello include server hello (only ztls)
@@ -471,8 +471,8 @@ type ConnectOptions struct {
471471
SNI string
472472
VersionTLS string
473473
Ciphers []string
474-
CipherLevel CipherSecLevel // Only used in cipher enum mode
475-
EnumMode EnumMode // Enumeration Mode (version or ciphers)
474+
CipherLevel []CipherSecLevel // Only used in cipher enum mode
475+
EnumMode EnumMode // Enumeration Mode (version or ciphers)
476476
}
477477

478478
// ParseASN1DNSequenceWithZpkixOrDefault return the parsed value of ASN1DNSequence or a default string value

pkg/tlsx/openssl/openssl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (c *Client) ConnectWithOptions(hostname, ip, port string, options clients.C
104104
// EnumerateCiphers enumerates all supported ciphers of openssl on target
105105
func (c *Client) EnumerateCiphers(hostname, ip, port string, options clients.ConnectOptions) ([]string, error) {
106106
// filter ciphers based on given seclevel
107-
toEnumerate := clients.GetCiphersWithLevel(AllCiphersNames, options.CipherLevel)
107+
toEnumerate := clients.GetCiphersWithLevel(AllCiphersNames, options.CipherLevel...)
108108

109109
enumeratedCiphers := []string{}
110110

pkg/tlsx/tls/tls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (c *Client) ConnectWithOptions(hostname, ip, port string, options clients.C
164164

165165
func (c *Client) EnumerateCiphers(hostname, ip, port string, options clients.ConnectOptions) ([]string, error) {
166166
// filter ciphers based on given seclevel
167-
toEnumerate := clients.GetCiphersWithLevel(AllCiphersNames, options.CipherLevel)
167+
toEnumerate := clients.GetCiphersWithLevel(AllCiphersNames, options.CipherLevel...)
168168

169169
if options.VersionTLS == "tls13" {
170170
return nil, errorutil.NewWithTag("ctls", "cipher enum not supported in ctls with tls1.3")

pkg/tlsx/tlsx.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,18 @@ func (s *Service) enumTlsVersions(host, ip, port string, options clients.Connect
147147

148148
func (s *Service) enumTlsCiphers(host, ip, port string, options clients.ConnectOptions) ([]string, error) {
149149
options.EnumMode = clients.Cipher
150-
switch s.options.TLsCipherLevel {
151-
case "weak":
152-
options.CipherLevel = clients.Weak
153-
case "secure":
154-
options.CipherLevel = clients.Secure
155-
case "insecure":
156-
options.CipherLevel = clients.Insecure
157-
default:
158-
options.CipherLevel = clients.All
150+
for _, cipher := range s.options.TLsCipherLevel {
151+
152+
switch cipher {
153+
case "weak":
154+
options.CipherLevel = append(options.CipherLevel, clients.Weak)
155+
case "secure":
156+
options.CipherLevel = append(options.CipherLevel, clients.Secure)
157+
case "insecure":
158+
options.CipherLevel = append(options.CipherLevel, clients.Insecure)
159+
default:
160+
options.CipherLevel = append(options.CipherLevel, clients.All)
161+
}
159162
}
160163
return s.client.EnumerateCiphers(host, ip, port, options)
161164
}

pkg/tlsx/ztls/ztls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (c *Client) ConnectWithOptions(hostname, ip, port string, options clients.C
183183
// EnumerateCiphers enumerate target with ciphers supported by ztls
184184
func (c *Client) EnumerateCiphers(hostname, ip, port string, options clients.ConnectOptions) ([]string, error) {
185185
// filter ciphers based on given seclevel
186-
toEnumerate := clients.GetCiphersWithLevel(AllCiphersNames, options.CipherLevel)
186+
toEnumerate := clients.GetCiphersWithLevel(AllCiphersNames, options.CipherLevel...)
187187

188188
enumeratedCiphers := []string{}
189189

0 commit comments

Comments
 (0)