mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-14 05:12:36 +08:00
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package Plugins
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/shadow1ng/fscan/Common"
|
|
"github.com/shadow1ng/fscan/Config"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
func MemcachedScan(info *Config.HostInfo) (err error) {
|
|
realhost := fmt.Sprintf("%s:%v", info.Host, info.Ports)
|
|
client, err := Common.WrapperTcpWithTimeout("tcp", realhost, time.Duration(Common.Timeout)*time.Second)
|
|
defer func() {
|
|
if client != nil {
|
|
client.Close()
|
|
}
|
|
}()
|
|
if err == nil {
|
|
err = client.SetDeadline(time.Now().Add(time.Duration(Common.Timeout) * time.Second))
|
|
if err == nil {
|
|
_, err = client.Write([]byte("stats\n")) //Set the key randomly to prevent the key on the server from being overwritten
|
|
if err == nil {
|
|
rev := make([]byte, 1024)
|
|
n, err := client.Read(rev)
|
|
if err == nil {
|
|
if strings.Contains(string(rev[:n]), "STAT") {
|
|
result := fmt.Sprintf("[+] Memcached %s unauthorized", realhost)
|
|
Common.LogSuccess(result)
|
|
}
|
|
} else {
|
|
errlog := fmt.Sprintf("[-] Memcached %v:%v %v", info.Host, info.Ports, err)
|
|
Common.LogError(errlog)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return err
|
|
}
|