Covenant Compiled tasks
While trying to update some of covenants submodules, namely rubeus, to latest version , i was faced with few problems, with latest version , that refused to compile with covenant's roslyn compiler.
If you're facing the same problem , long story short , disable optimization by Modify line 212 from Covenant/Covenant/Models/Grunts/GruntTask.cs , refer to this blog post for detailed guide.
But before i knew that ,i resorted to a quick and dirty way to add or modify tasks, which also resolved the problem of rubeus having two different versions now , one for .NET 3.5 and one for .NET 4.0
And so this blog post will be a brief high level guide on how to add compiled tasks , since i didn't see anyone talk about this way of adding tasks that might be a bit faster and easier to do and saves debugging time in case some wierd compilation error happens.
Adding compiled tasks:
i will take rubeus as an example ,but this should work for any other .NET project , so first create the task (or modifying if existing ) to include this line :
for rubeus task this line is in GhostPack.yaml, this will tell covenant to not recompile the task again from source code each time you run the task , cool feature prob was made first for debugging and now it comes to the rescue.
Next we need to compile rubeus , after adding a class tha contains the actual task code to the source code : then we simply compile for .NET 4.0 for now ,then take the compiled Rubeus.exe and use this powershell script i made to compress the file and output the Rubeus.compiled file: it's important that the name is Rubeus.compiled (Task name case sensitive +".compiled")
We then copy the result file in "Covenant\Data\Tasks\CSharp\Compiled\net40" and simply run the task and voila: latest version running , now the coolest part, we do the same steps but with rubeus last .NET 3.5 release rubeus 1.6, create the task and add to the project, compile for .NET 3.5 , compress with the powershell script , then copy the new Rubeus.compiled to "Covenant\Data\Tasks\CSharp\Compiled\net35": And now when we run the task from a .NET 3.5 grunt u get the 1.6 version and , 2.2 version when u run from 4.0 , worth noting , obviously , if you're adding tasks this way , then you might also consider obfuscating manually since now covenant is not compiling nor obfuscating the task for you.
My other contributions to covenant:
My pull request to covenant
My covenant instance , most of the work is in the dev branch.