go-shield/handlers/license.go

98 lines
63 KiB
Go
Raw Normal View History

2024-02-16 23:37:45 +02:00
package handlers
import (
"bufio"
"encoding/base64"
"github.com/techoner/gophp"
"os"
"strings"
)
func GetArticaGoldLicense() bool {
//Check Gold License
gold, _ := os.Open("/usr/local/share/artica/.GOLD")
defer gold.Close()
scannerGold := bufio.NewScanner(gold)
for scannerGold.Scan() {
fdata := strings.TrimSpace(scannerGold.Text())
if len(fdata) == 0 {
return false
}
if fdata == "TRUE" {
return true
}
str := "YTo2MDU6e3M6Mjc6IjJPWlRBWi1INU9HRzItWEQyRFJBLVlNN0lOWSI7YjoxO3M6Mjc6IldVRkhUNi1aT1VYTDktU00xWFFSLU9RTUVVQSI7YjoxO3M6Mjc6IktBRVFFMi1ZRUROUzEtSU5TSU9YLUJYNVdLNCI7YjoxO3M6Mjc6IlBQUEFUSi0ySDlWUkEtQTFMVktGLTlKTVZNMiI7YjoxO3M6Mjc6Ik9PVUk5TS1DN0RFUEEtSEdDRzFELUw2NEhKSSI7YjoxO3M6Mjc6IkNFUExGQi1GTjVMMTMtWFFVM1NBLVVWTEpLSiI7YjoxO3M6Mjc6Ik41NVlIUi1MQUYwQ1QtM0lWSlY5LTM5WllJQyI7YjoxO3M6Mjc6IkIxSklPSy1HWFNMUVMtRUFaMVhHLUxZOFNFUyI7YjoxO3M6Mjc6Ik9IVDZQVS00UElFUFgtOUZDTkJJLTlTREVWRiI7YjoxO3M6Mjc6Ikk5WEE2RC0yTk5BRjItNk1VQ0pPLTU5UFA4TCI7YjoxO3M6Mjc6IkU0TENXWi1WQlRKUVotTkFLWE5TLVNRT1JQMiI7YjoxO3M6Mjc6IlBaWE5LVS1VMkREQ1ktTUZPM0ZVLVFSRzhHTiI7YjoxO3M6Mjc6IlFETDVPRS0yMEhVOVctSlkyV05GLVpFR0JGRiI7YjoxO3M6Mjc6IlRBUk9EQS1TSkdRM0stR1lNRjBULThaSTlPVyI7YjoxO3M6Mjc6IlFBMUJBSy1YRFNWWFItWV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0LU1XQ0ZZQyI7YjoxO3M6Mjc6IjlZQUk0Ri1XSUIxMUYtUFBTRENDLVM4N0dEOCI7YjoxO3M6Mjc6IlRIVkZWTS1BS1JXTk4tQkpQME1WLVpQWUVTMCI7YjoxO3M6Mjc6Ik9YRUM1Vi01S1NNRFQtWUpUVTA5LUpRUTcyRiI7YjoxO3M6Mjc6IlU4VFFPVS1ZQjFZM0otVUxSVVNDLVhWSVpCWSI7YjoxO3M6Mjc6IkVRTk9UNC1KS
base64decoded, _ := base64.StdEncoding.DecodeString(str)
out, _ := gophp.Unserialize([]byte(base64decoded))
if mout, ok := out.(map[string]interface{}); ok {
if _, ok := mout[fdata].(map[string]interface{}); ok {
return true
}
return false
}
}
return false
}
func GetArticaLicense() bool {
//Check Gold License
gold, _ := os.Open("/usr/local/share/artica/.GOLD")
defer gold.Close()
scannerGold := bufio.NewScanner(gold)
for scannerGold.Scan() {
fdata := strings.TrimSpace(scannerGold.Text())
if len(fdata) == 0 {
return false
}
if fdata == "TRUE" {
return true
}
str := "YTo2MDU6e3M6Mjc6IjJPWlRBWi1INU9HRzItWEQyRFJBLVlNN0lOWSI7YjoxO3M6Mjc6IldVRkhUNi1aT1VYTDktU00xWFFSLU9RTUVVQSI7YjoxO3M6Mjc6IktBRVFFMi1ZRUROUzEtSU5TSU9YLUJYNVdLNCI7YjoxO3M6Mjc6IlBQUEFUSi0ySDlWUkEtQTFMVktGLTlKTVZNMiI7YjoxO3M6Mjc6Ik9PVUk5TS1DN0RFUEEtSEdDRzFELUw2NEhKSSI7YjoxO3M6Mjc6IkNFUExGQi1GTjVMMTMtWFFVM1NBLVVWTEpLSiI7YjoxO3M6Mjc6Ik41NVlIUi1MQUYwQ1QtM0lWSlY5LTM5WllJQyI7YjoxO3M6Mjc6IkIxSklPSy1HWFNMUVMtRUFaMVhHLUxZOFNFUyI7YjoxO3M6Mjc6Ik9IVDZQVS00UElFUFgtOUZDTkJJLTlTREVWRiI7YjoxO3M6Mjc6Ikk5WEE2R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TDktR1JWMlYwLVNIMkdaWSI7YjoxO3M6Mjc6IkFZSkM5TC1DT0lKRlItUElFWUpJLVcxVUxFUiI7YjoxO3M6Mjc6IkhXV0hKMS1WREZIUkYtTTJRUU1XLTNUU1ZHVSI7YjoxO3M6Mjc6Ikw5UUhPVS01OTU1OUwtTVhaWVc0LVpLUEpaTiI7YjoxO3M6Mjc6IldXQVhaTS1KM0oyTVEtMlI3SENJLTBDWkpPSyI7YjoxO3M6Mjc6IkRHWU1DMC0wR0dVRkctN0RPQVE0LU1XQ0ZZQyI7YjoxO3M6Mjc6IjlZQUk0Ri1XSUIxMUYtUFBTRENDLVM4N0dEOCI7YjoxO3M6Mjc6IlRIVkZWTS1BS1JXTk4tQkpQME1WLVpQWUVTMCI7YjoxO3M6Mjc6Ik9YRUM1Vi01S1NNRFQtWUpUVTA5LUpRUTcyRiI7YjoxO3M6Mjc6IlU4VFFPVS1ZQjFZM0otVUxSVVNDLVhWSVpCWSI7YjoxO3M6Mjc6IkVRTk9UNC1KS
base64decoded, _ := base64.StdEncoding.DecodeString(str)
out, _ := gophp.Unserialize([]byte(base64decoded))
if mout, ok := out.(map[string]interface{}); ok {
if _, ok := mout[fdata].(map[string]interface{}); ok {
return true
}
return false
}
}
//Check Corporate License
isArticaLicense := GetSocketInfoInt("isArticaLicense")
if isArticaLicense == 1 {
return true
}
corp, _ := os.Open("/etc/artica-postfix/settings/Daemons/CORP_LICENSE")
defer corp.Close()
scannerCorp := bufio.NewScanner(corp)
for scannerCorp.Scan() {
fdata := strings.TrimSpace(scannerCorp.Text())
if len(fdata) == 0 {
return false
}
if fdata == "VFJVRQ==" {
return true
}
return false
}
return false
}