-
Notifications
You must be signed in to change notification settings - Fork 110
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
31534cb
commit dee9a6e
Showing
3 changed files
with
53 additions
and
1 deletion.
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
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(tcpxmasCmd) | ||
} | ||
|
||
var tcpxmasCmd = &cobra.Command{ | ||
Use: "xmas [flags] subnet", | ||
Example: strings.Join([]string{"tcp xmas -p 22 192.168.0.1/24", "tcp xmas -p 22-4567 10.0.0.1"}, "\n"), | ||
Short: "Perform TCP Xmas 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.XmasScanType, args[0], portsFlag); err != nil { | ||
return | ||
} | ||
|
||
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) | ||
defer cancel() | ||
|
||
m := newTCPScanMethod(ctx, conf, | ||
withTCPScanName(tcp.XmasScanType), | ||
withTCPPacketFiller(tcp.NewPacketFiller(tcp.WithFIN(), tcp.WithPSH(), tcp.WithURG())), | ||
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