-
Notifications
You must be signed in to change notification settings - Fork 3
Allow Configurator on secure desktop only (release mode) #95
Conversation
@@ -0,0 +1,12 @@ | |||
{ | |||
"application_name": "CageConfigurator", | |||
"application_path": "C:\\sharkcage\\CageConfigurator.exe", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently enhancing our installer. The application_path
must be written by the installer or? It depends on the target folder specified by the user while installing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we can change the path to a placeholder and then replace it when installing
using System.IO; | ||
using System.Security.AccessControl; | ||
using System.Security.Cryptography; | ||
using System.Security.Principal; | ||
|
||
namespace CageServiceInstaller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have to rename the project...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, thx a lot 👍!!!
If I build the solution with release target, the cage manager will not be started by the chooser when selecting an config and pressing the start button. Only a error with message "Error communicating with service: Starting CageManager failed." is displayed.
If I start the CageManager
manually before pressing the start button in the CageChooser
, the desktop is switched and everything seems to be fine. After switching back, the same error message is displayed.
@@ -49,11 +49,11 @@ private void LoadConfigList() | |||
{ | |||
foreach (var value_name in key.GetValueNames()) | |||
{ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls remove this empty newline.
} | ||
} | ||
|
||
// FIXME might be easier to ask the service for this info in the future? :/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should create an issue for that? Otherwise we can remove the FIXME.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -91,6 +94,7 @@ private void CheckPath(string path, string[] file_types, Action<string> onSucces | |||
return path.EndsWith(type); | |||
}); | |||
|
|||
// fixme: check if path contains cage configurator and disallow it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should create an issue for that as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can just be deleted as we now explicitely want to be able to create a config for the Configurator
@SailReal Regarding your issue with the release mode: Did you copy all necessary files into the 'install folder'? If yes, did you recreate the config with the new release binary of the Configurator? I think I know why (from the Service):
In release mode the Manager must be signed ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SailReal
can't request changes on my own PR :) additional things:
- can you remove the Configurator desktop shortcut? it cannot be launched with the shortcut anyway
apart from the comments your changes look good, thx!
UninstallService(); | ||
} | ||
|
||
private void AssimilateConfigToCurrentSystem(string dir_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite get the name of this function, why 'assimilate'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant something like customize...?
{ | ||
var config_path = Path.Combine( | ||
Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), | ||
"SharkCage\\CageConfigurator.sconfig"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use @"one\slash\only"
if you don't want to use characters which are needed to be escaped (with @
everything is interpreted literally
const string APPLICATION_HASH_PROPERTY = "binary_hash"; | ||
var path_to_config_exe = Path.Combine(dir_path, "CageConfigurator.exe"); | ||
|
||
var json = JObject.Parse(File.ReadAllText(config_path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the json parsing can fail (if the file is missing or has a different structure), do we need a try catch here or does the installer handle it for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The installer is handling the exception and also will rollback all changes on the system, will display an error message with the content of the exception so nothing to do for us I think...
var json = JObject.Parse(File.ReadAllText(config_path)); | ||
var application_path = json.GetValue(APPLICATION_PATH_PROPERTY).ToString(); | ||
json[APPLICATION_PATH_PROPERTY] = path_to_config_exe; | ||
json[APPLICATION_HASH_PROPERTY] = GetSha512Hash(path_to_config_exe); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure patching the hash on the target system is a good idea. We can generate the hash once before creating the installer and just patch the correct path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hash looks different on our machines with the same target (debug) so I thought it will be the same result with the release target. I don't know what but something on the system must have an influence on the calculation of the hash over the binary. So I think the only way is it to calculate the hash on the target system but I think that should not decrease the security at all especially because up to the point of installation, the config is writable.
Maybe we should create an issue for that to think about how we can install the cage in a secure way on a already infected system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the hash only changes on creation. once it is created and signed the hash can be written to the config and the binary hash must be the same on the target machine for us to be sure there was no tampering during distribution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will create an issue for that.
@DonatJR I used the installer to copy all files and also created new configs. Is it working on your device? |
oh nooooo you're right, the |
Shouldn´t there be a default entry in |
@bencikpeter |
fixes #55
regarding WIP: @SailReal the
CageConfigurator.sconfig
file must be copied to the public documents folder on install and the registry needs to have a corresponding entry!! Only merge this after #91 !!