Skip to content

Commit

Permalink
Fix direction of DNS response
Browse files Browse the repository at this point in the history
  • Loading branch information
macronut committed Aug 6, 2022
1 parent a786f7e commit 60f055b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/Macronut/TCPioneer
module github.com/macronut/ghostcp

go 1.16

Expand Down
2 changes: 1 addition & 1 deletion header/dns.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tcpioneer
package ghostcp

import (
"encoding/binary"
Expand Down
2 changes: 1 addition & 1 deletion header/ghostcp.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tcpioneer
package ghostcp

import (
"bufio"
Expand Down
2 changes: 1 addition & 1 deletion header/scan.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tcpioneer
package ghostcp

import (
"crypto/tls"
Expand Down
2 changes: 1 addition & 1 deletion header/socks.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tcpioneer
package ghostcp

import (
"encoding/binary"
Expand Down
2 changes: 1 addition & 1 deletion header/tcp.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tcpioneer
package ghostcp

import (
"bytes"
Expand Down
4 changes: 3 additions & 1 deletion header/udp.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tcpioneer
package ghostcp

import (
"encoding/binary"
Expand Down Expand Up @@ -75,6 +75,8 @@ func DNSDaemon() {
anCount = config.ANCount6
}

packet.Addr.Data = 0x1

if anCount == 0 {
request := packet.Raw[ipheadlen+udpheadlen:]
udpsize := len(request) + 8
Expand Down
56 changes: 28 additions & 28 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"path/filepath"
"runtime"

"github.com/Macronut/TCPioneer/header"
"github.com/chai2010/winsvc"
"github.com/macronut/ghostcp/header"
)

var ServiceMode bool = true
Expand All @@ -23,68 +23,68 @@ func StartService() {
runtime.GOMAXPROCS(1)
log.SetFlags(log.LstdFlags | log.Lshortfile)

if tcpioneer.LogLevel > 0 {
var logFilename string = "tcpioneer.log"
if ghostcp.LogLevel > 0 {
var logFilename string = "ghostcp.log"
logFile, err := os.OpenFile(logFilename, os.O_RDWR|os.O_CREATE, 0777)
if err != nil {
log.Println(err)
return
}
defer logFile.Close()

tcpioneer.Logger = log.New(logFile, "\r\n", log.Ldate|log.Ltime|log.Lshortfile)
ghostcp.Logger = log.New(logFile, "\r\n", log.Ldate|log.Ltime|log.Lshortfile)
}

err := tcpioneer.LoadConfig()
err := ghostcp.LoadConfig()
if err != nil {
if tcpioneer.LogLevel > 0 || !ServiceMode {
if ghostcp.LogLevel > 0 || !ServiceMode {
log.Println(err)
}
return
}

Windir := os.Getenv("WINDIR")
err = tcpioneer.LoadHosts(Windir + "\\System32\\drivers\\etc\\hosts")
err = ghostcp.LoadHosts(Windir + "\\System32\\drivers\\etc\\hosts")
if err != nil && !ServiceMode {
log.Println(err)
return
}

if tcpioneer.LogLevel == 0 && !ServiceMode {
tcpioneer.LogLevel = 1
if ghostcp.LogLevel == 0 && !ServiceMode {
ghostcp.LogLevel = 1
}

if ScanIPRange != "" {
tcpioneer.DetectEnable = true
tcpioneer.ScanURL = ScanURL
tcpioneer.ScanTimeout = ScanTimeout
ghostcp.DetectEnable = true
ghostcp.ScanURL = ScanURL
ghostcp.ScanTimeout = ScanTimeout
}

tcpioneer.TCPDaemon(":443", false)
tcpioneer.TCPDaemon(":80", false)
tcpioneer.UDPDaemon(443, false)
tcpioneer.TCPRecv(443, false)
ghostcp.TCPDaemon(":443", false)
ghostcp.TCPDaemon(":80", false)
ghostcp.UDPDaemon(443, false)
ghostcp.TCPRecv(443, false)

if tcpioneer.Forward {
tcpioneer.TCPDaemon(":443", true)
tcpioneer.TCPDaemon(":80", true)
tcpioneer.UDPDaemon(443, true)
tcpioneer.TCPRecv(443, true)
if ghostcp.Forward {
ghostcp.TCPDaemon(":443", true)
ghostcp.TCPDaemon(":80", true)
ghostcp.UDPDaemon(443, true)
ghostcp.TCPRecv(443, true)
}

if tcpioneer.DNS == "" {
tcpioneer.DNSRecvDaemon()
if ghostcp.DNS == "" {
ghostcp.DNSRecvDaemon()
} else {
tcpioneer.TCPDaemon(tcpioneer.DNS, false)
tcpioneer.DNSDaemon()
ghostcp.TCPDaemon(ghostcp.DNS, false)
ghostcp.DNSDaemon()
}

if ScanIPRange != "" {
go tcpioneer.Scan(ScanIPRange, ScanSpeed)
go ghostcp.Scan(ScanIPRange, ScanSpeed)
}

fmt.Println("Service Start")
tcpioneer.Wait()
ghostcp.Wait()
}

func StopService() {
Expand All @@ -99,7 +99,7 @@ func StopService() {
}

func main() {
serviceName := "TCPPioneer"
serviceName := "GhosTCP"
var flagServiceInstall bool
var flagServiceUninstall bool
var flagServiceStart bool
Expand Down

0 comments on commit 60f055b

Please sign in to comment.