コード例 #1
0
ファイル: RenameTest.cs プロジェクト: yonglehou/dropkick
        public void NoExist()
        {
            var task = new RenameTask(_doesntExist, _renameTo, new DotNetPath());
            var o    = task.VerifyCanRun();

            Assert.IsTrue(o.ContainsError());
        }
コード例 #2
0
ファイル: RenameTest.cs プロジェクト: yonglehou/dropkick
        public void OriginalFileNoLongerExists()
        {
            var task = new RenameTask(_sourceFile, _renameTo, new DotNetPath());

            task.Execute();

            Assert.IsFalse(File.Exists(_sourceFile));
        }
コード例 #3
0
ファイル: RenameTest.cs プロジェクト: yonglehou/dropkick
        public void RenameFileWorks()
        {
            var task = new RenameTask(_sourceFile, _renameTo, new DotNetPath());

            task.Execute();

            Assert.IsTrue(File.Exists(_renameTo));
        }
コード例 #4
0
ファイル: ProtoRenameTask.cs プロジェクト: GorelH/dropkick
        public override void RegisterRealTasks(PhysicalServer site)
        {
            string target = PathConverter.Convert(site, _target);
            string newName = PathConverter.Convert(site, _newName);

            var o = new RenameTask(target, newName, new DotNetPath());
            site.AddTask(o);
        }
コード例 #5
0
        public override void RegisterRealTasks(PhysicalServer site)
        {
            string target  = PathConverter.Convert(site, _target);
            string newName = PathConverter.Convert(site, _newName);

            var o = new RenameTask(target, newName, new DotNetPath());

            site.AddTask(o);
        }
コード例 #6
0
ファイル: ProtoRenameTask.cs プロジェクト: oriacle/dropkick
        public override void RegisterRealTasks(PhysicalServer site)
        {
            string target = _target;
            string newName = _newName;
            target = RemotePathHelper.Convert(site, target);

            var o = new RenameTask(target, newName, new DotNetPath());
            site.AddTask(o);
        }
コード例 #7
0
        public override void RegisterRealTasks(PhysicalServer site)
        {
            string target = site.MapPath(_target);
            string newName = site.MapPath(_newName);

            if (!Path.IsPathRooted(_newName))
                newName = site.MapPath(Path.Combine(Path.GetDirectoryName(_target), _newName));

            var o = new RenameTask(target, newName, new FileSystem.DotNetPath(), _deleteDestination);
            site.AddTask(o);
        }
コード例 #8
0
ファイル: ProtoRenameTask.cs プロジェクト: oriacle/dropkick
        public override void RegisterRealTasks(PhysicalServer site)
        {
            string target  = _target;
            string newName = _newName;

            target = RemotePathHelper.Convert(site, target);

            var o = new RenameTask(target, newName, new DotNetPath());

            site.AddTask(o);
        }
コード例 #9
0
        public static string Process(Context ctx, LogInfo info, LogWarn war, LogErr err)
        {
            try
            {
                string      startobf = "Starting ";
                ModuleDefMD module   = ModuleDefMD.Load(ctx.FileName);
                module.GlobalType.FindOrCreateStaticConstructor();
                foreach (TaskID task in ctx.TasksList)
                {
                    switch (task)
                    {
                    case AntiDebugTask.ID:
                    {
                        info(startobf + "Anti-Debug Task...");
                        AntiDebugTask.Execute(module);
                    } break;

                    case StringEncodingTask.ID:
                    {
                        info(startobf + "String encoding Task...");
                        StringEncodingTask.Execute(module);
                    } break;

                    case ControlFlowTask.ID:
                    {
                        info(startobf + "Control Flow Task...");
                        ControlFlowTask.Execute(module);
                    } break;

                    case InvalidMDTask.ID:
                    {
                        info(startobf + "Invalid Metadata Task...");
                        InvalidMDTask.Execute(module);
                    } break;

                    case RenameTask.ID:
                        RenameTask.IsObfuscationActive = true; break;
                    }
                }
                info(startobf + "Rename Task..." + Environment.NewLine);
                RenameTask.Execute(module);
                module.Write(ctx.NewPath, new ModuleWriterOptions()
                {
                    Listener = NETUtils.listener
                });
                return(ctx.NewPath);
            }
            catch (Exception ex)
            {
                err(ex.Message);
                return("");
            }
        }
