tiamat/cmd/server.go

48 lines
1.0 KiB
Go
Raw Normal View History

2024-06-03 09:24:18 +02:00
/*
Copyright © 2024 raul <raul@bulgariu.xyz
*/
package cmd
import (
"github.com/spf13/cobra"
"log"
2024-06-03 09:24:18 +02:00
)
// serverCmd represents the server command
var serverCmd = &cobra.Command{
Use: "server",
Short: "Tiamat Server",
Long: `Tiamat Server including the C2 server and the Web server`,
2024-06-03 09:24:18 +02:00
Run: func(cmd *cobra.Command, args []string) {
if err := setServerParameters(cmd); err != nil {
log.Fatalf("Error happened trying to set parameters: %v\n", err)
}
2024-06-03 09:24:18 +02:00
Server()
},
}
func init() {
rootCmd.AddCommand(serverCmd)
serverCmd.PersistentFlags().StringP("clients", "c", "", "File to recover clients from")
serverCmd.Flags().Bool("insecure", false, "[UNSAFE] Do not use TLS encryption")
}
2024-06-03 09:24:18 +02:00
func setServerParameters(cmd *cobra.Command) error {
parameterClients, err := cmd.Flags().GetString("clients")
if err != nil {
return err
}
if parameterClients != "" {
isUsingJSONParameter = true
clientJSONPath = parameterClients
}
insecure, err := cmd.Flags().GetBool("insecure")
if insecure == true {
servInsecure = true
}
return nil
2024-06-03 09:24:18 +02:00
}