Cablej master (#232)
* Add support to HTTP for setting local interface * Add net import * use correct flag * better CLI flag name * Remove logged `\n` * Remove extranneous if statement
This commit is contained in:
parent
dd478522e9
commit
4c1161b29e
12
config.go
12
config.go
@ -1,6 +1,7 @@
|
|||||||
package zgrab2
|
package zgrab2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -16,7 +17,7 @@ type Config struct {
|
|||||||
InputFileName string `short:"f" long:"input-file" default:"-" description:"Input filename, use - for stdin"`
|
InputFileName string `short:"f" long:"input-file" default:"-" description:"Input filename, use - for stdin"`
|
||||||
MetaFileName string `short:"m" long:"metadata-file" default:"-" description:"Metadata filename, use - for stderr"`
|
MetaFileName string `short:"m" long:"metadata-file" default:"-" description:"Metadata filename, use - for stderr"`
|
||||||
LogFileName string `short:"l" long:"log-file" default:"-" description:"Log filename, use - for stderr"`
|
LogFileName string `short:"l" long:"log-file" default:"-" description:"Log filename, use - for stderr"`
|
||||||
Interface string `short:"i" long:"interface" description:"Network interface to send on"`
|
LocalAddress string `long:"source-ip" description:"Local source IP address to use for making connections"`
|
||||||
Senders int `short:"s" long:"senders" default:"1000" description:"Number of send goroutines to use"`
|
Senders int `short:"s" long:"senders" default:"1000" description:"Number of send goroutines to use"`
|
||||||
Debug bool `long:"debug" description:"Include debug fields in the output."`
|
Debug bool `long:"debug" description:"Include debug fields in the output."`
|
||||||
GOMAXPROCS int `long:"gomaxprocs" default:"0" description:"Set GOMAXPROCS"`
|
GOMAXPROCS int `long:"gomaxprocs" default:"0" description:"Set GOMAXPROCS"`
|
||||||
@ -30,6 +31,7 @@ type Config struct {
|
|||||||
logFile *os.File
|
logFile *os.File
|
||||||
inputTargets InputTargetsFunc
|
inputTargets InputTargetsFunc
|
||||||
outputResults OutputResultsFunc
|
outputResults OutputResultsFunc
|
||||||
|
localAddr *net.TCPAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetInputFunc sets the target input function to the provided function.
|
// SetInputFunc sets the target input function to the provided function.
|
||||||
@ -61,6 +63,14 @@ func validateFrameworkConfiguration() {
|
|||||||
}
|
}
|
||||||
SetInputFunc(InputTargetsCSV)
|
SetInputFunc(InputTargetsCSV)
|
||||||
|
|
||||||
|
if config.LocalAddress != "" {
|
||||||
|
parsed := net.ParseIP(config.LocalAddress)
|
||||||
|
if parsed == nil {
|
||||||
|
log.Fatalf("Error parsing local interface %s as IP", config.LocalAddress)
|
||||||
|
}
|
||||||
|
config.localAddr = &net.TCPAddr{parsed, 0, ""}
|
||||||
|
}
|
||||||
|
|
||||||
if config.InputFileName == "-" {
|
if config.InputFileName == "-" {
|
||||||
config.inputFile = os.Stdin
|
config.inputFile = os.Stdin
|
||||||
} else {
|
} else {
|
||||||
|
4
conn.go
4
conn.go
@ -298,6 +298,10 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.
|
|||||||
// ensure that our aux dialer is up-to-date; copied from http/transport.go
|
// ensure that our aux dialer is up-to-date; copied from http/transport.go
|
||||||
d.Dialer.Timeout = d.getTimeout(d.ConnectTimeout)
|
d.Dialer.Timeout = d.getTimeout(d.ConnectTimeout)
|
||||||
d.Dialer.KeepAlive = d.Timeout
|
d.Dialer.KeepAlive = d.Timeout
|
||||||
|
|
||||||
|
// Copy over the source IP if set, or nil
|
||||||
|
d.Dialer.LocalAddr = config.localAddr
|
||||||
|
|
||||||
dialContext, cancelDial := context.WithTimeout(ctx, d.Dialer.Timeout)
|
dialContext, cancelDial := context.WithTimeout(ctx, d.Dialer.Timeout)
|
||||||
defer cancelDial()
|
defer cancelDial()
|
||||||
conn, err := d.Dialer.DialContext(dialContext, network, address)
|
conn, err := d.Dialer.DialContext(dialContext, network, address)
|
||||||
|
2
go.mod
2
go.mod
@ -3,8 +3,6 @@ module github.com/zmap/zgrab2
|
|||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
|
||||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
|
||||||
github.com/prometheus/client_golang v1.1.0
|
github.com/prometheus/client_golang v1.1.0
|
||||||
github.com/sirupsen/logrus v1.4.2
|
github.com/sirupsen/logrus v1.4.2
|
||||||
github.com/zmap/zcrypto v0.0.0-20190729165852-9051775e6a2e
|
github.com/zmap/zcrypto v0.0.0-20190729165852-9051775e6a2e
|
||||||
|
Loading…
Reference in New Issue
Block a user