This commit is contained in:
crusader
2017-12-04 16:27:08 +09:00
commit ac4d422cd9
61 changed files with 5573 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
package protected
import (
cnsm "git.loafle.net/commons_go/network_service_matcher"
)
const (
COMPARE_STR_1 = "-"
COMPARE_STR_2 = "DENIED"
)
type RedisProtectedMatcher struct {
cnsm.Matchers
}
func (r *RedisProtectedMatcher) ServiceName() string {
return "Redis:Protected"
}
func (r *RedisProtectedMatcher) IsPrePacket() bool {
return true
}
func (r *RedisProtectedMatcher) HasResponse(index int) bool {
return true
}
func (r *RedisProtectedMatcher) IsError(info cnsm.MatchInfo, index int, packet *cnsm.Packet) bool {
return false
}
func (r *RedisProtectedMatcher) Match(info cnsm.MatchInfo, index int, packet *cnsm.Packet) bool {
if packet == nil {
return false
}
switch index {
case 0:
str := string(packet.Buffer[:packet.Len])
if str == "" {
return false
}
if len(str) <= 0 {
return false
}
firstCompare := str[0:1]
seconcdCompare := str[1 : len(COMPARE_STR_2)+1]
if firstCompare != COMPARE_STR_1 {
return false
}
if seconcdCompare != COMPARE_STR_2 {
return false
}
return true
}
return false
}
func NewMatcher() cnsm.Matcher {
m := &RedisProtectedMatcher{}
return m
}

View File

@@ -0,0 +1,33 @@
package protected
//import (
// "git.loafle.net/overflow/overflow_discovery/collector/core/scan/service/matcher/packet"
// "net"
// "testing"
//)
//
//func TestRedisProtected(t *testing.T) {
//
// m := NewRedisProtectedMatcher()
//
// conn, err := net.Dial("tcp", "192.168.1.215:8379")
//
// if err != nil {
// t.Log(err)
// return
// }
//
// defer conn.Close()
//
// bytes := make([]byte, 1024)
// n, _ := conn.Read(bytes)
//
// //fmt.Println(string(bytes[:n]))
//
// b := m.Match(0, matcher.NewPacket(bytes, n), nil)
//
// if b {
// t.Log("good!")
// }
//
//}