2017-08-03 10:08:34 +00:00
|
|
|
package http
|
|
|
|
|
2017-08-09 03:21:34 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"git.loafle.net/overflow/overflow_probe/matcher/packet"
|
|
|
|
//"git.loafle.net/overflow/overflow_probe/discovery/discovery/types"
|
|
|
|
"net"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHTTPMatcher_Packet(t *testing.T) {
|
|
|
|
hm := NewHTTPMatcher()
|
|
|
|
fmt.Println(hm)
|
|
|
|
fmt.Println(hm.sendPackets[0])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHTTPMatcher_Match(t *testing.T) {
|
|
|
|
fmt.Println("Match")
|
|
|
|
|
|
|
|
hm := NewHTTPMatcher()
|
|
|
|
|
|
|
|
//port := types.NewPort("80", types.NewHost("192.168.1.103"), types.TYPE_TCP)
|
|
|
|
//
|
|
|
|
//var ipport string
|
|
|
|
//ipport = port.Host.Ip + ":" + string(port.Port)
|
|
|
|
|
|
|
|
//fmt.Println(ipport)
|
|
|
|
|
|
|
|
client, _ := net.Dial("tcp", "192.168.1.15:38980")
|
|
|
|
|
|
|
|
defer client.Close()
|
|
|
|
|
|
|
|
pack := hm.Packet(0)
|
|
|
|
|
|
|
|
//fmt.Println(pack)
|
|
|
|
|
|
|
|
//writer.WriteString(pack)
|
|
|
|
client.Write(pack.Buffer)
|
|
|
|
|
|
|
|
bytes := make([]byte, 512)
|
|
|
|
|
|
|
|
l, _ := client.Read(bytes)
|
|
|
|
|
|
|
|
//fmt.Println(bytes)
|
|
|
|
|
|
|
|
hm.Match(0, packet.NewPacket(bytes, l), nil)
|
|
|
|
|
|
|
|
}
|