コード例 #10
0
ファイル: ControlFlowTask.cs プロジェクト: xHeaven/Isolated
        public static Dictionary <MethodDef, Tuple <int[], int[]> > CreateMethods(ModuleDef loadedMod)
        {
            DynamicCode code = new DynamicCode(3);

            int[] modules = new int[4];
            for (int i = 0; i < modules.Length; i++)
            {
                modules[i] = rand.Next(2, 25);
            }
            Instruction[,] methods = new Instruction[4, 10];
            for (int i = 0; i < 4; i++)
            {
                Instruction[] methodBody = code.Create();
                for (int y = 0; y < methodBody.Length; y++)
                {
                    methods[i, y] = methodBody[y];
                }
            }

            List <Tuple <Instruction[], Tuple <int, Tuple <int[], int[]> > > > InstrToInt =
                new List <Tuple <Instruction[], Tuple <int, Tuple <int[], int[]> > > >();

            for (int i = 0; i < 4; i++)
            {
                List <Instruction> instr = new List <Instruction>();
                int[] numbersTrue        = new int[5];
                int[] numbersFalse       = new int[5];
                for (int y = 0; y < 10; y++)
                {
                    instr.Add(methods[i, y]);
                }
                for (int y = 0; y < 5; y++)
                {
                    numbersTrue[y] = code.RandomNumberInModule(instr.ToArray(), modules[i], true);
                }
                for (int y = 0; y < 5; y++)
                {
                    numbersFalse[y] = code.RandomNumberInModule(instr.ToArray(), modules[i], false);
                }
                InstrToInt.Add(Tuple.Create(instr.ToArray(), Tuple.Create(modules[i], Tuple.Create(numbersTrue, numbersFalse))));
            }
            Dictionary <MethodDef, Tuple <int[], int[]> > final = new Dictionary <MethodDef, Tuple <int[], int[]> >();
            MethodAttributes methFlags = MethodAttributes.Public | MethodAttributes.Static
                                         | MethodAttributes.HideBySig | MethodAttributes.ReuseSlot;
            MethodImplAttributes methImplFlags = MethodImplAttributes.IL | MethodImplAttributes.Managed;

            for (int i = 0; i < 4; i++)
            {
                MethodDef methodDefs1 = new MethodDefUser(
                    "",
                    MethodSig.CreateStatic(loadedMod.CorLibTypes.Boolean, loadedMod.CorLibTypes.Int32),
                    methImplFlags, methFlags);
                RenameTask.Rename(methodDefs1);
                methodDefs1.Body = new CilBody();
                methodDefs1.ParamDefs.Add(new ParamDefUser("lol", 0));
                List <Instruction> preInstr = new List <Instruction>(InstrToInt[i].Item1);
                int module = InstrToInt[i].Item2.Item1;
                //preInstr.RemoveAt(preInstr.Count - 1);
                preInstr.Insert(preInstr.Count - 1, Instruction.CreateLdcI4(module));
                preInstr.Insert(preInstr.Count - 1, OpCodes.Rem.ToInstruction());
                preInstr.Insert(preInstr.Count - 1, Instruction.CreateLdcI4(0));
                preInstr.Insert(preInstr.Count - 1, Instruction.Create(OpCodes.Ceq));
                //preInstr.Insert(preInstr.Count - 1, Instruction.Create(OpCodes.Ret));
                foreach (var item in preInstr)
                {
                    methodDefs1.Body.Instructions.Add(item);
                }
                final.Add(methodDefs1, InstrToInt[i].Item2.Item2);
            }

            TypeDef type1 = new TypeDefUser("", "", loadedMod.CorLibTypes.Object.TypeDefOrRef);

            RenameTask.Rename(type1);
            type1.Attributes = dnlib.DotNet.TypeAttributes.Public | dnlib.DotNet.TypeAttributes.AutoLayout |
                               dnlib.DotNet.TypeAttributes.Class | dnlib.DotNet.TypeAttributes.AnsiClass;
            loadedMod.Types.Add(type1);
            foreach (var item in final)
            {
                type1.Methods.Add(item.Key);
            }
            return(final);
        }
コード例 #11
0
ファイル: RenameTest.cs プロジェクト: yonglehou/dropkick
        public void RemoteRename()
        {
            var task = new RenameTask(@"\\srvtestwebtpg\E$\FHLB MQApps\BloombergIntegration\bin\des.exe", "hi.exe", new DotNetPath());

            task.Execute();
        }
コード例 #12
0
ファイル: RenameTest.cs プロジェクト: yonglehou/dropkick
        public void RenameOnTopOfConflictingFile()
        {
            var task = new RenameTask(_sourceFile, _conflictFile, new DotNetPath());

            task.Execute();
        }
コード例 #13
0
ファイル: RenameTest.cs プロジェクト: yonglehou/dropkick
        public void NameIsDescriptive()
        {
            var task = new RenameTask(_sourceFile, _renameTo, new DotNetPath());

            Assert.AreEqual(@"Rename '.\stuff.txt' to 'notstuff.txt'.", task.Name);
        }