go fmt duh

This commit is contained in:
Jeffrey Paul 2018-08-25 12:07:33 -07:00
parent 5f3046319c
commit 596a551aa5
1 changed files with 36 additions and 36 deletions

View File

@ -6,9 +6,9 @@ package main
import (
"flag"
"fmt"
"os"
"github.com/akrennmair/gopcap"
"github.com/op/go-logging"
"github.com/op/go-logging"
"os"
)
var log = logging.MustGetLogger("gpk")
@ -28,15 +28,15 @@ const (
// it is dumb that go doesn't let me define additional methods
// on the external package, now these have to be plain funcs
func isRST(tcp *pcap.Tcphdr) bool {
return (tcp.Flags & TCP_RST) != 0
return (tcp.Flags & TCP_RST) != 0
}
func isACK(tcp *pcap.Tcphdr) bool {
return (tcp.Flags & TCP_ACK) != 0
return (tcp.Flags & TCP_ACK) != 0
}
func isFIN(tcp *pcap.Tcphdr) bool {
return (tcp.Flags & TCP_FIN) != 0
return (tcp.Flags & TCP_FIN) != 0
}
func min(x uint32, y uint32) uint32 {
@ -47,8 +47,8 @@ func min(x uint32, y uint32) uint32 {
}
func usage() {
fmt.Printf("usage: gopakketo [-d <device> | -r <file>]\n")
os.Exit(0)
fmt.Printf("usage: gopakketo [-d <device> | -r <file>]\n")
os.Exit(0)
}
var logFormat = logging.MustStringFormatter(
@ -58,40 +58,40 @@ var logFormat = logging.MustStringFormatter(
func main() {
loggingBackend := logging.NewLogBackend(os.Stderr, "", 0)
backendFormatter := logging.NewBackendFormatter(loggingBackend, logFormat)
logging.SetBackend(backendFormatter)
backendFormatter := logging.NewBackendFormatter(loggingBackend, logFormat)
logging.SetBackend(backendFormatter)
var device *string = flag.String("d", "", "device")
var targetlist *string = flag.String("t", "", "target list e.g. 192.168.0.0/16 or 192.168.0-255.0-255")
var portlist *string = flag.String("p", "", "port list e.g. 0-1024 or 22,23,80 or 0-1024,6667")
//var outfile *string = flag.String("o", "", "output file")
//var expr *string = flag.String("e", "", "filter expression")
//var expr *string = flag.String("e", "", "filter expression")
flag.Parse()
go send(device, targetlist, portlist);
receive(device);
go send(device, targetlist, portlist)
receive(device)
}
func parsePortList (pl *[]uint16, s *string) {
func parsePortList(pl *[]uint16, s *string) {
}
func parseTargetList (tl *[]uint32, s *string) {
func parseTargetList(tl *[]uint32, s *string) {
}
func send(device *string, targetlist *string, portlist *string) {
pl := make([]uint16, 0)
parsePortList(pl, portlist)
pl := make([]uint16, 0)
parsePortList(pl, portlist)
tl := make([]uint32, 0)
parseTargetList(tl, targetlist)
tl := make([]uint32, 0)
parseTargetList(tl, targetlist)
}
func sendSyn (device *string, sport uint16, dst uint32, dport uint16) {
func sendSyn(device *string, sport uint16, dst uint32, dport uint16) {
}
@ -104,7 +104,7 @@ func receive(device *string) {
panic(fmt.Sprintf("no interfaces found : %s\n", err))
}
if *device != "" {
if *device != "" {
pc, err = pcap.Openlive(*device, 65535, true, 0)
if pc == nil {
log.Noticef("Openlive(%s) failed: %s\n", *device, err)
@ -113,9 +113,9 @@ func receive(device *string) {
if err != nil {
log.Criticalf("Openlive(%s) failed: %s\n", *device, err)
return
}
}
} else {
usage()
usage()
return
}
defer pc.Close()
@ -123,22 +123,22 @@ func receive(device *string) {
log.Infof("pcap version: %s\n", pcap.Version())
for pkt := pc.Next(); pkt != nil; pkt = pc.Next() {
pkt.Decode()
if pkt.TCP == nil {
// we are only interested in TCP for scanning purposes rn
continue
}
pkt.Decode()
if pkt.TCP == nil {
// we are only interested in TCP for scanning purposes rn
continue
}
if !isRST(pkt.TCP) && !isACK(pkt.TCP) {
// for scanning we only want RSTs (closed) and ACKs (open)
continue
}
if !isRST(pkt.TCP) && !isACK(pkt.TCP) {
// for scanning we only want RSTs (closed) and ACKs (open)
continue
}
if isACK(pkt.TCP) {
if isFIN(pkt.TCP) {
continue
}
}
if isACK(pkt.TCP) {
if isFIN(pkt.TCP) {
continue
}
}
fmt.Printf("%s\n", pkt.String())
}