-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7299572
commit b17777d
Showing
5 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os" | ||
"os/signal" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/v-byte-cpu/sx/pkg/scan/tcp" | ||
) | ||
|
||
func init() { | ||
tcpCmd.AddCommand(tcpnullCmd) | ||
} | ||
|
||
var tcpnullCmd = &cobra.Command{ | ||
Use: "null [flags] subnet", | ||
Example: strings.Join([]string{"tcp null -p 22 192.168.0.1/24", "tcp null -p 22-4567 10.0.0.1"}, "\n"), | ||
Short: "Perform TCP NULL scan", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
return errors.New("requires one ip subnet argument") | ||
} | ||
return nil | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
var conf *scanConfig | ||
if conf, err = parseScanConfig(tcp.NULLScanType, args[0], portsFlag); err != nil { | ||
return | ||
} | ||
|
||
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) | ||
defer cancel() | ||
|
||
m := newTCPScanMethod(ctx, conf, | ||
withTCPScanName(tcp.NULLScanType), | ||
withTCPPacketFiller(tcp.NewPacketFiller()), | ||
withTCPPacketFilterFunc(tcp.TrueFilter), | ||
withTCPPacketFlags(tcp.AllFlags), | ||
) | ||
|
||
return startEngine(ctx, &engineConfig{ | ||
logger: conf.logger, | ||
scanRange: conf.scanRange, | ||
scanMethod: m, | ||
bpfFilter: tcp.BPFFilter, | ||
}) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters