import path

This commit is contained in:
insanity 2018-08-15 16:17:18 +09:00
parent 3d28519fa1
commit 14ddc4feba
52 changed files with 310 additions and 779 deletions

2
Gopkg.lock generated
View File

@ -3,7 +3,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "git.loafle.net/commons/service_matcher-go" name = "git.loafle.net/overflow/service_matcher-go"
packages = [ packages = [
".", ".",
"snmp" "snmp"

View File

@ -27,7 +27,7 @@
[[constraint]] [[constraint]]
branch = "master" branch = "master"
name = "git.loafle.net/commons/service_matcher-go" name = "git.loafle.net/overflow/service_matcher-go"
[[constraint]] [[constraint]]
name = "github.com/stretchr/testify" name = "github.com/stretchr/testify"

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -170,7 +170,7 @@ type AD_RECV struct {
} }
type ActiveDirectoryMatcher struct { type ActiveDirectoryMatcher struct {
csm.Matchers osm.Matchers
} }
func (m *ActiveDirectoryMatcher) Key() string { func (m *ActiveDirectoryMatcher) Key() string {
@ -181,7 +181,7 @@ func (m *ActiveDirectoryMatcher) Name() string {
return "ActiveDirectory" return "ActiveDirectory"
} }
func (m *ActiveDirectoryMatcher) Meta() csm.Metadata { func (m *ActiveDirectoryMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -189,14 +189,14 @@ func (m *ActiveDirectoryMatcher) IsPrePacket() bool {
return false return false
} }
func (m *ActiveDirectoryMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (m *ActiveDirectoryMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (m *ActiveDirectoryMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (m *ActiveDirectoryMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
@ -207,11 +207,11 @@ func (m *ActiveDirectoryMatcher) Match(info csm.MatchInfo, index int, packet *cs
binary.Read(buf, binary.BigEndian, &adRecv) binary.Read(buf, binary.BigEndian, &adRecv)
if adRecv.MessageId != AD_MESSAGE_ID { if adRecv.MessageId != AD_MESSAGE_ID {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if adRecv.ProtocolOp != LDAP_RES_SEARCH_ENTRY { if adRecv.ProtocolOp != LDAP_RES_SEARCH_ENTRY {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
///AD_TYPE_STR ///AD_TYPE_STR
@ -233,7 +233,7 @@ func (m *ActiveDirectoryMatcher) Match(info csm.MatchInfo, index int, packet *cs
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
ls := AD_SEND{ ls := AD_SEND{
DefaultCode: 0x30, DefaultCode: 0x30,
@ -306,7 +306,7 @@ func NewMatcher() csm.Matcher {
//sendPackets: make([][]byte, 2), //sendPackets: make([][]byte, 2),
} }
pp := csm.NewPacket(sendByte1, len(sendByte1)) pp := osm.NewPacket(sendByte1, len(sendByte1))
m.AddPacket(pp) m.AddPacket(pp)
@ -327,7 +327,7 @@ func NewMatcher() csm.Matcher {
quBytes := lqBuffer.Bytes() quBytes := lqBuffer.Bytes()
pp2 := csm.NewPacket(quBytes, len(quBytes)) pp2 := osm.NewPacket(quBytes, len(quBytes))
m.AddPacket(pp2) m.AddPacket(pp2)

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestAD(t *testing.T) { func TestAD(t *testing.T) {
@ -24,7 +24,7 @@ func TestAD(t *testing.T) {
conn.Write(pack.Buffer) conn.Write(pack.Buffer)
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type cassandra struct { type cassandra struct {
@ -16,7 +16,7 @@ type cassandra struct {
} }
type CassandraMatcher struct { type CassandraMatcher struct {
csm.Matchers osm.Matchers
} }
func (m *CassandraMatcher) Key() string { func (m *CassandraMatcher) Key() string {
@ -27,7 +27,7 @@ func (m *CassandraMatcher) Name() string {
return "Cassandra" return "Cassandra"
} }
func (m *CassandraMatcher) Meta() csm.Metadata { func (m *CassandraMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -39,14 +39,14 @@ func (m *CassandraMatcher) HasResponse(index int) bool {
return true return true
} }
func (m *CassandraMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (m *CassandraMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (m *CassandraMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (m *CassandraMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
reader := new(bytes.Buffer) reader := new(bytes.Buffer)
@ -57,23 +57,23 @@ func (m *CassandraMatcher) Match(info csm.MatchInfo, index int, packet *csm.Pack
return err return err
} }
if c.Version != 0x84 { if c.Version != 0x84 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if c.Flags != 0x00 { if c.Flags != 0x00 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if c.Stream != 0x00 { if c.Stream != 0x00 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if c.Opcode != 0x06 { if c.Opcode != 0x06 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &CassandraMatcher{} m := &CassandraMatcher{}
c := cassandra{ c := cassandra{
@ -86,7 +86,7 @@ func NewMatcher() csm.Matcher {
writer := new(bytes.Buffer) writer := new(bytes.Buffer)
binary.Write(writer, binary.LittleEndian, c) binary.Write(writer, binary.LittleEndian, c)
m.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len())) m.AddPacket(osm.NewPacket(writer.Bytes(), writer.Len()))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestCassandra(t *testing.T) { func TestCassandra(t *testing.T) {
@ -24,7 +24,7 @@ func TestCassandra(t *testing.T) {
conn.Write(pack.Buffer) conn.Write(pack.Buffer)
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type Dns_frame_header struct { type Dns_frame_header struct {
@ -38,7 +38,7 @@ type Dns_authority_section struct {
} }
type DNSMatcher struct { type DNSMatcher struct {
csm.Matchers osm.Matchers
} }
func (t *DNSMatcher) Key() string { func (t *DNSMatcher) Key() string {
@ -49,7 +49,7 @@ func (t *DNSMatcher) String() string {
return "DNS" return "DNS"
} }
func (t *DNSMatcher) Meta() csm.Metadata { func (t *DNSMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -61,13 +61,13 @@ func (t *DNSMatcher) HasResponse(index int) bool {
return true return true
} }
func (t *DNSMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (t *DNSMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (t *DNSMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (t *DNSMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
reader := new(bytes.Buffer) reader := new(bytes.Buffer)
@ -79,36 +79,36 @@ func (t *DNSMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) er
} }
if h.Transaction_id != 0x2a88 { if h.Transaction_id != 0x2a88 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if h.Flags != 0x8180 && h.Flags != 0x8182 { if h.Flags != 0x8180 && h.Flags != 0x8182 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if h.Questions != 1 { if h.Questions != 1 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if h.Answer_rrs != 0 { if h.Answer_rrs != 0 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if h.Authority_rrs != 0 && h.Authority_rrs != 1 { if h.Authority_rrs != 0 && h.Authority_rrs != 1 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if h.Additional_rrs != 0 && h.Additional_rrs != 1 { if h.Additional_rrs != 0 && h.Additional_rrs != 1 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
q := Dns_query_section{} q := Dns_query_section{}
if err := binary.Read(reader, binary.BigEndian, &q); err != nil { if err := binary.Read(reader, binary.BigEndian, &q); err != nil {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if q.Name != 0 { if q.Name != 0 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if q.Query_type != 1 { if q.Query_type != 1 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if q.Class_type != 1 { if q.Class_type != 1 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
@ -121,7 +121,7 @@ func (t *DNSMatcher) IsSend(port int) bool {
return false return false
} }
func NewMatcher() csm.UDPMatcher { func NewMatcher() osm.UDPMatcher {
m := &DNSMatcher{} m := &DNSMatcher{}
@ -144,7 +144,7 @@ func NewMatcher() csm.UDPMatcher {
binary.Write(buf, binary.BigEndian, header) binary.Write(buf, binary.BigEndian, header)
binary.Write(buf, binary.BigEndian, query) binary.Write(buf, binary.BigEndian, query)
m.AddPacket(csm.NewPacket(buf.Bytes(), buf.Len())) m.AddPacket(osm.NewPacket(buf.Bytes(), buf.Len()))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestDns(t *testing.T) { func TestDns(t *testing.T) {
@ -22,7 +22,7 @@ func TestDns(t *testing.T) {
conn.Write(pack.Buffer) conn.Write(pack.Buffer)
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, 0, p); err != nil { if err := m.Match(nil, 0, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -6,12 +6,12 @@ import (
"strconv" "strconv"
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type ElasticSearchMatcher struct { type ElasticSearchMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (es *ElasticSearchMatcher) Key() string { func (es *ElasticSearchMatcher) Key() string {
@ -26,7 +26,7 @@ func (es *ElasticSearchMatcher) Name() string {
return name return name
} }
func (es *ElasticSearchMatcher) Meta() csm.Metadata { func (es *ElasticSearchMatcher) Meta() osm.Metadata {
return es.meta return es.meta
} }
@ -38,14 +38,14 @@ func (es *ElasticSearchMatcher) HasResponse(index int) bool {
return true return true
} }
func (es *ElasticSearchMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (es *ElasticSearchMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (es *ElasticSearchMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (es *ElasticSearchMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
str := string(packet.Buffer) str := string(packet.Buffer)
@ -64,18 +64,18 @@ func (es *ElasticSearchMatcher) Match(info csm.MatchInfo, index int, packet *csm
} }
if lineNo == 0 && !strings.HasPrefix(line, "HTTP/") { if lineNo == 0 && !strings.HasPrefix(line, "HTTP/") {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if strings.Contains(line, ":") { if strings.Contains(line, ":") {
kv := strings.Split(line, ": ") kv := strings.Split(line, ": ")
if kv[0] == "content-type" && !strings.Contains(kv[1], "application/json") { if kv[0] == "content-type" && !strings.Contains(kv[1], "application/json") {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if kv[0] == "content-length" { if kv[0] == "content-length" {
len, err := strconv.Atoi(kv[1]) len, err := strconv.Atoi(kv[1])
if err != nil { if err != nil {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
contentLen = len contentLen = len
} }
@ -84,14 +84,14 @@ func (es *ElasticSearchMatcher) Match(info csm.MatchInfo, index int, packet *csm
} }
content := body[:contentLen] content := body[:contentLen]
if strings.HasPrefix(content, "{") && strings.HasSuffix(content, "}") { if strings.HasPrefix(content, "{") && strings.HasSuffix(content, "}") {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
es.parseJson(content) es.parseJson(content)
if _, ok := es.meta["cluster_name"]; !ok { if _, ok := es.meta["cluster_name"]; !ok {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if _, ok := es.meta["cluster_uuid"]; !ok { if _, ok := es.meta["cluster_uuid"]; !ok {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
@ -119,16 +119,16 @@ func (es *ElasticSearchMatcher) dumpMap(m map[string]interface{}) {
} }
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &ElasticSearchMatcher{} m := &ElasticSearchMatcher{}
m.meta = csm.NewMetadata() m.meta = osm.NewMetadata()
reqStr := "GET / HTTP/1.1\r\n\r\n" reqStr := "GET / HTTP/1.1\r\n\r\n"
byte := make([]byte, len(reqStr)) byte := make([]byte, len(reqStr))
copy(byte[:], reqStr) copy(byte[:], reqStr)
m.AddPacket(csm.NewPacket(byte, len(reqStr))) m.AddPacket(osm.NewPacket(byte, len(reqStr)))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestES(t *testing.T) { func TestES(t *testing.T) {
@ -24,7 +24,7 @@ func TestES(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -3,7 +3,7 @@ package ftp
import ( import (
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
// FTP Status codes, defined in RFC 959 // FTP Status codes, defined in RFC 959
@ -26,8 +26,8 @@ const (
) )
type FTPMatcher struct { type FTPMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (ftp *FTPMatcher) Key() string { func (ftp *FTPMatcher) Key() string {
@ -38,7 +38,7 @@ func (ftp *FTPMatcher) Name() string {
return "FTP" return "FTP"
} }
func (ftp *FTPMatcher) Meta() csm.Metadata { func (ftp *FTPMatcher) Meta() osm.Metadata {
return ftp.meta return ftp.meta
} }
@ -50,19 +50,19 @@ func (ftp *FTPMatcher) HasResponse(index int) bool {
return true return true
} }
func (ftp *FTPMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (ftp *FTPMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (ftp *FTPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (ftp *FTPMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
str := strings.Split(string(packet.Buffer), "\r\n")[0] str := strings.Split(string(packet.Buffer), "\r\n")[0]
if len(str) < 4 { if len(str) < 4 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
code := str[:3] code := str[:3]
@ -79,18 +79,18 @@ func (ftp *FTPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet)
} }
} }
return csm.NotMatchedError() return osm.NotMatchedError()
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &FTPMatcher{} m := &FTPMatcher{}
m.meta = csm.NewMetadata() m.meta = osm.NewMetadata()
quitStr := "QUIT\r\n" quitStr := "QUIT\r\n"
quitByte := make([]byte, len(quitStr)) quitByte := make([]byte, len(quitStr))
copy(quitByte[:], quitStr) copy(quitByte[:], quitStr)
m.AddPacket(csm.NewPacket(quitByte, len(quitStr))) m.AddPacket(osm.NewPacket(quitByte, len(quitStr)))
return m return m
} }

View File

@ -6,7 +6,7 @@ import (
"testing" "testing"
"time" "time"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestFTP(t *testing.T) { func TestFTP(t *testing.T) {
@ -27,7 +27,7 @@ func TestFTP(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)
@ -68,7 +68,7 @@ func TestFTPS(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -3,12 +3,12 @@ package http
import ( import (
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type HTTPMatcher struct { type HTTPMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (h *HTTPMatcher) Key() string { func (h *HTTPMatcher) Key() string {
@ -23,7 +23,7 @@ func (h *HTTPMatcher) Name() string {
return name return name
} }
func (h *HTTPMatcher) Meta() csm.Metadata { func (h *HTTPMatcher) Meta() osm.Metadata {
return h.meta return h.meta
} }
@ -35,27 +35,27 @@ func (h *HTTPMatcher) HasResponse(index int) bool {
return true return true
} }
func (h *HTTPMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (h *HTTPMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (h *HTTPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (h *HTTPMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
str := string(packet.Buffer) str := string(packet.Buffer)
elems := strings.Split(str, "\r\n") elems := strings.Split(str, "\r\n")
if len(elems) <= 0 || 9 > len(elems[0]) { if len(elems) <= 0 || 9 > len(elems[0]) {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
protocol := (elems[0])[:8] protocol := (elems[0])[:8]
if !strings.HasPrefix(protocol, "HTTP/") { if !strings.HasPrefix(protocol, "HTTP/") {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
serverName := "" serverName := ""
@ -76,16 +76,16 @@ func (h *HTTPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) e
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &HTTPMatcher{} m := &HTTPMatcher{}
m.meta = csm.NewMetadata() m.meta = osm.NewMetadata()
reqStr := "GET / HTTP/1.1\r\n\r\n" reqStr := "GET / HTTP/1.1\r\n\r\n"
byte := make([]byte, len(reqStr)) byte := make([]byte, len(reqStr))
copy(byte[:], reqStr) copy(byte[:], reqStr)
m.AddPacket(csm.NewPacket(byte, len(reqStr))) m.AddPacket(osm.NewPacket(byte, len(reqStr)))
return m return m
} }

View File

@ -6,7 +6,7 @@ import (
"testing" "testing"
"time" "time"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestHTTP(t *testing.T) { func TestHTTP(t *testing.T) {
@ -26,7 +26,7 @@ func TestHTTP(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)
@ -65,7 +65,7 @@ func TestHTTPS(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -1,7 +1,7 @@
package imap package imap
import ( import (
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -10,7 +10,7 @@ const (
) )
type IMAPMatcher struct { type IMAPMatcher struct {
csm.Matchers osm.Matchers
} }
func (i *IMAPMatcher) Key() string { func (i *IMAPMatcher) Key() string {
@ -29,11 +29,11 @@ func (i *IMAPMatcher) HasResponse(index int) bool {
return true return true
} }
func (i *IMAPMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (i *IMAPMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (i *IMAPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (i *IMAPMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bool {
switch index { switch index {
case 0: case 0:
@ -69,7 +69,7 @@ func (i *IMAPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) b
return false return false
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &IMAPMatcher{} m := &IMAPMatcher{}
@ -77,7 +77,7 @@ func NewMatcher() csm.Matcher {
byte := make([]byte, len(reqStr)) byte := make([]byte, len(reqStr))
copy(byte[:], reqStr) copy(byte[:], reqStr)
m.AddPacket(csm.NewPacket(byte, len(reqStr))) m.AddPacket(osm.NewPacket(byte, len(reqStr)))
return m return m

View File

@ -6,7 +6,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func ImapRun(client net.Conn, t *testing.T) { func ImapRun(client net.Conn, t *testing.T) {
@ -29,7 +29,7 @@ func ImapRun(client net.Conn, t *testing.T) {
rr, _ := client.Read(bytett) rr, _ := client.Read(bytett)
bb := lm.Match(nil, 0, csm.NewPacket(bytett, rr)) bb := lm.Match(nil, 0, osm.NewPacket(bytett, rr))
if bb { if bb {
t.Log("good!") t.Log("good!")
@ -53,7 +53,7 @@ func ImapRun(client net.Conn, t *testing.T) {
//fmt.Println(bytes) //fmt.Println(bytes)
b := lm.Match(nil, ii+1, csm.NewPacket(bytes, read)) b := lm.Match(nil, ii+1, osm.NewPacket(bytes, read))
if b { if b {
t.Log("send Good!") t.Log("send Good!")
@ -113,8 +113,8 @@ func TestImap(t *testing.T) {
rr, _ := client.Read(bytett) rr, _ := client.Read(bytett)
//bb := lm.Match(0, csm.NewPacket(bytett, rr), scanInfo) //bb := lm.Match(0, osm.NewPacket(bytett, rr), scanInfo)
bb := lm.Match(nil, 0, csm.NewPacket(bytett, rr)) bb := lm.Match(nil, 0, osm.NewPacket(bytett, rr))
if bb { if bb {
t.Log("good!") t.Log("good!")
@ -138,7 +138,7 @@ func TestImap(t *testing.T) {
//fmt.Println(bytes) //fmt.Println(bytes)
b := lm.Match(nil, ii+1, csm.NewPacket(bytes, read)) b := lm.Match(nil, ii+1, osm.NewPacket(bytes, read))
if b { if b {
t.Log("send Good!") t.Log("send Good!")

View File

@ -4,7 +4,7 @@ import (
"math/rand" "math/rand"
"time" "time"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
ber "gopkg.in/asn1-ber.v1" ber "gopkg.in/asn1-ber.v1"
) )
@ -14,7 +14,7 @@ const (
) )
type LDAPMatcher struct { type LDAPMatcher struct {
csm.Matchers osm.Matchers
reqID int64 reqID int64
} }
@ -26,7 +26,7 @@ func (l *LDAPMatcher) Name() string {
return "LDAP" return "LDAP"
} }
func (l *LDAPMatcher) Meta() csm.Metadata { func (l *LDAPMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -34,33 +34,33 @@ func (l *LDAPMatcher) IsPrePacket() bool {
return false return false
} }
func (l *LDAPMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (l *LDAPMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (l *LDAPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (l *LDAPMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
p := ber.DecodePacket(packet.Buffer) p := ber.DecodePacket(packet.Buffer)
respID, ok := p.Children[0].Value.(int64) respID, ok := p.Children[0].Value.(int64)
if !ok { if !ok {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if respID != l.reqID { if respID != l.reqID {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if p.Children[1].Tag != ApplicationBindResponse { if p.Children[1].Tag != ApplicationBindResponse {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &LDAPMatcher{} m := &LDAPMatcher{}
@ -75,7 +75,7 @@ func NewMatcher() csm.Matcher {
bindRequest.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, "LOAFLEOVERFLOW", "Password")) bindRequest.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, "LOAFLEOVERFLOW", "Password"))
p.AppendChild(bindRequest) p.AppendChild(bindRequest)
m.AddPacket(csm.NewPacket(p.Bytes(), len(p.Bytes()))) m.AddPacket(osm.NewPacket(p.Bytes(), len(p.Bytes())))
return m return m

View File

@ -7,7 +7,7 @@ import (
"math/rand" "math/rand"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
"gopkg.in/asn1-ber.v1" "gopkg.in/asn1-ber.v1"
) )
@ -28,7 +28,7 @@ func TestLdap(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -1,19 +1,19 @@
package lpd package lpd
import ( import (
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type LPDMatcher struct { type LPDMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (l *LPDMatcher) Key() string { func (l *LPDMatcher) Key() string {
return "LPD" return "LPD"
} }
func (l *LPDMatcher) Meta() csm.Metadata { func (l *LPDMatcher) Meta() osm.Metadata {
return l.meta return l.meta
} }
@ -29,31 +29,31 @@ func (l *LPDMatcher) HasResponse(index int) bool {
return true return true
} }
func (l *LPDMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (l *LPDMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (l *LPDMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (l *LPDMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
if packet.Len != 1 { if packet.Len != 1 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &LPDMatcher{} m := &LPDMatcher{}
reqStr := "GET / HTTP/1.1\r\n\r\n" reqStr := "GET / HTTP/1.1\r\n\r\n"
rbyte := make([]byte, len(reqStr)) rbyte := make([]byte, len(reqStr))
copy(rbyte[:], reqStr) copy(rbyte[:], reqStr)
m.AddPacket(csm.NewPacket(rbyte, len(reqStr))) m.AddPacket(osm.NewPacket(rbyte, len(reqStr)))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestLDP(t *testing.T) { func TestLDP(t *testing.T) {
@ -24,7 +24,7 @@ func TestLDP(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -5,7 +5,7 @@ import (
"encoding/binary" "encoding/binary"
"math/rand" "math/rand"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -47,8 +47,8 @@ type OP_reply struct {
} }
type MongoDBMatcher struct { type MongoDBMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (m *MongoDBMatcher) Key() string { func (m *MongoDBMatcher) Key() string {
@ -59,7 +59,7 @@ func (m *MongoDBMatcher) Name() string {
return "MongoDB" return "MongoDB"
} }
func (m *MongoDBMatcher) Meta() csm.Metadata { func (m *MongoDBMatcher) Meta() osm.Metadata {
return m.meta return m.meta
} }
@ -71,14 +71,14 @@ func (m *MongoDBMatcher) HasResponse(index int) bool {
return true return true
} }
func (m *MongoDBMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (m *MongoDBMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (m *MongoDBMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (m *MongoDBMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
reader := new(bytes.Buffer) reader := new(bytes.Buffer)
@ -90,25 +90,25 @@ func (m *MongoDBMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet
} }
if uint32(packet.Len) != reply.Header.MessageLength { if uint32(packet.Len) != reply.Header.MessageLength {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if reply.Header.ResponseTo != MONGO_REQUEST_ID { if reply.Header.ResponseTo != MONGO_REQUEST_ID {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if reply.Header.OpCode != MONGO_OP_REPLY { if reply.Header.OpCode != MONGO_OP_REPLY {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
mm := &MongoDBMatcher{} mm := &MongoDBMatcher{}
mm.meta = csm.NewMetadata() mm.meta = osm.NewMetadata()
tempBuf := new(bytes.Buffer) tempBuf := new(bytes.Buffer)
binary.Write(tempBuf, binary.BigEndian, OP_request{}) binary.Write(tempBuf, binary.BigEndian, OP_request{})
@ -139,7 +139,7 @@ func NewMatcher() csm.Matcher {
writer := new(bytes.Buffer) writer := new(bytes.Buffer)
binary.Write(writer, binary.LittleEndian, m) binary.Write(writer, binary.LittleEndian, m)
mm.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len())) mm.AddPacket(osm.NewPacket(writer.Bytes(), writer.Len()))
return mm return mm
} }

View File

@ -5,7 +5,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestMongoNor(t *testing.T) { func TestMongoNor(t *testing.T) {
@ -43,7 +43,7 @@ func MongoRun(conn net.Conn, t *testing.T) {
conn.Write(pack.Buffer) conn.Write(pack.Buffer)
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -6,12 +6,12 @@ import (
"io" "io"
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type MySqlMatcher struct { type MySqlMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (m *MySqlMatcher) Key() string { func (m *MySqlMatcher) Key() string {
@ -29,7 +29,7 @@ func (m *MySqlMatcher) Name() string {
return name return name
} }
func (m *MySqlMatcher) Meta() csm.Metadata { func (m *MySqlMatcher) Meta() osm.Metadata {
return m.meta return m.meta
} }
@ -41,7 +41,7 @@ func (m *MySqlMatcher) HasResponse(index int) bool {
return true return true
} }
func (m *MySqlMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (m *MySqlMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
@ -55,26 +55,26 @@ type serverSettings struct {
keepalive int64 keepalive int64
} }
func (m *MySqlMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (m *MySqlMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
buf := bytes.NewBuffer(packet.Buffer[:3]) buf := bytes.NewBuffer(packet.Buffer[:3])
packetLen, _ := binary.ReadUvarint(buf) packetLen, _ := binary.ReadUvarint(buf)
if packetLen != uint64(packet.Len-4) { if packetLen != uint64(packet.Len-4) {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
pos := 4 pos := 4
p := new(serverSettings) p := new(serverSettings)
p.protocol = packet.Buffer[pos] p.protocol = packet.Buffer[pos]
if p.protocol != 9 && p.protocol != 10 { if p.protocol != 9 && p.protocol != 10 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
pos++ pos++
slice, err := readSlice(packet.Buffer[pos:], 0x00) slice, err := readSlice(packet.Buffer[pos:], 0x00)
if err != nil { if err != nil {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
m.meta["version"] = string(slice) m.meta["version"] = string(slice)
pos += len(slice) + 1 pos += len(slice) + 1
@ -103,8 +103,8 @@ func bytesToUint32(b []byte) (n uint32) {
return return
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &MySqlMatcher{} m := &MySqlMatcher{}
m.meta = csm.NewMetadata() m.meta = osm.NewMetadata()
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestMySql(t *testing.T) { func TestMySql(t *testing.T) {
@ -17,7 +17,7 @@ func TestMySql(t *testing.T) {
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, 0, p); err != nil { if err := m.Match(nil, 0, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -26,7 +26,7 @@ type NBSS struct {
} }
type NBSSMatcher struct { type NBSSMatcher struct {
csm.Matchers osm.Matchers
} }
func (t *NBSSMatcher) Key() string { func (t *NBSSMatcher) Key() string {
@ -37,7 +37,7 @@ func (t *NBSSMatcher) Name() string {
return "NBSS" return "NBSS"
} }
func (t *NBSSMatcher) Meta() csm.Metadata { func (t *NBSSMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -49,14 +49,14 @@ func (t *NBSSMatcher) HasResponse(index int) bool {
return true return true
} }
func (t *NBSSMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (t *NBSSMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (t *NBSSMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (t *NBSSMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
reader := new(bytes.Buffer) reader := new(bytes.Buffer)
@ -64,18 +64,18 @@ func (t *NBSSMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) e
n := NBSS{} n := NBSS{}
if err := binary.Read(reader, binary.LittleEndian, &n); err != nil { if err := binary.Read(reader, binary.LittleEndian, &n); err != nil {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if NBSS_NEGATIVE_SESSION_RESPONSE != n.MsgType { if NBSS_NEGATIVE_SESSION_RESPONSE != n.MsgType {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &NBSSMatcher{} m := &NBSSMatcher{}
@ -103,7 +103,7 @@ func NewMatcher() csm.Matcher {
writer := new(bytes.Buffer) writer := new(bytes.Buffer)
binary.Write(writer, binary.LittleEndian, query) binary.Write(writer, binary.LittleEndian, query)
m.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len())) m.AddPacket(osm.NewPacket(writer.Bytes(), writer.Len()))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestNBSS(t *testing.T) { func TestNBSS(t *testing.T) {
@ -21,7 +21,7 @@ func TestNBSS(t *testing.T) {
conn.Write(pack.Buffer) conn.Write(pack.Buffer)
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, 0, p); err != nil { if err := m.Match(nil, 0, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -4,11 +4,11 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type OracleMatcher struct { type OracleMatcher struct {
csm.Matchers osm.Matchers
} }
func (o *OracleMatcher) Key() string { func (o *OracleMatcher) Key() string {
@ -26,11 +26,11 @@ func (o *OracleMatcher) HasResponse(index int) bool {
return true return true
} }
func (o *OracleMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (o *OracleMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (o *OracleMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (o *OracleMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bool {
if packet == nil { if packet == nil {
return false return false
@ -77,7 +77,7 @@ func (o *OracleMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet)
return true return true
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &OracleMatcher{} m := &OracleMatcher{}
@ -145,7 +145,7 @@ func NewMatcher() csm.Matcher {
copy(sendByte[len(hpBt):], bcBt) copy(sendByte[len(hpBt):], bcBt)
copy(sendByte[len(hpBt)+len(bcBt):], connect_data) copy(sendByte[len(hpBt)+len(bcBt):], connect_data)
m.AddPacket(csm.NewPacket(sendByte, byteSize)) m.AddPacket(osm.NewPacket(sendByte, byteSize))
return m return m

View File

@ -1,7 +1,7 @@
package oracle package oracle
import ( import (
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
"net" "net"
"testing" "testing"
@ -36,7 +36,7 @@ func TestOracle(t *testing.T) {
t.Log(bytes) t.Log(bytes)
b := lm.Match(ii, csm.NewPacket(bytes, read), nil) b := lm.Match(ii, osm.NewPacket(bytes, read), nil)
if b { if b {
t.Log("Good") t.Log("Good")

View File

@ -1,7 +1,7 @@
package pop package pop
import ( import (
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -9,7 +9,7 @@ const (
) )
type POPMatcher struct { type POPMatcher struct {
csm.Matchers osm.Matchers
} }
func (p *POPMatcher) Key() string { func (p *POPMatcher) Key() string {
@ -28,11 +28,11 @@ func (p *POPMatcher) HasResponse(index int) bool {
return true return true
} }
func (p *POPMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (p *POPMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (p *POPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (p *POPMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bool {
switch index { switch index {
case 0: case 0:
@ -55,14 +55,14 @@ func (p *POPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bo
return false return false
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &POPMatcher{} m := &POPMatcher{}
reqStr := "QUIT\r\n" reqStr := "QUIT\r\n"
byte := make([]byte, len(reqStr)) byte := make([]byte, len(reqStr))
copy(byte[:], reqStr) copy(byte[:], reqStr)
m.AddPacket(csm.NewPacket(byte, len(reqStr))) m.AddPacket(osm.NewPacket(byte, len(reqStr)))
return m return m

View File

@ -4,7 +4,7 @@ import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
"net" "net"
"testing" "testing"
@ -50,7 +50,7 @@ func pop3Run(client net.Conn, t *testing.T) {
read, _ := client.Read(bytett) read, _ := client.Read(bytett)
bb := lm.Match(0, csm.NewPacket(bytett, read), nil) bb := lm.Match(0, osm.NewPacket(bytett, read), nil)
if bb { if bb {
t.Log("good!") t.Log("good!")
@ -72,7 +72,7 @@ func pop3Run(client net.Conn, t *testing.T) {
//fmt.Println(bytes) //fmt.Println(bytes)
b := lm.Match(ii+1, csm.NewPacket(bytes, rr), nil) b := lm.Match(ii+1, osm.NewPacket(bytes, rr), nil)
if b { if b {
t.Log("send Good!") t.Log("send Good!")

View File

@ -5,7 +5,7 @@ import (
"encoding/binary" "encoding/binary"
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -38,8 +38,8 @@ type pgsqlErrResponse struct {
} }
type PostgreSQLMatcher struct { type PostgreSQLMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (p *PostgreSQLMatcher) Key() string { func (p *PostgreSQLMatcher) Key() string {
@ -50,7 +50,7 @@ func (p *PostgreSQLMatcher) Name() string {
return "PostgreSQL" return "PostgreSQL"
} }
func (p *PostgreSQLMatcher) Meta() csm.Metadata { func (p *PostgreSQLMatcher) Meta() osm.Metadata {
return p.meta return p.meta
} }
@ -62,14 +62,14 @@ func (p *PostgreSQLMatcher) HasResponse(index int) bool {
return true return true
} }
func (p *PostgreSQLMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (p *PostgreSQLMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return true return true
} }
func (p *PostgreSQLMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (p *PostgreSQLMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
reader := new(bytes.Buffer) reader := new(bytes.Buffer)
@ -81,12 +81,12 @@ func (p *PostgreSQLMatcher) Match(info csm.MatchInfo, index int, packet *csm.Pac
} }
if pg.ResponseType != RESPONSE_TYPE_ERR { if pg.ResponseType != RESPONSE_TYPE_ERR {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
length := binary.BigEndian.Uint32(pg.Len[:]) length := binary.BigEndian.Uint32(pg.Len[:])
if length+1 != uint32(packet.Len) { if length+1 != uint32(packet.Len) {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
data := string(pg.Data[:]) data := string(pg.Data[:])
@ -104,14 +104,14 @@ func (p *PostgreSQLMatcher) Match(info csm.MatchInfo, index int, packet *csm.Pac
} }
if !findSeverity || !findErrorCode { if !findSeverity || !findErrorCode {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &PostgreSQLMatcher{} m := &PostgreSQLMatcher{}
@ -163,7 +163,7 @@ func NewMatcher() csm.Matcher {
writer := new(bytes.Buffer) writer := new(bytes.Buffer)
binary.Write(writer, binary.BigEndian, pg) binary.Write(writer, binary.BigEndian, pg)
m.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len())) m.AddPacket(osm.NewPacket(writer.Bytes(), writer.Len()))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestPG(t *testing.T) { func TestPG(t *testing.T) {
@ -23,7 +23,7 @@ func TestPG(t *testing.T) {
conn.Write(pack.Buffer) conn.Write(pack.Buffer)
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -4,7 +4,7 @@ import (
"bufio" "bufio"
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const REDIS_PING string = "*1\r\n$4\r\nPING\r\n" const REDIS_PING string = "*1\r\n$4\r\nPING\r\n"
@ -12,8 +12,8 @@ const REDIS_INFO string = "*1\r\n$4\r\nINFO\r\n"
const REDIS_QUIT string = "*1\r\n$4\r\nQUIT\r\n" const REDIS_QUIT string = "*1\r\n$4\r\nQUIT\r\n"
type RedisMatcher struct { type RedisMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
protected bool protected bool
} }
@ -36,7 +36,7 @@ func (r *RedisMatcher) Name() string {
return name return name
} }
func (r *RedisMatcher) Meta() csm.Metadata { func (r *RedisMatcher) Meta() osm.Metadata {
return r.meta return r.meta
} }
@ -48,26 +48,26 @@ func (r *RedisMatcher) HasResponse(index int) bool {
return true return true
} }
func (r *RedisMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (r *RedisMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (r *RedisMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (r *RedisMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
resp := strings.Split(string(packet.Buffer), "\r\n")[0] resp := strings.Split(string(packet.Buffer), "\r\n")[0]
if len(resp) <= 0 { if len(resp) <= 0 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
switch index { switch index {
case 0: case 0:
sign := string([]rune(resp)[0]) sign := string([]rune(resp)[0])
if len(sign) <= 0 { if len(sign) <= 0 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if sign == "+" { if sign == "+" {
@ -99,12 +99,12 @@ func (r *RedisMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet)
} }
return nil return nil
default: default:
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return csm.NotMatchedError() return osm.NotMatchedError()
} }
func (r *RedisMatcher) checkProtectedMode(packet *csm.Packet) bool { func (r *RedisMatcher) checkProtectedMode(packet *osm.Packet) bool {
var ( var (
compareSign = "-" compareSign = "-"
compareMsg = "DENIED" compareMsg = "DENIED"
@ -156,13 +156,13 @@ func (r *RedisMatcher) PacketCount() int {
return 3 return 3
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &RedisMatcher{} m := &RedisMatcher{}
m.meta = csm.NewMetadata() m.meta = osm.NewMetadata()
m.AddPacket(csm.NewPacket([]byte(REDIS_PING), len(REDIS_PING))) m.AddPacket(osm.NewPacket([]byte(REDIS_PING), len(REDIS_PING)))
m.AddPacket(csm.NewPacket([]byte(REDIS_INFO), len(REDIS_INFO))) m.AddPacket(osm.NewPacket([]byte(REDIS_INFO), len(REDIS_INFO)))
m.AddPacket(csm.NewPacket([]byte(REDIS_QUIT), len(REDIS_QUIT))) m.AddPacket(osm.NewPacket([]byte(REDIS_QUIT), len(REDIS_QUIT)))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -26,7 +26,7 @@ func TestRedisMatcher(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -28,7 +28,7 @@ type RMI_RECV_MESSAGE struct {
} }
type RMIMatcher struct { type RMIMatcher struct {
csm.Matchers osm.Matchers
} }
func (r *RMIMatcher) Key() string { func (r *RMIMatcher) Key() string {
@ -39,7 +39,7 @@ func (r *RMIMatcher) Name() string {
return "RMI" return "RMI"
} }
func (r *RMIMatcher) Meta() csm.Metadata { func (r *RMIMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -51,14 +51,14 @@ func (r *RMIMatcher) HasResponse(index int) bool {
return true return true
} }
func (r *RMIMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (r *RMIMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (r *RMIMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (r *RMIMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
rmiRecv := RMI_RECV_MESSAGE{} rmiRecv := RMI_RECV_MESSAGE{}
@ -83,10 +83,10 @@ func (r *RMIMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) er
return nil return nil
} }
return csm.NotMatchedError() return osm.NotMatchedError()
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &RMIMatcher{} m := &RMIMatcher{}
rsm := RMI_SEND_MESSAGE{ rsm := RMI_SEND_MESSAGE{
@ -100,7 +100,7 @@ func NewMatcher() csm.Matcher {
sendByte := mCache.Bytes() sendByte := mCache.Bytes()
m.AddPacket(csm.NewPacket(sendByte, len(sendByte))) m.AddPacket(osm.NewPacket(sendByte, len(sendByte)))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestRMIMatcher_Match(t *testing.T) { func TestRMIMatcher_Match(t *testing.T) {
@ -25,7 +25,7 @@ func TestRMIMatcher_Match(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -5,7 +5,7 @@ import (
"encoding/binary" "encoding/binary"
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -49,7 +49,7 @@ type smb struct {
} }
type SMBMatcher struct { type SMBMatcher struct {
csm.Matchers osm.Matchers
} }
func (t *SMBMatcher) Key() string { func (t *SMBMatcher) Key() string {
@ -60,7 +60,7 @@ func (t *SMBMatcher) Name() string {
return "SMB" return "SMB"
} }
func (t *SMBMatcher) Meta() csm.Metadata { func (t *SMBMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -72,14 +72,14 @@ func (t *SMBMatcher) HasResponse(index int) bool {
return true return true
} }
func (t *SMBMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (t *SMBMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (t *SMBMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (t *SMBMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
reader := new(bytes.Buffer) reader := new(bytes.Buffer)
@ -95,22 +95,22 @@ func (t *SMBMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) er
packetLen := binary.BigEndian.Uint32(des[:]) packetLen := binary.BigEndian.Uint32(des[:])
if packetLen != uint32(packet.Len-4) { if packetLen != uint32(packet.Len-4) {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if !strings.Contains(string(s.Component[:]), "SMB") { if !strings.Contains(string(s.Component[:]), "SMB") {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if s.SmbCommand != SMB_COM_NEGOTIATE { if s.SmbCommand != SMB_COM_NEGOTIATE {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
return nil return nil
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &SMBMatcher{} m := &SMBMatcher{}
@ -160,7 +160,7 @@ func NewMatcher() csm.Matcher {
writer := new(bytes.Buffer) writer := new(bytes.Buffer)
binary.Write(writer, binary.LittleEndian, query) binary.Write(writer, binary.LittleEndian, query)
m.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len())) m.AddPacket(osm.NewPacket(writer.Bytes(), writer.Len()))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -30,7 +30,7 @@ func TestSMBMatcher(t *testing.T) {
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, 0, p); err != nil { if err := m.Match(nil, 0, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -3,11 +3,11 @@ package smtp
import ( import (
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type SmtpMatcher struct { type SmtpMatcher struct {
csm.Matchers osm.Matchers
} }
func (t *SmtpMatcher) Key() string { func (t *SmtpMatcher) Key() string {
@ -26,11 +26,11 @@ func (t *SmtpMatcher) HasResponse(index int) bool {
return true return true
} }
func (t *SmtpMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (t *SmtpMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (t *SmtpMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (t *SmtpMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bool {
if packet == nil { if packet == nil {
return false return false
} }
@ -57,15 +57,15 @@ func (t *SmtpMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) b
return false return false
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &SmtpMatcher{} m := &SmtpMatcher{}
b := []byte("helo test\r\n") b := []byte("helo test\r\n")
m.AddPacket(csm.NewPacket(b, len(b))) m.AddPacket(osm.NewPacket(b, len(b)))
b = []byte("quit\r\n") b = []byte("quit\r\n")
m.AddPacket(csm.NewPacket(b, len(b))) m.AddPacket(osm.NewPacket(b, len(b)))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"encoding/asn1" "encoding/asn1"
"math/rand" "math/rand"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type snmpv2 struct { type snmpv2 struct {
@ -38,9 +38,9 @@ var (
) )
type SNMPMatcher struct { type SNMPMatcher struct {
csm.Matchers osm.Matchers
requestID int32 requestID int32
meta csm.Metadata meta osm.Metadata
} }
func (s *SNMPMatcher) Key() string { func (s *SNMPMatcher) Key() string {
@ -51,7 +51,7 @@ func (s *SNMPMatcher) Name() string {
return "SNMP" return "SNMP"
} }
func (s *SNMPMatcher) Meta() csm.Metadata { func (s *SNMPMatcher) Meta() osm.Metadata {
return s.meta return s.meta
} }
@ -64,10 +64,10 @@ func (s *SNMPMatcher) HasResponse(index int) bool {
return true return true
} }
func (s *SNMPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (s *SNMPMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
var p struct { var p struct {
@ -88,11 +88,11 @@ func (s *SNMPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) e
resp := &response{p.Data.RequestID, p.Data.ErrorStatus, p.Data.ErrorIndex, p.Data.Bindings} resp := &response{p.Data.RequestID, p.Data.ErrorStatus, p.Data.ErrorIndex, p.Data.Bindings}
if s.requestID != resp.ID { if s.requestID != resp.ID {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
if len(resp.Bindings) == 0 { if len(resp.Bindings) == 0 {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
for _, binding := range resp.Bindings { for _, binding := range resp.Bindings {
@ -116,10 +116,10 @@ func (s *SNMPMatcher) IsSend(port int) bool {
return false return false
} }
func NewMatcher() csm.UDPMatcher { func NewMatcher() osm.UDPMatcher {
m := &SNMPMatcher{} m := &SNMPMatcher{}
m.meta = csm.NewMetadata() m.meta = osm.NewMetadata()
m.requestID = rand.Int31() m.requestID = rand.Int31()
@ -139,7 +139,7 @@ func NewMatcher() csm.UDPMatcher {
} }
buf, _ := asn1.Marshal(p) buf, _ := asn1.Marshal(p)
m.AddPacket(csm.NewPacket(buf, len(buf))) m.AddPacket(osm.NewPacket(buf, len(buf)))
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestSNMPv2(t *testing.T) { func TestSNMPv2(t *testing.T) {
@ -23,7 +23,7 @@ func TestSNMPv2(t *testing.T) {
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, 0, p); err != nil { if err := m.Match(nil, 0, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -1,216 +0,0 @@
package v3
import (
"bytes"
"encoding/binary"
csm "git.loafle.net/commons/service_matcher-go"
csms "git.loafle.net/commons/service_matcher-go/snmp"
)
type snmpv3GlobalData struct {
GlobalDataStartSeq uint8
GlobalDataLen uint8
MsgIdType uint8
MsgIdLen uint8
MsgId uint32
MsgMaxSizeType uint8
MsgMaxSizeLen uint8
MsgMaxSize [3]uint8
MsgFlagsType uint8
MsgFlagsTypeLen uint8
MsgFlags uint8
MsgSecurityModelType uint8
MsgSecurityModelLen uint8
MsgSecurityModel uint8
}
type snmpv3MsgData struct {
MsgDataStartSeq uint8
MsgDataLen uint8
ContextEngineId uint16
ContextEngineName uint16
SnmpType uint8
Len uint8
RequestIdType uint8
RequestIdLen uint8
RequestId uint32
ErrorStatusType uint8
ErrorStatusLen uint8
ErrorStatus uint8
ErrorIndexType uint8
ErrorIndexLen uint8
ErrorIndex uint8
EndSeq uint8
EndIndicator uint8
}
type snmpv3 struct {
StartSeq uint8
SeqLen uint8
SNMPVersionType uint8
SNMPVersionLen uint8
SNMPVersion uint8
MsgGlobalData snmpv3GlobalData
Unk1 uint16
Unk2 uint16
MsgAuthoritativeEngineId uint16
MsgAuthoritativeEngineBootsType uint8
MsgAuthoritativeEngineBootsLen uint8
MsgAuthoritativeEngineBoots uint8
MsgAuthoritativeEngineTimeType uint8
MsgAuthoritativeEngineTimeLen uint8
MsgAuthoritativeEngineTime uint8
MsgUserName uint16
MsgAuthenticationParam uint16
MsgPrivacyParam uint16
MsgData snmpv3MsgData
}
type SNMPMatcher struct {
csm.Matchers
}
func (t *SNMPMatcher) Key() string {
return "SNMP_V3"
}
func (t *SNMPMatcher) Meta() map[string]string {
return nil
}
func (t *SNMPMatcher) IsPrePacket() bool {
return false
}
func (t *SNMPMatcher) HasResponse(index int) bool {
return true
}
func (t *SNMPMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool {
return false
}
func (t *SNMPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool {
if packet == nil {
return false
}
reader := new(bytes.Buffer)
reader.Write(packet.Buffer)
s := snmpv3{}
if err := binary.Read(reader, binary.LittleEndian, &s); err != nil {
return false
}
if s.StartSeq != csms.SNMP_START_SEQUENCE {
return false
}
var p uint8
r := new(bytes.Buffer)
r.Write(packet.Buffer)
for {
binary.Read(r, binary.LittleEndian, &p)
if p == csms.SNMP_TYPE_INTEGER {
break
}
}
binary.Read(r, binary.BigEndian, &p)
if p == 0x01 {
binary.Read(r, binary.BigEndian, &p)
if p == 0x03 {
return true
}
}
return false
}
func (t *SNMPMatcher) IsSend(port int) bool {
if 161 == port {
return true
}
return false
}
func NewMatcher() csm.UDPMatcher {
m := &SNMPMatcher{}
snmpTempBuf := new(bytes.Buffer)
binary.Write(snmpTempBuf, binary.BigEndian, snmpv3{}) //For getting the struct size
snmpMsgDataTempBuf := new(bytes.Buffer)
binary.Write(snmpMsgDataTempBuf, binary.BigEndian, snmpv3MsgData{}) //For getting the struct size
snmpGlobalTempBuf := new(bytes.Buffer)
binary.Write(snmpGlobalTempBuf, binary.BigEndian, snmpv3GlobalData{}) //For getting the struct size
q := snmpv3{}
q.StartSeq = csms.SNMP_START_SEQUENCE
q.SeqLen = uint8(len(snmpTempBuf.Bytes())) - 2
q.SNMPVersionType = csms.SNMP_TYPE_INTEGER
q.SNMPVersionLen = 0x01
q.SNMPVersion = csms.SNMP_PROTOCOL_VERSION_3
q.MsgGlobalData.GlobalDataStartSeq = csms.SNMP_START_SEQUENCE
q.MsgGlobalData.GlobalDataLen = uint8(len(snmpGlobalTempBuf.Bytes())) - 2
q.MsgGlobalData.MsgIdType = csms.SNMP_TYPE_INTEGER
q.MsgGlobalData.MsgIdLen = 0x04
q.MsgGlobalData.MsgId = csms.SNMP_MSG_ID_MAX_VALUE
q.MsgGlobalData.MsgMaxSizeType = csms.SNMP_TYPE_INTEGER
q.MsgGlobalData.MsgMaxSizeLen = 0x03
q.MsgGlobalData.MsgMaxSize[2] = 0xe3
q.MsgGlobalData.MsgMaxSize[1] = 0xff
q.MsgGlobalData.MsgMaxSize[0] = 0x00
q.MsgGlobalData.MsgFlagsType = csms.SNMP_TYPE_STRING
q.MsgGlobalData.MsgFlagsTypeLen = 0x01
q.MsgGlobalData.MsgFlags = 0x04
q.MsgGlobalData.MsgSecurityModelType = csms.SNMP_TYPE_INTEGER
q.MsgGlobalData.MsgSecurityModelLen = 0x01
q.MsgGlobalData.MsgSecurityModel = 0x03
q.Unk1 = 0x1004
q.Unk2 = 0x0e30
q.MsgAuthoritativeEngineId = csms.SNMP_NO_DESC
q.MsgAuthoritativeEngineBootsType = csms.SNMP_TYPE_INTEGER
q.MsgAuthoritativeEngineBootsLen = 0x01
q.MsgAuthoritativeEngineBoots = 0x00
q.MsgAuthoritativeEngineTimeType = csms.SNMP_TYPE_INTEGER
q.MsgAuthoritativeEngineTimeLen = 0x01
q.MsgAuthoritativeEngineTime = 0x00
q.MsgUserName = csms.SNMP_NO_DESC
q.MsgAuthenticationParam = csms.SNMP_NO_DESC
q.MsgPrivacyParam = csms.SNMP_NO_DESC
q.MsgData.MsgDataStartSeq = csms.SNMP_START_SEQUENCE
q.MsgData.MsgDataLen = uint8(len(snmpMsgDataTempBuf.Bytes())) - 2
q.MsgData.ContextEngineId = csms.SNMP_NO_DESC
q.MsgData.ContextEngineName = csms.SNMP_NO_DESC
q.MsgData.SnmpType = csms.SNMP_GET_REQUEST
q.MsgData.Len = 0x0E
q.MsgData.RequestIdType = csms.SNMP_TYPE_INTEGER
q.MsgData.RequestIdLen = 0x04
q.MsgData.RequestId = 0x00 //
q.MsgData.ErrorStatusType = csms.SNMP_TYPE_INTEGER
q.MsgData.ErrorStatusLen = 0x01
q.MsgData.ErrorStatus = 0x00
q.MsgData.ErrorIndexType = csms.SNMP_TYPE_INTEGER
q.MsgData.ErrorIndexLen = 0x01
q.MsgData.ErrorIndex = 0x00
q.MsgData.EndSeq = csms.SNMP_END_SEQUENCE
q.MsgData.EndIndicator = 0x00
writer := new(bytes.Buffer)
binary.Write(writer, binary.LittleEndian, q)
m.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len()))
return m
}

View File

@ -1,216 +0,0 @@
package v3
import (
"bytes"
"encoding/binary"
csm "git.loafle.net/commons/service_matcher-go"
csms "git.loafle.net/commons/service_matcher-go/snmp"
)
type snmpv3GlobalData struct {
GlobalDataStartSeq uint8
GlobalDataLen uint8
MsgIdType uint8
MsgIdLen uint8
MsgId uint32
MsgMaxSizeType uint8
MsgMaxSizeLen uint8
MsgMaxSize [3]uint8
MsgFlagsType uint8
MsgFlagsTypeLen uint8
MsgFlags uint8
MsgSecurityModelType uint8
MsgSecurityModelLen uint8
MsgSecurityModel uint8
}
type snmpv3MsgData struct {
MsgDataStartSeq uint8
MsgDataLen uint8
ContextEngineId uint16
ContextEngineName uint16
SnmpType uint8
Len uint8
RequestIdType uint8
RequestIdLen uint8
RequestId uint32
ErrorStatusType uint8
ErrorStatusLen uint8
ErrorStatus uint8
ErrorIndexType uint8
ErrorIndexLen uint8
ErrorIndex uint8
EndSeq uint8
EndIndicator uint8
}
type snmpv3 struct {
StartSeq uint8
SeqLen uint8
SNMPVersionType uint8
SNMPVersionLen uint8
SNMPVersion uint8
MsgGlobalData snmpv3GlobalData
Unk1 uint16
Unk2 uint16
MsgAuthoritativeEngineId uint16
MsgAuthoritativeEngineBootsType uint8
MsgAuthoritativeEngineBootsLen uint8
MsgAuthoritativeEngineBoots uint8
MsgAuthoritativeEngineTimeType uint8
MsgAuthoritativeEngineTimeLen uint8
MsgAuthoritativeEngineTime uint8
MsgUserName uint16
MsgAuthenticationParam uint16
MsgPrivacyParam uint16
MsgData snmpv3MsgData
}
type SNMPMatcher struct {
csm.Matchers
}
func (t *SNMPMatcher) Key() string {
return "SNMP_V3"
}
func (t *SNMPMatcher) Meta() map[string]string {
return nil
}
func (t *SNMPMatcher) IsPrePacket() bool {
return false
}
func (t *SNMPMatcher) HasResponse(index int) bool {
return true
}
func (t *SNMPMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool {
return false
}
func (t *SNMPMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool {
if packet == nil {
return false
}
reader := new(bytes.Buffer)
reader.Write(packet.Buffer)
s := snmpv3{}
if err := binary.Read(reader, binary.LittleEndian, &s); err != nil {
return false
}
if s.StartSeq != csms.SNMP_START_SEQUENCE {
return false
}
var p uint8
r := new(bytes.Buffer)
r.Write(packet.Buffer)
for {
binary.Read(r, binary.LittleEndian, &p)
if p == csms.SNMP_TYPE_INTEGER {
break
}
}
binary.Read(r, binary.BigEndian, &p)
if p == 0x01 {
binary.Read(r, binary.BigEndian, &p)
if p == 0x03 {
return true
}
}
return false
}
func (t *SNMPMatcher) IsSend(port int) bool {
if 161 == port {
return true
}
return false
}
func NewMatcher() csm.UDPMatcher {
m := &SNMPMatcher{}
snmpTempBuf := new(bytes.Buffer)
binary.Write(snmpTempBuf, binary.BigEndian, snmpv3{}) //For getting the struct size
snmpMsgDataTempBuf := new(bytes.Buffer)
binary.Write(snmpMsgDataTempBuf, binary.BigEndian, snmpv3MsgData{}) //For getting the struct size
snmpGlobalTempBuf := new(bytes.Buffer)
binary.Write(snmpGlobalTempBuf, binary.BigEndian, snmpv3GlobalData{}) //For getting the struct size
q := snmpv3{}
q.StartSeq = csms.SNMP_START_SEQUENCE
q.SeqLen = uint8(len(snmpTempBuf.Bytes())) - 2
q.SNMPVersionType = csms.SNMP_TYPE_INTEGER
q.SNMPVersionLen = 0x01
q.SNMPVersion = csms.SNMP_PROTOCOL_VERSION_3
q.MsgGlobalData.GlobalDataStartSeq = csms.SNMP_START_SEQUENCE
q.MsgGlobalData.GlobalDataLen = uint8(len(snmpGlobalTempBuf.Bytes())) - 2
q.MsgGlobalData.MsgIdType = csms.SNMP_TYPE_INTEGER
q.MsgGlobalData.MsgIdLen = 0x04
q.MsgGlobalData.MsgId = csms.SNMP_MSG_ID_MAX_VALUE
q.MsgGlobalData.MsgMaxSizeType = csms.SNMP_TYPE_INTEGER
q.MsgGlobalData.MsgMaxSizeLen = 0x03
q.MsgGlobalData.MsgMaxSize[2] = 0xe3
q.MsgGlobalData.MsgMaxSize[1] = 0xff
q.MsgGlobalData.MsgMaxSize[0] = 0x00
q.MsgGlobalData.MsgFlagsType = csms.SNMP_TYPE_STRING
q.MsgGlobalData.MsgFlagsTypeLen = 0x01
q.MsgGlobalData.MsgFlags = 0x04
q.MsgGlobalData.MsgSecurityModelType = csms.SNMP_TYPE_INTEGER
q.MsgGlobalData.MsgSecurityModelLen = 0x01
q.MsgGlobalData.MsgSecurityModel = 0x03
q.Unk1 = 0x1004
q.Unk2 = 0x0e30
q.MsgAuthoritativeEngineId = csms.SNMP_NO_DESC
q.MsgAuthoritativeEngineBootsType = csms.SNMP_TYPE_INTEGER
q.MsgAuthoritativeEngineBootsLen = 0x01
q.MsgAuthoritativeEngineBoots = 0x00
q.MsgAuthoritativeEngineTimeType = csms.SNMP_TYPE_INTEGER
q.MsgAuthoritativeEngineTimeLen = 0x01
q.MsgAuthoritativeEngineTime = 0x00
q.MsgUserName = csms.SNMP_NO_DESC
q.MsgAuthenticationParam = csms.SNMP_NO_DESC
q.MsgPrivacyParam = csms.SNMP_NO_DESC
q.MsgData.MsgDataStartSeq = csms.SNMP_START_SEQUENCE
q.MsgData.MsgDataLen = uint8(len(snmpMsgDataTempBuf.Bytes())) - 2
q.MsgData.ContextEngineId = csms.SNMP_NO_DESC
q.MsgData.ContextEngineName = csms.SNMP_NO_DESC
q.MsgData.SnmpType = csms.SNMP_GET_REQUEST
q.MsgData.Len = 0x0E
q.MsgData.RequestIdType = csms.SNMP_TYPE_INTEGER
q.MsgData.RequestIdLen = 0x04
q.MsgData.RequestId = 0x00 //
q.MsgData.ErrorStatusType = csms.SNMP_TYPE_INTEGER
q.MsgData.ErrorStatusLen = 0x01
q.MsgData.ErrorStatus = 0x00
q.MsgData.ErrorIndexType = csms.SNMP_TYPE_INTEGER
q.MsgData.ErrorIndexLen = 0x01
q.MsgData.ErrorIndex = 0x00
q.MsgData.EndSeq = csms.SNMP_END_SEQUENCE
q.MsgData.EndIndicator = 0x00
writer := new(bytes.Buffer)
binary.Write(writer, binary.LittleEndian, q)
m.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len()))
return m
}

View File

@ -1,37 +0,0 @@
package v3
import (
"net"
"testing"
csm "git.loafle.net/commons/service_matcher-go"
)
func TestSNMP3(t *testing.T) {
m := NewMatcher()
conn, err := net.Dial("udp", "192.168.1.204:161")
if err != nil {
t.Error(err)
return
}
defer conn.Close()
for i := 0; i < m.PacketCount(); i++ {
pack := m.Packet(i)
conn.Write(pack.Buffer)
bytes := make([]byte, 1024)
n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n)
if m.Match(nil, i, p) {
t.Log("SNMP found")
return
}
t.Error("SNMP not found")
}
}

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -64,7 +64,7 @@ type mssqlResponse struct {
} }
type SQLServerMatcher struct { type SQLServerMatcher struct {
csm.Matchers osm.Matchers
isSSL bool isSSL bool
} }
@ -87,11 +87,11 @@ func (t *SQLServerMatcher) HasResponse(index int) bool {
return true return true
} }
func (t *SQLServerMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (t *SQLServerMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (t *SQLServerMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (t *SQLServerMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bool {
if packet == nil { if packet == nil {
return false return false
@ -133,7 +133,7 @@ func (t *SQLServerMatcher) Match(info csm.MatchInfo, index int, packet *csm.Pack
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
mm := &SQLServerMatcher{} mm := &SQLServerMatcher{}
@ -164,7 +164,7 @@ func NewMatcher() csm.Matcher {
writer := new(bytes.Buffer) writer := new(bytes.Buffer)
binary.Write(writer, binary.BigEndian, m) binary.Write(writer, binary.BigEndian, m)
mm.AddPacket(csm.NewPacket(writer.Bytes(), writer.Len())) mm.AddPacket(osm.NewPacket(writer.Bytes(), writer.Len()))
return mm return mm
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
/* /*
@ -51,7 +51,7 @@ func sqlServerRun(conn net.Conn, t *testing.T) {
conn.Write(pack.Buffer) conn.Write(pack.Buffer)
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if m.Match(nil, i, p) { if m.Match(nil, i, p) {
t.Log(m.Key()) t.Log(m.Key())

View File

@ -5,12 +5,12 @@ import (
"bytes" "bytes"
"strings" "strings"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
type SSHMatcher struct { type SSHMatcher struct {
csm.Matchers osm.Matchers
meta csm.Metadata meta osm.Metadata
} }
func (ssh *SSHMatcher) Key() string { func (ssh *SSHMatcher) Key() string {
@ -25,7 +25,7 @@ func (ssh *SSHMatcher) Name() string {
return name return name
} }
func (ssh *SSHMatcher) Meta() csm.Metadata { func (ssh *SSHMatcher) Meta() osm.Metadata {
return ssh.meta return ssh.meta
} }
@ -37,14 +37,14 @@ func (ssh *SSHMatcher) HasResponse(index int) bool {
return true return true
} }
func (ssh *SSHMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (ssh *SSHMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (ssh *SSHMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (ssh *SSHMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
// SSH-protoversion-softwareversion SP comments CR LF // SSH-protoversion-softwareversion SP comments CR LF
@ -54,7 +54,7 @@ func (ssh *SSHMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet)
exchange := scanner.Text() exchange := scanner.Text()
if !strings.HasPrefix(exchange, "SSH") { if !strings.HasPrefix(exchange, "SSH") {
return csm.NotMatchedError() return osm.NotMatchedError()
} }
temp := strings.Split(exchange, " ") temp := strings.Split(exchange, " ")
@ -75,11 +75,11 @@ func (ssh *SSHMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet)
break break
} }
return csm.NotMatchedError() return osm.NotMatchedError()
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &SSHMatcher{} m := &SSHMatcher{}
m.meta = csm.NewMetadata() m.meta = osm.NewMetadata()
return m return m
} }

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestSSH(t *testing.T) { func TestSSH(t *testing.T) {
@ -25,7 +25,7 @@ func TestSSH(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -1,7 +1,7 @@
package telnet package telnet
import ( import (
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -13,7 +13,7 @@ const (
) )
type TelnetMatcher struct { type TelnetMatcher struct {
csm.Matchers osm.Matchers
} }
func (tel *TelnetMatcher) Key() string { func (tel *TelnetMatcher) Key() string {
@ -24,7 +24,7 @@ func (tel *TelnetMatcher) Name() string {
return "Telnet" return "Telnet"
} }
func (tel *TelnetMatcher) Meta() csm.Metadata { func (tel *TelnetMatcher) Meta() osm.Metadata {
return nil return nil
} }
@ -36,14 +36,14 @@ func (tel *TelnetMatcher) HasResponse(index int) bool {
return true return true
} }
func (tel *TelnetMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (tel *TelnetMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (tel *TelnetMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) error { func (tel *TelnetMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
if packet == nil || packet.Buffer == nil || packet.Len == 0 { if packet == nil || packet.Buffer == nil || packet.Len == 0 {
return csm.NoPacketReceivedError() return osm.NoPacketReceivedError()
} }
buf := make([]byte, 0, 0) buf := make([]byte, 0, 0)
@ -65,13 +65,13 @@ func (tel *TelnetMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packe
} }
} }
return csm.NotMatchedError() return osm.NotMatchedError()
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &TelnetMatcher{} m := &TelnetMatcher{}
m.AddPacket(csm.NewPacket([]byte{CMD, DO, 37}, 3)) m.AddPacket(osm.NewPacket([]byte{CMD, DO, 37}, 3))
return m return m
} }

View File

@ -1,7 +1,7 @@
package telnet package telnet
import ( import (
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
"net" "net"
"testing" "testing"
@ -25,7 +25,7 @@ func TestTelnetMatcher_Match(t *testing.T) {
} }
bytes := make([]byte, 1024) bytes := make([]byte, 1024)
n, _ := conn.Read(bytes) n, _ := conn.Read(bytes)
p := csm.NewPacket(bytes, n) p := osm.NewPacket(bytes, n)
if err := m.Match(nil, i, p); err != nil { if err := m.Match(nil, i, p); err != nil {
t.Error(err) t.Error(err)

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
const ( const (
@ -18,7 +18,7 @@ const (
) )
type WMIMatcher struct { type WMIMatcher struct {
csm.Matchers osm.Matchers
} }
func (w *WMIMatcher) Key() string { func (w *WMIMatcher) Key() string {
@ -37,11 +37,11 @@ func (w *WMIMatcher) HasResponse(index int) bool {
return true return true
} }
func (w *WMIMatcher) IsError(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (w *WMIMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool {
return false return false
} }
func (w *WMIMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bool { func (w *WMIMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bool {
if packet == nil { if packet == nil {
return false return false
@ -81,7 +81,7 @@ func (w *WMIMatcher) Match(info csm.MatchInfo, index int, packet *csm.Packet) bo
return false return false
} }
func NewMatcher() csm.Matcher { func NewMatcher() osm.Matcher {
m := &WMIMatcher{} m := &WMIMatcher{}
@ -205,8 +205,8 @@ func NewMatcher() csm.Matcher {
copy(secondByte[0:], ds2Bytes) copy(secondByte[0:], ds2Bytes)
copy(secondByte[len(ds2Bytes):], daBytes) copy(secondByte[len(ds2Bytes):], daBytes)
m.AddPacket(csm.NewPacket(firstByte, len(ds1Bytes)+len(ioxidrBytes))) m.AddPacket(osm.NewPacket(firstByte, len(ds1Bytes)+len(ioxidrBytes)))
m.AddPacket(csm.NewPacket(secondByte, len(ds2Bytes)+len(daBytes))) m.AddPacket(osm.NewPacket(secondByte, len(ds2Bytes)+len(daBytes)))
return m return m

View File

@ -5,7 +5,7 @@ import (
"net" "net"
"testing" "testing"
csm "git.loafle.net/commons/service_matcher-go" osm "git.loafle.net/overflow/service_matcher-go"
) )
func TestWMI(t *testing.T) { func TestWMI(t *testing.T) {
@ -38,7 +38,7 @@ func TestWMI(t *testing.T) {
//fmt.Println(bytes) //fmt.Println(bytes)
b := lm.Match(nil, ii, csm.NewPacket(bytes, read)) b := lm.Match(nil, ii, osm.NewPacket(bytes, read))
if b { if b {
fmt.Println("Good") fmt.Println("Good")