malscan/malscan.go

43 lines
991 B
Go
Raw Permalink Normal View History

2023-04-06 08:27:37 +00:00
package main
import (
"fmt"
"log"
2023-04-06 08:27:37 +00:00
)
2023-04-06 09:35:59 +00:00
func banner() {
fmt.Println(" _ \n _ __ ___ __ _| |___ ___ __ _ _ __ \n| '_ ` _ \\ / _` | / __|/ __/ _` | '_ \\ \n| | | | | | (_| | \\__ \\ (_| (_| | | | |\n|_| |_| |_|\\__,_|_|___/\\___\\__,_|_| |_|\n ")
fmt.Println("malscan v0.1 microservice")
fmt.Println("")
}
2023-04-07 12:22:47 +00:00
func sanity_check() (bool, int) {
vName, error, sigNo := scan_data([]byte("X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"))
if error != nil && vName == "" {
panic(error)
}
if vName == "Win.Test.EICAR_HDB-1" {
2023-04-07 12:22:47 +00:00
return true, sigNo
}
2023-04-07 12:22:47 +00:00
return false, 0
}
2023-04-06 08:27:37 +00:00
func main() {
2023-04-06 09:35:59 +00:00
banner()
// start freshclam goroutine
go freshclam_update()
log.Println("Carrying out sanity checks...")
2023-04-07 12:22:47 +00:00
scannerIsSane, _ := sanity_check()
if !scannerIsSane {
log.Println("Sanity check failed!")
return
2023-04-06 08:27:37 +00:00
}
log.Println("Sanity check passed! Continuing startup...")
2023-04-06 09:35:59 +00:00
2023-04-07 11:57:58 +00:00
// start API
start_api()
2023-04-06 08:27:37 +00:00
}