SpoofDPI/spoof-dpi.go

68 lines
1.4 KiB
Go
Raw Normal View History

2021-12-27 07:43:03 +00:00
package main
import (
2021-12-27 08:29:17 +00:00
"SpoofDPI/mitm"
"SpoofDPI/util"
"fmt"
"log"
"net"
2021-12-27 07:43:03 +00:00
)
2021-12-27 08:29:17 +00:00
const (
CLI_PORT = "8080"
DNS_ADDR = "1.1.1.1"
)
2021-12-27 07:43:03 +00:00
func main() {
log.Println("##### Listening 8080..")
2021-12-27 08:29:17 +00:00
listener, err := net.Listen("tcp", ":" + CLI_PORT)
2021-12-27 07:43:03 +00:00
if err != nil {
panic(err)
}
2021-12-27 08:29:17 +00:00
2021-12-27 07:43:03 +00:00
for {
2021-12-27 08:29:17 +00:00
clientConn, err := listener.Accept()
2021-12-27 07:43:03 +00:00
if err != nil {
log.Println("error accepting connection", err)
continue
}
2021-12-27 08:29:17 +00:00
log.Println("##### New connection", clientConn.RemoteAddr())
go func() {
defer clientConn.Close()
buf, err := util.ReadBytes(clientConn)
if err != nil {
return
}
2021-12-27 07:43:03 +00:00
2021-12-27 08:29:17 +00:00
fmt.Println()
log.Println()
fmt.Println("##### Request from client : ")
fmt.Println(string(buf))
domain, port := util.ExtractDomainAndPort(string(buf))
log.Println("domain: "+ domain)
log.Println("port: " + port)
ip, err := util.DnsLookupOverHttps(DNS_ADDR, domain) // Dns lookup over https
if err != nil {
log.Fatal(err)
return
}
remoteConn, err := net.Dial("tcp", ip+":"+port) // create connection to server
if err != nil {
log.Fatal(err)
return
}
defer remoteConn.Close()
mitm.GoGoSing(clientConn, remoteConn, buf)
}()
2021-12-27 07:43:03 +00:00
}
}