initial working tls connection
parent
480c54e81e
commit
130f818110
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -197,7 +198,15 @@ func d4checkConfig(d4 *d4S) bool {
|
||||||
f, _ := os.Open("capture.pcap")
|
f, _ := os.Open("capture.pcap")
|
||||||
(*d4).src = f
|
(*d4).src = f
|
||||||
}
|
}
|
||||||
|
isn, dstnet := isNet((*d4).conf.destination)
|
||||||
|
if isn {
|
||||||
|
//conn, err := net.Dial("tcp", dstnet[0]+":"+dstnet[1])
|
||||||
|
conn, err := tls.Dial("tcp", dstnet[0]+":"+dstnet[1], &tls.Config{InsecureSkipVerify: true})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
(*d4).dst = newD4Writer(conn, (*d4).conf.key)
|
||||||
|
} else {
|
||||||
switch (*d4).conf.destination {
|
switch (*d4).conf.destination {
|
||||||
case "stdout":
|
case "stdout":
|
||||||
(*d4).dst = newD4Writer(os.Stdout, (*d4).conf.key)
|
(*d4).dst = newD4Writer(os.Stdout, (*d4).conf.key)
|
||||||
|
@ -205,6 +214,7 @@ func d4checkConfig(d4 *d4S) bool {
|
||||||
f, _ := os.Create("test.txt")
|
f, _ := os.Create("test.txt")
|
||||||
(*d4).dst = newD4Writer(f, (*d4).conf.key)
|
(*d4).dst = newD4Writer(f, (*d4).conf.key)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the copy buffer
|
// Create the copy buffer
|
||||||
(*d4).dst.fb = make([]byte, HDR_SIZE+(*d4).conf.snaplen)
|
(*d4).dst.fb = make([]byte, HDR_SIZE+(*d4).conf.snaplen)
|
||||||
|
@ -213,15 +223,15 @@ func d4checkConfig(d4 *d4S) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isNet(d []byte) (bool, []string) {
|
func isNet(d string) (bool, []string) {
|
||||||
ss := strings.Split(string(d), ":")
|
ss := strings.Split(string(d), ":")
|
||||||
if len(ss) != 1 {
|
if len(ss) != 1 {
|
||||||
if net.ParseIP(ss[0]) != nil {
|
if net.ParseIP(ss[0]) != nil {
|
||||||
infof(fmt.Sprintf("Server IP: %s, Server Port: %s\n", ss[0], ss[1]))
|
infof(fmt.Sprintf("Server IP: %s, Server Port: %s\n", ss[0], ss[1]))
|
||||||
return true, make([]string, 0)
|
return true, ss
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, ss
|
return false, make([]string, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateUUIDv4() []byte {
|
func generateUUIDv4() []byte {
|
||||||
|
|
Loading…
Reference in New Issue