private static IAttack OutputSkeletonTemplateExample() { var HOSTNAME = "HostnameA"; // fetch the Host instance created in MyWarez.Base.Utils.InitHosts using the hosts.yaml file provided, if one does not exist, then create one. var HOST = Host.GetHostByHostName(HOSTNAME) ?? new Host(HOSTNAME, HOSTNAME, null); // "Output"s produce the files and dependencies necessary to reproduce the attack. // SamplesOutput // Used to bookkeep sample files var samplesOutput = new SamplesOutput(); // RemoteFileServerOutput // A generic output for files on a remote server // Can be used to bookkeep things like reverseshell listeners // Be mindful of which ports on a particular virtual host will already be used... var genericServerOutput = new RemoteFileServerOutput(HOST, port: 1337, name: "GenericName"); // SmbServerOutput // Used to bookkeep files on a SMB fileshare var smbSharename = "SomeShare"; var smbServerOutput = new SmbServerOutput(smbSharename, HOST); // HttpServerOutput // Used to bookkeep files on an HTTP server var httpServerOutput = new HttpServerOutput(HOST); // HtmlmthServerOutput // Used to bookkeep the files need for an HTMLMTH server instance // A HTMLMTH server is used mostly used for client side HTML+HTTP evasions. But can also be used as an HTTP server var htmlmthServerOutput = new HtmlmthServerOutput(HOST); // An Attack is a collection of everything required to generate the sample(s) + dependencies necessary to reproduce an attack // So, a collection of Output var attackName = "OutputSkeletonTemplate"; // Give a descriptive & identifiable name var attackNotes = "OutputSkeletonTemplate notes"; var attack = new Attack(new IOutput[] { samplesOutput, genericServerOutput, smbServerOutput, httpServerOutput, htmlmthServerOutput }, name: attackName, notes: attackNotes); // Not all the Output are required. So if one is not going to be used, omit it. // .. Code to bookkeep Output files here... // Serialize the attack to disk. // The output will be in the directory: $(ProjectDir)\bin\$(Configuration)\$(TargetFramework)\Output // Since nothing was added to the Outputs, the folder should be empty attack.Generate(); return(attack); }
private static IAttack HttpServerOutputExample() { var HOSTNAME = "HostnameB"; var HOST = Host.GetHostByHostName(HOSTNAME) ?? new Host(HOSTNAME, HOSTNAME, null); var httpServerOutput = new HttpServerOutput(HOST); // the default port is 80 var attackName = "HttpServerOutput"; var attack = new Attack(new IOutput[] { httpServerOutput, }, name: attackName); // The files placed in "$(ProjectDir)\Resources" or "$(ProjectDir)\..\Resources" will be available for use // This is useful for bringing in your own exploits, payloads, Output files, etc var sampleAResourcePath = Path.Join(MyWarez.Core.Constants.ResourceDirectory, "HttpServerOutput.html"); var sampleAResourceText = File.ReadAllText(sampleAResourcePath); var html = new OnePageWebsite(sampleAResourceText); var sampleAFilename = "/somepath/HttpServerOutputExampleA.html"; // HttpServerOutput has the same Add methods as SamplesOutput httpServerOutput.Add(sampleAFilename, html); attack.Generate(); // The file should now be at $(ProjectDir)\bin\$(Configuration)\$(TargetFramework)\Output\Server\HostnameB\80_HTTP_Server\wwwroot\somepath\HttpServerOutputExampleA.html return(attack); }