Open rosch100 opened 1 year ago
By (re)signing the executable appended MSH file is stripped of.
On adding MSH data there is some Modification to signature record done (in exeHandler.js).
I did try to place an executable with my signature into MeshCentral (at path /opt/meshcentral/meshcentral/agents/MeshCentralAssistant.exe).
After download it does contain MSH data but signature is do longer displayed in file.explorer.
There seems to be some trick required.
Just found an Solution to handle that.
Patching config-Data into signed executable is not the best idea. Therefore I added an Option to Embedd config as an Asembly-Resource.
The Modification required in Assistant is in PullRequest "Optional loading MSH File from Resource".
To Add your config to exe you can use this minimal C#-Program. Invocation as AddRes.exe OLD_EXE MSF_FILE NEW_EXE:
using System; using System.IO; using Mono.Cecil;
namespace AddRes { internal class Program { static void Main(string[] args) { Console.WriteLine("{0} + {1} => {2}",args[0],args[1],args[2]); AssemblyDefinition asdDefinition = AssemblyDefinition.ReadAssembly(args[0]); EmbeddedResource erTemp = new EmbeddedResource("msh", ManifestResourceAttributes.Public,File.ReadAllBytes(args[1])); asdDefinition.MainModule.Resources.Add(erTemp); asdDefinition.Write(args[2]); } } }
When code-signing a customised assistant, the newly signed exe does not recognise the (embedded) msh file anymore and thus cannot connect to my server.
Debug output:
It kind of works with an external msh file, but since I could only find an agent msh file, the assistant now lost the custom icon and name and is residing in the tray.