-
Notifications
You must be signed in to change notification settings - Fork 20
/
main.go
45 lines (35 loc) · 975 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"flag"
"log"
"regexp"
"github.com/Adikso/minecraft-log4j-honeypot/extractor"
"github.com/Adikso/minecraft-log4j-honeypot/minecraft"
)
func Analyse(text string) {
log.Printf("Testing text: %s\n", text)
pattern := regexp.MustCompile(`\${jndi:(.*)}`)
finder := extractor.NewFinder(pattern)
injections := finder.FindInjections(text)
for _, url := range injections {
log.Printf("Fetching payload for: jndi:%s", url.String())
files, err := extractor.FetchFromLdap(url)
if err != nil {
log.Printf("Failed to fetch class from %s", url)
continue
}
for _, filename := range files {
log.Printf("Saved payload to file %s\n", filename)
}
}
}
func main() {
address := flag.String("h", ":25565", "Minecraft server binding address")
flag.Parse()
server := minecraft.NewServer(*address)
server.ChatMessageCallback = Analyse
server.AcceptLoginCallback = Analyse
if err := server.Run(); err != nil {
log.Println(err)
}
}