diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64709ff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +up-six.sh diff --git a/down-six.sh b/down-six.sh new file mode 100644 index 0000000..fda174e --- /dev/null +++ b/down-six.sh @@ -0,0 +1 @@ +ip link del he-ipv6 diff --git a/main.go b/main.go new file mode 100644 index 0000000..ec4080c --- /dev/null +++ b/main.go @@ -0,0 +1,65 @@ +package main + +import ( + "fmt" + "log" + "os/exec" + "io/ioutil" + "strings" + "math/rand" + "time" +) + +const ( + upFile = "up-six.sh" + downFile = "down-six.sh" + repeatTimer = 120 +) + +func main() { + for true { + fileToExec(downFile) + fileToExec(upFile) + time.Sleep(repeatTimer * time.Second) + } +} + +func fileToExec(filename string) { + doCmds := fileToCmd(filename) + for _, currCmd := range doCmds { + actualCmd := "" + if strings.Count(currCmd, "%x") == 1 { + actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536) + } else if strings.Count(currCmd, "%x") == 2 { + actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536) + } else if strings.Count(currCmd, "%x") == 3 { + actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536) + } else if strings.Count(currCmd, "%x") == 4 { + actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536) + } else if strings.Count(currCmd, "%x") == 5 { + actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536) + } else { + actualCmd = currCmd + } + executeCmd(actualCmd) + } +} + +func fileToCmd(filename string) []string { + fileBody, err := ioutil.ReadFile(filename) + if err != nil { + log.Printf("Error while reading file %s\n", filename) + return []string{} + } + cmdArr := strings.Split(string(fileBody), "\n") + return cmdArr +} + +func executeCmd(cmdStr string) { + cmd := exec.Command("bash", "-c", cmdStr) + log.Println(cmdStr) + err := cmd.Run() + if err != nil { + log.Println(err) + } +} diff --git a/sixes-to-fours b/sixes-to-fours new file mode 100755 index 0000000..7175a99 Binary files /dev/null and b/sixes-to-fours differ diff --git a/up-six.sh.example b/up-six.sh.example new file mode 100644 index 0000000..b2a1840 --- /dev/null +++ b/up-six.sh.example @@ -0,0 +1,8 @@ +# use configuration from hurricane electric to modify +# up to 5 hex placeholder in ipv6 allowed + +ip tunnel add he-ipv6 mode sit remote 1.2.3.4 local 1.2.3.5 ttl 255 +ip link set he-ipv6 up +ip addr add aaaa:aaa:aa:aaa::%x:%x/64 dev he-ipv6 +ip route add ::/0 dev he-ipv6 +ip -f inet6 addr