2017-04-10 11:14:12 +00:00
|
|
|
package pop
|
|
|
|
|
|
|
|
import (
|
2017-05-29 10:52:11 +00:00
|
|
|
"git.loafle.net/overflow/commons_go/matcher/packet"
|
|
|
|
"git.loafle.net/overflow/commons_go/model/scaninfo"
|
2017-04-10 11:14:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
COMPARE_STR = "+OK"
|
|
|
|
)
|
|
|
|
|
|
|
|
type POPMatcher struct {
|
|
|
|
sendPackets []*packet.Packet
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *POPMatcher) Match(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) bool {
|
|
|
|
|
|
|
|
switch index {
|
|
|
|
case 0:
|
|
|
|
fallthrough
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
recvStr := string(packet.Buffer)
|
|
|
|
|
|
|
|
if len(recvStr) < 3 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
compareStr := recvStr[0:3]
|
|
|
|
|
|
|
|
if compareStr == COMPARE_STR {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *POPMatcher) PacketCount() int {
|
|
|
|
return len(p.sendPackets)
|
|
|
|
}
|
|
|
|
func (p *POPMatcher) Packet(index int) *packet.Packet {
|
|
|
|
return p.sendPackets[index]
|
|
|
|
}
|
|
|
|
func (p *POPMatcher) ServiceName() string {
|
|
|
|
return "POPMatcher"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *POPMatcher) IsError(index int, packet *packet.Packet, info scaninfo.ServiceScanInfo) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
func (p *POPMatcher) IsNoResponse(index int) bool {
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *POPMatcher) IsPrePacket() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPOPMatcher() *POPMatcher {
|
|
|
|
|
|
|
|
pm := POPMatcher{}
|
|
|
|
|
|
|
|
reqStr := "QUIT\r\n"
|
|
|
|
byte := make([]byte, len(reqStr))
|
|
|
|
copy(byte[:], reqStr)
|
|
|
|
pm.sendPackets = append(pm.sendPackets, packet.NewPacket(byte, len(reqStr)))
|
|
|
|
|
|
|
|
return &pm
|
|
|
|
|
|
|
|
}
|