2021-10-08 13:20:19 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.ddd.rip/ptrcnull/debil-finder/checks"
|
|
|
|
"git.ddd.rip/ptrcnull/telegram"
|
|
|
|
"github.com/CaliDog/certstream-go"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
tg := telegram.Client{Token: os.Getenv("TELEGRAM_TOKEN")}
|
|
|
|
chatId := os.Getenv("TELEGRAM_CHAT_ID")
|
|
|
|
|
|
|
|
res, err := tg.SendMessage(chatId, "Starting...")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
log.Println(res)
|
|
|
|
|
|
|
|
c := &checks.Checks{
|
|
|
|
Message: func(msg string) {
|
|
|
|
tg.SendMessage(chatId, msg)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-10-08 13:52:12 +00:00
|
|
|
recent := make([]string, 20)
|
|
|
|
for i := range recent {
|
|
|
|
recent[i] = ""
|
|
|
|
}
|
|
|
|
|
2021-10-08 13:20:19 +00:00
|
|
|
stream, errStream := certstream.CertStreamEventStream(false)
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case jq := <-stream:
|
|
|
|
messageType, err := jq.String("message_type")
|
|
|
|
if err != nil {
|
|
|
|
tg.SendMessage(chatId, "failed decoding message: " + err.Error())
|
|
|
|
}
|
|
|
|
if messageType != "certificate_update" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
allDomains, err := jq.ArrayOfStrings("data", "leaf_cert", "all_domains")
|
|
|
|
if err != nil {
|
|
|
|
tg.SendMessage(chatId, "failed getting domains: " + err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
polish := false
|
|
|
|
ndc := false
|
|
|
|
for _, domain := range allDomains {
|
|
|
|
if strings.HasSuffix(domain, ".pl") {
|
|
|
|
polish = true
|
|
|
|
}
|
|
|
|
if strings.HasSuffix(domain, "ndc.pl") {
|
|
|
|
ndc = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !polish {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if ndc {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println(allDomains)
|
|
|
|
for _, domain := range allDomains {
|
|
|
|
if domain[0] == '*' || domain == "sni.cloudflaressl.com" {
|
|
|
|
continue
|
|
|
|
}
|
2021-10-08 13:52:12 +00:00
|
|
|
|
|
|
|
// skip if was checked recently
|
|
|
|
skip := false
|
|
|
|
for _, recentDomain := range recent {
|
|
|
|
if domain == recentDomain {
|
|
|
|
skip = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if skip {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2021-10-08 13:20:19 +00:00
|
|
|
log.Println("checking " + domain)
|
|
|
|
go c.CheckGit(domain)
|
|
|
|
go c.CheckEnv(domain)
|
|
|
|
go c.CheckIndex(domain)
|
2021-10-08 13:52:12 +00:00
|
|
|
|
|
|
|
recent = append(recent[1:], domain)
|
2021-10-08 13:20:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case err := <-errStream:
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|