Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private static IAttack SmbServerOutputExample()
        {
            var HOSTNAME        = "HostnameB";
            var HOST            = Host.GetHostByHostName(HOSTNAME) ?? new Host(HOSTNAME, HOSTNAME, null);
            var smbSharename    = "BearShare";
            var smbServerOutput = new SmbServerOutput(smbSharename, HOST); // the default port is 445
            var attackName      = "SmbServerOutput";
            var attack          = new Attack(new IOutput[] {
                smbServerOutput,
            }, name: attackName);

            // SmbServerOutput has the same Add methods as SamplesOutput
            var javascript = new JavaScript("WScript.Echo(1337);");
            // Adding randomization to sample filenames can be useful sometimes
            var sampleAFilename = "SmbServerOutputExampleA" + MyWarez.Core.Utils.RandomString(10) + ".js";

            smbServerOutput.Add(sampleAFilename, javascript);

            attack.Generate();
            // a file should now be in $(ProjectDir)\bin\$(Configuration)\$(TargetFramework)\Output\Server\HostnameB\445_SMB_Server\BearShare
            return(attack);
        }