Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
#55 simplified CageServiceInstaller #95
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Aug 5, 2018
1 parent 785dc6d commit efb0696
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 200 deletions.
34 changes: 29 additions & 5 deletions SharkCage/CageServiceInstaller/CageServiceInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,46 @@ public override void Uninstall(System.Collections.IDictionary saved_state)

private void AssimilateConfigToCurrentSystem(string dir_path)
{
const string APPLICATION_PATH_PROPERTY = "application_path";
const string APPLICATION_HASH_PROPERTY = "binary_hash";
var path_to_config_exe = dir_path + "CageConfigurator.exe";

var config_path = Environment.ExpandEnvironmentVariables("%SystemDrive%\\Users\\Public\\Documents\\SharkCage\\CageConfigurator.sconfig");
var config_path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments),
"SharkCage\\CageConfigurator.sconfig");

Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\SharkCage\Configs", "CageConfigurator", config_path);

MoveConfigFileToConfigPath(config_path, dir_path);

UpdateContentOfConfigFile(config_path, dir_path);

UpdateSecurityAclsOfConfigFile(config_path);
}

private void MoveConfigFileToConfigPath(string config_path, string dir_path)
{
if (File.Exists(config_path))
{
File.Delete(config_path);
}

File.Move(Path.Combine(dir_path, "CageConfigurator.sconfig"), config_path);
}

private void UpdateContentOfConfigFile(string config_path, string dir_path)
{
const string APPLICATION_PATH_PROPERTY = "application_path";
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));
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);
var output = Newtonsoft.Json.JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented);

File.WriteAllText(config_path, output);
}

