-
Notifications
You must be signed in to change notification settings - Fork 0
/
shecan.go
42 lines (40 loc) · 956 Bytes
/
shecan.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
package main
import (
"fmt"
"log"
"net"
"os/exec"
"shecan-cli/dns"
"time"
)
func main(){
var snumber int
interfaces,err := net.Interfaces()
interfaces_slice := []string{}
if err != nil {
fmt.Println(err)
}
for i,o := range interfaces {
fmt.Printf("%d -> %s\n",i+1,o.Name)
interfaces_slice = append(interfaces_slice, o.Name)
}
fmt.Print("Select interface : ");fmt.Scanln(&snumber)
if snumber > len(interfaces_slice) {
log.Fatal("Not in range!")
}
//Clear dns servers
cc := exec.Command("wmic","nicconfig","where","(IPEnabled=TRUE)","call","SetDNSServerSearchOrder","()")
cc.Output()
//Set dns servers
for _,i := range dns.GetDns() {
network := `"` + interfaces_slice[snumber-1] + `"`
cmd := exec.Command("netsh","interface","ip", "add","dns",network,i,"INDEX=2")
_,err := cmd.Output()
if err != nil {
fmt.Println(err)
time.Sleep(60 * time.Second)
}
}
fmt.Println("\n\nDone!")
time.Sleep(60 * time.Second)
}