87 lines
1.2 KiB
Go
87 lines
1.2 KiB
Go
package pop
|
|
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"fmt"
|
|
"git.loafle.net/overflow/overflow_discovery/service/matcher"
|
|
|
|
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
func TestPopTLS(t *testing.T) {
|
|
conn, _ := tls.Dial(
|
|
"tcp",
|
|
"192.168.1.15:995",
|
|
&tls.Config{
|
|
InsecureSkipVerify: true,
|
|
ServerName: "192.168.1.15",
|
|
},
|
|
)
|
|
|
|
defer conn.Close()
|
|
|
|
pop3Run(conn, t)
|
|
}
|
|
|
|
func TestPopNor(t *testing.T) {
|
|
|
|
client, _ := net.Dial("tcp", "192.168.1.15:110")
|
|
|
|
defer client.Close()
|
|
|
|
pop3Run(client, t)
|
|
|
|
}
|
|
|
|
func pop3Run(client net.Conn, t *testing.T) {
|
|
|
|
lm := NewPOPMatcher()
|
|
|
|
//port := types.NewPort("110", types.NewHost("192.168.1.215"), types.TYPE_TCP)
|
|
//scanInfo := scaninfo.NewServiceScanInfo(port)
|
|
//var ipport string
|
|
//ipport = port.Host.Ip + ":" + string(port.Port)
|
|
//
|
|
//fmt.Println(ipport)
|
|
|
|
bytett := make([]byte, 1024)
|
|
|
|
read, _ := client.Read(bytett)
|
|
|
|
bb := lm.Match(0, matcher.NewPacket(bytett, read), nil)
|
|
|
|
if bb {
|
|
t.Log("good!")
|
|
}
|
|
|
|
fmt.Println(lm.PacketCount())
|
|
|
|
for ii := 0; ii < lm.PacketCount(); ii++ {
|
|
|
|
pack := lm.Packet(ii)
|
|
|
|
//fmt.Println(pack)
|
|
|
|
client.Write(pack.Buffer)
|
|
|
|
bytes := make([]byte, 1024)
|
|
|
|
rr, _ := client.Read(bytes)
|
|
|
|
//fmt.Println(bytes)
|
|
|
|
b := lm.Match(ii+1, matcher.NewPacket(bytes, rr), nil)
|
|
|
|
if b {
|
|
t.Log("send Good!")
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|