private void UpdateSecurityAclsOfConfigFile(string config_path)
{
// generate acl for config (only admin group has access)
IdentityReference built_in_administrators = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
var file_security = new FileSecurity();
Expand Down
222 changes: 27 additions & 195 deletions SharkCage/SharkCageInstaller/SharkCageInstaller.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@
}
"Entry"
{
"MsmKey" = "8:_3C925011CD3F7A18E7C91E8C89EDC65C"
"OwnerKey" = "8:_63AF181CABB14A408EE15B685CD7A728"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_3CFED900173BECEED806865EB74E4812"
"OwnerKey" = "8:_01BBBCE4106E46A891E20AE0FAFF7469"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -459,12 +453,6 @@
}
"Entry"
{
"MsmKey" = "8:_7E6086BEF17877E802D69EF59547AB90"
"OwnerKey" = "8:_63AF181CABB14A408EE15B685CD7A728"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_8367362E667E948AFD8AE6203AA507EB"
"OwnerKey" = "8:_01BBBCE4106E46A891E20AE0FAFF7469"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -501,12 +489,6 @@
}
"Entry"
{
"MsmKey" = "8:_8C5442F1C142C4B47D4DC84A72BEA129"
"OwnerKey" = "8:_63AF181CABB14A408EE15B685CD7A728"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_8D7AC36FA6BE4AAD055FE668EBCF5267"
"OwnerKey" = "8:_01BBBCE4106E46A891E20AE0FAFF7469"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -621,12 +603,6 @@
}
"Entry"
{
"MsmKey" = "8:_A62535A58545AB110BF0AED9ADCA4562"
"OwnerKey" = "8:_63AF181CABB14A408EE15B685CD7A728"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_A9BF1F96E92374873E687211E9C4DC83"
"OwnerKey" = "8:_01BBBCE4106E46A891E20AE0FAFF7469"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -687,12 +663,6 @@
}
"Entry"
{
"MsmKey" = "8:_B60E9FE7870E3C84880B2437C5BD152D"
"OwnerKey" = "8:_63AF181CABB14A408EE15B685CD7A728"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_B73685C8ABA69CA445108E043DD47C9F"
"OwnerKey" = "8:_40C4E63BE603F64D57323B523CD3CCAD"
"MsmSig" = "8:_UNDEFINED"
Expand All @@ -717,12 +687,6 @@
}
"Entry"
{
"MsmKey" = "8:_BDF9499DE863E742DA3F3B6C12B0FF21"
"OwnerKey" = "8:_63AF181CABB14A408EE15B685CD7A728"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_BF3B974444DE732260E6F4DCC2B13182"
"OwnerKey" = "8:_AE0CA5D7FDCCBB78382954AA3E3F9645"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -1245,6 +1209,12 @@
}
"Entry"
{
"MsmKey" = "8:_C3C5E1F5C500495982ECAFEF6106BDE7"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_C4761DB3A6CE86BF69C267529A8B08C9"
"OwnerKey" = "8:_01BBBCE4106E46A891E20AE0FAFF7469"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -1341,12 +1311,6 @@
}
"Entry"
{
"MsmKey" = "8:_CDF3FA1DF0EB4D86940A3E55AB5E8871"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_CE9921615B010F306E9BCF36EC662AFF"
"OwnerKey" = "8:_01BBBCE4106E46A891E20AE0FAFF7469"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -3253,26 +3217,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_3C925011CD3F7A18E7C91E8C89EDC65C"
{
"SourcePath" = "8:NETAPI32.dll"
"TargetName" = "8:NETAPI32.dll"
"Tag" = "8:"
"Folder" = "8:_AF35AA7C0DA64CECA8201B61E6196592"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_3CFED900173BECEED806865EB74E4812"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -4243,26 +4187,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7E6086BEF17877E802D69EF59547AB90"
{
"SourcePath" = "8:VCRUNTIME140D.dll"
"TargetName" = "8:VCRUNTIME140D.dll"
"Tag" = "8:"
"Folder" = "8:_AF35AA7C0DA64CECA8201B61E6196592"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_8367362E667E948AFD8AE6203AA507EB"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -4418,26 +4342,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8C5442F1C142C4B47D4DC84A72BEA129"
{
"SourcePath" = "8:gdiplus.dll"
"TargetName" = "8:gdiplus.dll"
"Tag" = "8:"
"Folder" = "8:_AF35AA7C0DA64CECA8201B61E6196592"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_8D7AC36FA6BE4AAD055FE668EBCF5267"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -4996,26 +4900,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A62535A58545AB110BF0AED9ADCA4562"
{
"SourcePath" = "8:MSVCP140D.dll"
"TargetName" = "8:MSVCP140D.dll"
"Tag" = "8:"
"Folder" = "8:_AF35AA7C0DA64CECA8201B61E6196592"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A9BF1F96E92374873E687211E9C4DC83"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -5326,26 +5210,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B60E9FE7870E3C84880B2437C5BD152D"
{
"SourcePath" = "8:RPCRT4.dll"
"TargetName" = "8:RPCRT4.dll"
"Tag" = "8:"
"Folder" = "8:_AF35AA7C0DA64CECA8201B61E6196592"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_B73685C8ABA69CA445108E043DD47C9F"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -5439,26 +5303,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_BDF9499DE863E742DA3F3B6C12B0FF21"
{
"SourcePath" = "8:ucrtbased.dll"
"TargetName" = "8:ucrtbased.dll"
"Tag" = "8:"
"Folder" = "8:_AF35AA7C0DA64CECA8201B61E6196592"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_BF3B974444DE732260E6F4DCC2B13182"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -5676,6 +5520,26 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C3C5E1F5C500495982ECAFEF6106BDE7"
{
"SourcePath" = "8:..\\special_configs\\CageConfigurator.sconfig"
"TargetName" = "8:CageConfigurator.sconfig"
"Tag" = "8:"
"Folder" = "8:_AF35AA7C0DA64CECA8201B61E6196592"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_C4761DB3A6CE86BF69C267529A8B08C9"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -6110,26 +5974,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CDF3FA1DF0EB4D86940A3E55AB5E8871"
{
"SourcePath" = "8:..\\special_configs\\CageConfigurator.sconfig"
"TargetName" = "8:CageConfigurator.sconfig"
"Tag" = "8:"
"Folder" = "8:_CAE5CEE96E7744C9AE7E53D74A96D9D5"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_CE9921615B010F306E9BCF36EC662AFF"
{
"AssemblyRegister" = "3:1"
Expand Down Expand Up @@ -7317,18 +7161,6 @@
}
}
}
"{994432C3-9487-495D-8656-3E829A8DBDDE}:_CAE5CEE96E7744C9AE7E53D74A96D9D5"
{
"DefaultLocation" = "8:[WindowsVolume]Users\\Public\\Documents\\SharkCage"
"Name" = "8:CageConfigsFolder"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:NEWPROPERTY1"
"Folders"
{
}
}
}
"LaunchCondition"
{
Expand All @@ -7346,7 +7178,7 @@
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:SharkCage"
"ProductCode" = "8:{ABDFC121-DD3E-48A6-93D2-775E2B08A35F}"
"PackageCode" = "8:{6D1714ED-E152-46B6-81F1-C56FE4AC0F9F}"
"PackageCode" = "8:{3908E1A0-A824-4BF4-A6FB-D1970D1CCBC1}"
"UpgradeCode" = "8:{593757A6-95D5-412D-A2FF-7530C14252A4}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
Expand Down

0 comments on commit efb0696

Please sign in to comment.