Skip to content

Commit

Permalink
TCP Xmas scan
Browse files Browse the repository at this point in the history
  • Loading branch information
v-byte-cpu committed Mar 22, 2021
1 parent 31534cb commit dee9a6e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The goal of this project is to create the fastest network scanner with clean and
Features:
* ARP scan
* TCP SYN scan
* TCP FIN / NULL scans
* TCP FIN / NULL / Xmas scans

## Building

Expand Down
51 changes: 51 additions & 0 deletions command/tcp_xmas.go
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,
})
},
}
1 change: 1 addition & 0 deletions pkg/scan/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
SYNScanType = "tcpsyn"
FINScanType = "tcpfin"
NULLScanType = "tcpnull"
XmasScanType = "tcpxmas"
)

//easyjson:json
Expand Down

0 comments on commit dee9a6e

Please sign in to comment.