forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented config generation commands.
Velociraptor can now generate its own config, as well as rotate the server keys. Velociraptor client verifies server keys are signed by CA and serial numbers are incremented properly.
- Loading branch information
Showing
16 changed files
with
837 additions
and
549 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"gopkg.in/alecthomas/kingpin.v2" | ||
"www.velocidex.com/golang/velociraptor/config" | ||
"www.velocidex.com/golang/velociraptor/crypto" | ||
"www.velocidex.com/golang/velociraptor/logging" | ||
) | ||
|
||
func doShowConfig() { | ||
config_obj, err := get_config(*config_path) | ||
kingpin.FatalIfError(err, "Unable to load config.") | ||
|
||
res, err := config.Encode(config_obj) | ||
if err != nil { | ||
kingpin.FatalIfError(err, "Unable to encode config.") | ||
} | ||
fmt.Printf("%v", string(res)) | ||
} | ||
|
||
func doGenerateConfig() { | ||
config_obj := config.GetDefaultConfig() | ||
logger := logging.NewLogger(config_obj) | ||
ca_bundle, err := crypto.GenerateCACert(2048) | ||
if err != nil { | ||
logger.Error("Unable to create CA cert", err) | ||
return | ||
} | ||
|
||
config_obj.Client.CaCertificate = ca_bundle.Cert | ||
config_obj.CA.PrivateKey = ca_bundle.PrivateKey | ||
|
||
frontend_cert, err := crypto.GenerateServerCert(config_obj) | ||
if err != nil { | ||
logger.Error("Unable to create Frontend cert", err) | ||
return | ||
} | ||
|
||
config_obj.Frontend.Certificate = frontend_cert.Cert | ||
config_obj.Frontend.PrivateKey = frontend_cert.PrivateKey | ||
|
||
// Users have to updated the following fields. | ||
config_obj.Client.ServerUrls = []string{"http://localhost:8000/"} | ||
|
||
res, err := config.Encode(config_obj) | ||
if err != nil { | ||
logger.Error("Unable to create CA cert", err) | ||
return | ||
} | ||
fmt.Printf("%v", string(res)) | ||
} | ||
|
||
func doRotateKeyConfig() { | ||
config_obj, err := get_config(*config_path) | ||
kingpin.FatalIfError(err, "Unable to load config.") | ||
logger := logging.NewLogger(config_obj) | ||
frontend_cert, err := crypto.GenerateServerCert(config_obj) | ||
if err != nil { | ||
logger.Error("Unable to create Frontend cert", err) | ||
return | ||
} | ||
|
||
config_obj.Frontend.Certificate = frontend_cert.Cert | ||
config_obj.Frontend.PrivateKey = frontend_cert.PrivateKey | ||
|
||
res, err := config.Encode(config_obj) | ||
if err != nil { | ||
kingpin.FatalIfError(err, "Unable to encode config.") | ||
} | ||
fmt.Printf("%v", string(res)) | ||
} | ||
|
||
func doDumpClientConfig() { | ||
config_obj, err := get_config(*config_path) | ||
kingpin.FatalIfError(err, "Unable to load config.") | ||
|
||
client_config := config.NewClientConfig() | ||
client_config.Client = config_obj.Client | ||
|
||
res, err := config.Encode(client_config) | ||
if err != nil { | ||
kingpin.FatalIfError(err, "Unable to encode config.") | ||
} | ||
fmt.Printf("%v", string(res)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.