first probe

This commit is contained in:
snoop
2017-08-03 19:08:34 +09:00
commit fe424d070d
263 changed files with 19925 additions and 0 deletions

76
matcher/redis/redis.go Normal file
View File

@@ -0,0 +1,76 @@
package redis
import (
"git.loafle.net/overflow/commons_go/matcher/packet"
"git.loafle.net/overflow/commons_go/model/scaninfo"
"strings"
)
const REDIS_PING string = "*1\r\n$4\r\nping\r\n"
type RedisMatcher struct {
packets []*packet.Packet
}
func NewRedisMatcher() *RedisMatcher {
redisMatcher := &RedisMatcher{}
redisMatcher.packets = append(redisMatcher.packets, packet.NewPacket([]byte(REDIS_PING), len(REDIS_PING)))
return redisMatcher
}
func (t *RedisMatcher) ServiceName() string {
return "Redis"
}
func (t *RedisMatcher) PacketCount() int {
return len(t.packets)
}
func (t *RedisMatcher) Packet(index int) *packet.Packet {
return t.packets[index]
}
func (t *RedisMatcher) IsError(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) bool {
return false
}
func (t *RedisMatcher) IsNoResponse(index int) bool {
return false
}
func (t *RedisMatcher) IsPrePacket() bool {
return false
}
func (t *RedisMatcher) Match(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) bool {
if packet == nil {
return false
}
resp := strings.Split(string(packet.Buffer), "\r\n")[0]
if len(resp) <= 0 {
return false
}
sign := string([]rune(resp)[0])
if len(sign) <= 0 {
return false
}
if sign == "+" {
if resp == "+PONG" || resp == "+OK" {
return true
}
}
if sign == "-" {
if resp == "-NOAUTH" || resp == "-ERR" {
return true
}
}
return false
}

View File

@@ -0,0 +1,78 @@
package redis
import (
"git.loafle.net/overflow/commons_go/matcher/packet"
"git.loafle.net/overflow/commons_go/model/scaninfo"
)
const (
COMPARE_STR_1 = "-"
COMPARE_STR_2 = "DENIED"
)
type RedisProtectedMatcher struct {
}
func NewRedisProtectedMatcher() *RedisProtectedMatcher {
redisMatcher := &RedisProtectedMatcher{}
return redisMatcher
}
func (r *RedisProtectedMatcher) ServiceName() string {
return "RedisProtectedMatcher"
}
func (r *RedisProtectedMatcher) PacketCount() int {
return 0
}
func (r *RedisProtectedMatcher) Packet(index int) *packet.Packet {
return nil
}
func (r *RedisProtectedMatcher) IsError(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) bool {
return false
}
func (r *RedisProtectedMatcher) IsNoResponse(index int) bool {
return false
}
func (r *RedisProtectedMatcher) IsPrePacket() bool {
return true
}
func (r *RedisProtectedMatcher) Match(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) 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
}

View File

@@ -0,0 +1,33 @@
package redis
//import (
// "loafle.com/overflow/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, packet.NewPacket(bytes, n), nil)
//
// if b {
// t.Log("good!")
// }
//
//}

View File

@@ -0,0 +1,38 @@
package redis
//
//import (
// "loafle.com/overflow/collector/core/scan/service/matcher/packet"
// "net"
// "testing"
//)
//
//const (
// ADDR string = "192.168.1.215:6379"
//)
//
//func TestRedisMatcher(t *testing.T) {
//
// m := NewRedisMatcher()
//
// conn, _ := net.Dial("tcp", ADDR)
// 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 := packet.NewPacket(bytes, n)
//
// if m.Match(i, p, nil) {
// t.Log("Redis found.")
// return
// }
//
// t.Error("Redis not found")
// }
//
//}