@@ -34,6 +34,7 @@ type Config struct {
3434 ClientCertFile string `json:"ClientCertFile"` // client cert for mTLS
3535 ClientKeyFile string `json:"ClientKeyFile"` // client priv key for mTLS
3636 ListenerMTLS bool `json:"ListenerMTLS"` // use the ClientKeyFile to set mTLS on the listener
37+ RichRaw bool `json:"RichRaw"`
3738 IPS []string // IPAddress for the child cert
3839 Names []string // DNSNames for the child cert
3940 Raw bool `json:"Raw"`
@@ -149,7 +150,11 @@ func dumpData(r io.Reader, source string, id int) {
149150 // doing this is using hex.Dumper(fw) is slightly faster than
150151 // using `fw.WriteString(hex.Dump(data[:n]))`
151152 // even though the code is debatable uglier
152- outDumper .Write (data [:n ])
153+ if config .RichRaw { // don't hex dump, this is basically enriched raw
154+ fw .Write (data [:n ])
155+ } else {
156+ outDumper .Write (data [:n ])
157+ }
153158 fw .WriteByte ('\n' )
154159 fw .Flush ()
155160 } else {
@@ -327,7 +332,7 @@ func startListener(isTLS bool) {
327332 }
328333}
329334
330- func setConfig (configFile string , localPort int , localHost , remoteHost string , caCertFile , caKeyFile string , clientCertFile , clientKeyFile , outFile string , listenerMTLS bool ) {
335+ func setConfig (configFile string , localPort int , localHost , remoteHost string , caCertFile , caKeyFile string , clientCertFile , clientKeyFile , outFile string ) {
331336 if configFile != "" {
332337 data , err := os .ReadFile (configFile )
333338 if err != nil {
@@ -351,10 +356,6 @@ func setConfig(configFile string, localPort int, localHost, remoteHost string, c
351356 if clientCertFile != "" {
352357 config .ClientCertFile = clientCertFile
353358 config .ClientKeyFile = clientKeyFile
354- config .ListenerMTLS = listenerMTLS
355- } else if listenerMTLS {
356- fmt .Println ("[-] ClientCertFile must be set when using listener mTLS" )
357- os .Exit (1 )
358359 }
359360
360361 if localPort != 0 {
@@ -385,6 +386,7 @@ func main() {
385386 clientKeyPtr := flag .String ("clientKey" , "" , "A public client key to use for mTLS" )
386387 quietPtr := flag .Bool ("q" , false , "Hide app messages and just show the data stream" )
387388 rawPtr := flag .Bool ("raw" , false , "Don't use hex.dump to pretty format output" )
389+ richRawPtr := flag .Bool ("richraw" , false , "Slightly enrich the raw output, don't use hex.dump to pretty format output" )
388390 outFilePtr := flag .String ("o" , "" , "Write output to file" )
389391
390392 flag .Parse ()
@@ -399,10 +401,21 @@ func main() {
399401 os .Exit (1 )
400402 }
401403
402- setConfig (* configPtr , * localPort , * localHost , * remoteHostPtr , * caCertFilePtr , * caKeyFilePtr , * clientCertPtr , * clientKeyPtr , * outFilePtr , * listenerMTLSPtr )
404+ setConfig (* configPtr , * localPort , * localHost , * remoteHostPtr , * caCertFilePtr , * caKeyFilePtr , * clientCertPtr , * clientKeyPtr , * outFilePtr )
403405
406+ config .ListenerMTLS = * listenerMTLSPtr
407+ if config .ListenerMTLS {
408+ fmt .Println ("[-] ClientCertFile must be set when using listener mTLS" )
409+ os .Exit (1 )
410+ }
404411 config .Quiet = * quietPtr
405412 config .Raw = * rawPtr
413+ config .RichRaw = * richRawPtr
414+
415+ if config .Raw && config .RichRaw {
416+ fmt .Println ("[-] Conflicting configuration, -raw and -richraw can't be used together." )
417+ os .Exit (1 )
418+ }
406419
407420 if config .Raw && config .ToFile == "" {
408421 fmt .Println ("[-] Raw mode specified but no output file supplied. There won't be any output!" )
0 commit comments