Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
zgrab: log target address/port on panic (#305)
Browse files Browse the repository at this point in the history
* Catch panics in GrabBanner and log the target before bubbling the panic back out to the caller
  • Loading branch information
justinbastress committed Feb 20, 2018
1 parent bcbf9fc commit 4d61f56
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions zlib/grabber.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,18 @@ func makeXSSHGrabber(gblConfig *Config, grabData GrabData) func(string) error {
}

func GrabBanner(config *Config, target *GrabTarget) *Grab {
defer func() {
if e := recover(); e != nil {
addr := "<not set>"
if target.Addr != nil {
addr = target.Addr.String()
}
config.ErrorLog.Errorf("Panic when scanning addr = %s / domain = %s, port %d", addr, target.Domain, config.Port)
// Bubble out original error (with original stack) in lieu of explicitly logging the stack / error
panic(e)
}
}()

if config.XSSH.XSSH {
t := time.Now()

Expand Down

0 comments on commit 4d61f56

Please sign in to comment.