|
|
@@ -0,0 +1,129 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import "strconv"
|
|
|
+import "bufio"
|
|
|
+import "fmt"
|
|
|
+import "os"
|
|
|
+
|
|
|
+type Ipv7 struct {
|
|
|
+ Raw string
|
|
|
+ SupernetSequence []string
|
|
|
+ HypernetSequence []string
|
|
|
+}
|
|
|
+
|
|
|
+func IsAbba(in string) bool {
|
|
|
+ for i := 1; i < len(in) -2; i++ {
|
|
|
+ if in[i +1] == in[i] && in[i +2] == in[i -1] && in[i -1] != in[i] {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+func (this Ipv7) IsSupportingTLS() bool {
|
|
|
+ for _, i := range(this.HypernetSequence) {
|
|
|
+ if IsAbba(i) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, i := range(this.SupernetSequence) {
|
|
|
+ if IsAbba(i) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+func checkBab(BaB string, AbA []string) bool {
|
|
|
+ for _, i:= range(AbA) {
|
|
|
+ if BaB[0] == i[1] && BaB[1] == i[0] {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+func (this Ipv7) IsSupportingSSL() bool {
|
|
|
+ var Aba []string
|
|
|
+
|
|
|
+ for _, i := range(this.SupernetSequence) {
|
|
|
+ for j := 1; j < len(i) -1; j++ {
|
|
|
+ if (i[j -1] == i[j +1]) {
|
|
|
+ Aba = append(Aba, i[j-1: j +1])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, i := range(this.HypernetSequence) {
|
|
|
+ for j := 1; j < len(i) -1; j++ {
|
|
|
+ if (i[j -1] == i[j +1]) {
|
|
|
+ if checkBab(i[j -1:j +1], Aba) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+func NewIpv7(ip string) Ipv7 {
|
|
|
+ var this Ipv7
|
|
|
+ step := 0
|
|
|
+ var tmp string
|
|
|
+ this.Raw = ip
|
|
|
+
|
|
|
+ for _, v := range(ip) {
|
|
|
+ if v == '[' {
|
|
|
+ if len(tmp) > 0 && step == 0 {
|
|
|
+ this.SupernetSequence = append(this.SupernetSequence, tmp)
|
|
|
+ tmp = ""
|
|
|
+ }
|
|
|
+ step = 1
|
|
|
+ } else if v == ']' {
|
|
|
+ if len(tmp) > 0 && step == 1 {
|
|
|
+ this.HypernetSequence = append(this.HypernetSequence, tmp)
|
|
|
+ tmp = ""
|
|
|
+ }
|
|
|
+ step = 0
|
|
|
+ } else {
|
|
|
+ tmp += string(v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(tmp) > 0 {
|
|
|
+ if step == 0 {
|
|
|
+ this.SupernetSequence = append(this.SupernetSequence, tmp)
|
|
|
+ } else {
|
|
|
+ this.HypernetSequence = append(this.HypernetSequence, tmp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return this
|
|
|
+}
|
|
|
+
|
|
|
+func main() {
|
|
|
+ reader := bufio.NewReader(os.Stdin)
|
|
|
+ tlsCount := 0
|
|
|
+ sslCount := 0
|
|
|
+
|
|
|
+ for true {
|
|
|
+ line, err := reader.ReadString('\n')
|
|
|
+ if len(line) == 0 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ line = line[0:len(line)-1]
|
|
|
+ ip := NewIpv7(line)
|
|
|
+ if ip.IsSupportingTLS() {
|
|
|
+ tlsCount++
|
|
|
+ }
|
|
|
+ if ip.IsSupportingSSL() {
|
|
|
+ sslCount++
|
|
|
+ }
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fmt.Println("TLS: " +strconv.Itoa(tlsCount))
|
|
|
+ fmt.Println("SSL: " +strconv.Itoa(sslCount))
|
|
|
+}
|
|
|
+
|