This repository was archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathmodule.go
More file actions
87 lines (66 loc) · 2.51 KB
/
Copy pathmodule.go
File metadata and controls
87 lines (66 loc) · 2.51 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package module
import (
"crypto/tls"
"encoding/hex"
"github.com/praetorian-inc/trudy/pipe"
"net"
)
//Data is a thin wrapper that provides metadata that may be useful when mangling bytes on the network.
type Data struct {
FromClient bool //FromClient is true is the data sent is coming from the client (the device you are proxying)
Bytes []byte //Bytes is a byte slice that contians the TCP data
TLSConfig *tls.Config //TLSConfig is a TLS server config that contains Trudy's TLS server certficiate.
ServerAddr net.Addr //ServerAddr is net.Addr of the server
ClientAddr net.Addr //ClientAddr is the net.Addr of the client (the device you are proxying)
}
//DoMangle will return true if Data needs to be sent to the Mangle function.
func (input Data) DoMangle() bool {
return true
}
//Mangle can modify/replace the Bytes values within the Data struct. This can
//be empty if no programmatic mangling needs to be done.
func (input *Data) Mangle() {
}
//Drop will return true if the Data needs to be dropped before going through
//the pipe.
func (input Data) Drop() bool {
return false
}
//PrettyPrint returns the string representation of the data. This string will
//be the value that is logged to the console.
func (input Data) PrettyPrint() string {
return hex.Dump(input.Bytes)
}
//DoPrint will return true if the PrettyPrinted version of the Data struct
//needs to be logged to the console.
func (input Data) DoPrint() bool {
return true
}
//DoIntercept returns true if data should be sent to the Trudy interceptor.
func (input Data) DoIntercept() bool {
return false
}
//Deserialize should replace the Data struct's Bytes with a deserialized bytes.
//For example, unpacking a HTTP/2 frame would be deserialization.
func (input *Data) Deserialize() {
}
//Serialize should replace the Data struct's Bytes with the serialized form of
//the bytes. The serialized bytes will be sent over the wire.
func (input *Data) Serialize() {
}
//BeforeWriteToClient is a function that will be called before data is sent to
//a client.
func (input *Data) BeforeWriteToClient(p pipe.Pipe) {
}
//AfterWriteToClient is a function that will be called after data is sent to
//a client.
func (input *Data) AfterWriteToClient(p pipe.Pipe) {
}
//BeforeWriteToServer is a function that will be called before data is sent to
//a server.
func (input *Data) BeforeWriteToServer(p pipe.Pipe) {
}
//AfterWriteToServer is a function that will be called after data is sent to
//a server.
func (input *Data) AfterWriteToServer(p pipe.Pipe) {
}