-
Notifications
You must be signed in to change notification settings - Fork 45
4. Extending PersistAssist
The PersistAssist framework is heavily reliant on the concept of reflection. Reflection in the context of C# is essentially the ability to obtain information of a program during runtime. PersistAssist uses this concept to compile a list of objects inheriting from certain classes at runtime and referencing these lists throughout the execution of its processes. It does so by inheriting from what are known as abstract classes, these are classes that act as "blueprints" a class can use to essentially become that type.
The abstract classes have two types of variables: abstract and virtual. abstract variables are those that are required to be defined for the class to function and virtual are optional variables.
The persistence module pulls from Persist.cs file
public abstract class Persist {
public abstract string PersistName { get; }
public abstract string PersistDesc { get; }
public abstract string PersistUsage { get; }
public abstract PersistType PersistCategory { get; }
public abstract string PersistExec(ParsedArgs pArgs);
public abstract string PersistCleanup(ParsedArgs pArgs);
public virtual string Author { get; }
}
- PersistName - name of the function that will be used to ID the function
- PersistDesc - description of the function for the help and info pages
- PersistUsage - how to use the technique for both deploying and cleaning up persistence
- PersistCategory - categorizes the technique based on the PersistType enumeration, requires importing the
PersistAssist.Utils.Data
namespace - PersistExec - deploys persistence technique
- PersistCleanup - cleans up persistence
- Author - author of persistence technique
To create a new Persist module, inherit the Persist abstract class (requires importing the PersistAssist.Utils
namespace) and implement the abstract class. Fill out the info variables and include the deploying code in the PersistExec()
and cleanup code in the PersistCleanup()
methods
The tradecraft module pulls from the Tradecraft.cs file
public abstract class Tradecraft {
public abstract string TradecraftName { get; }
public abstract string TradecraftDesc { get; }
public abstract string TradecraftUsage { get; }
public virtual string Author { get; }
public abstract string TradecraftTask(ParsedArgs pArgs);
}
- TradecraftName - name of tradecraft utility
- TradecraftDesc - description of module for help and info pages
- TradecraftUsage - usage information for tradecraft module
- Author - author of tradecraft module
- TradecraftTask - perform tradecraft utility
To create a new Tradecraft module, inherit the Tradecraft abstract class (requires importing the PersistAssist.Utils
namespace) and implement the abstract class. Fill out the info variables and include the code for the utility in the TradecraftTask()
method
The payloads module pulls from the Payloads.cs file
public abstract class Payload {
public abstract string PayloadName { get; }
public abstract string PayloadDesc { get; }
public abstract string[] PayloadNamespaces { get; }
public abstract string PayloadCode { get; }
public virtual string Author { get; }
}
- PayloadName - name of the payload
- PayloadDesc - description of the payload
- PayloadNamespaces (v0.2 will change this to virtual) - array of namespaces a payload uses for compilation in the case of C# payloads
- PayloadCode - payload
- Author - author of payload
To create a new Payload module, inherit the Payload abstract class (requires importing the PersistAssist.Utils
namespace) and implement the abstract class. Fill out the info variables and include the paylaod code in the PayloadCode
variable.
Adding arguments involves modifying two files: Program.cs and ParsedArgs.cs. Add in the name of the argument in the ParsedArgs class in the ParsedArgs.cs file and then create an entry for the argument in the OptionSet method in Program.cs. The format to add a new argument entry is as follows:
{ "[argument]", "[argument description]", opt => pArgs.[arguement name] = opt}
Note that if its not the last entry, a comma is required after the closing brace